mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
To: davem@redhat.com
Cc: linux-kernel@vger.kernel.org
Subject: [patch 2.5] net: severe bug in icmp stats
Date: Tue, 1 Apr 2003 18:57:07 +0400	[thread overview]
Message-ID: <20030401185707.A955@jurassic.park.msu.ru> (raw)

I believe many of those weird crash reports with recent 2.5
kernels can be explained by wrong pointer arithmetic in
ICMP_INC_STATS_xx_FIELD macros.

(*((long *)((void *)ptr) + offt))++

This actually adds "offt" _longs_, not _bytes_ to "ptr",
which causes increment of entirely unrelated kernel data.
Nasty thing is that a result of this corruption usually
shows up much later and depends on kernel layout.
I was "lucky" enough - on one of my boxes ICMP redirect
packets reproducibly caused increment of thread_info->task
pointer of kswapd, so finally I traced this back to icmp.h.

Ivan.

--- 2.5/include/net/icmp.h	Tue Mar 25 01:01:22 2003
+++ linux/include/net/icmp.h	Tue Apr  1 13:34:06 2003
@@ -39,15 +39,15 @@ DECLARE_SNMP_STAT(struct icmp_mib, icmp_
 #define ICMP_INC_STATS_FIELD(offt)					\
 	(*((unsigned long *) ((void *)					\
 			     per_cpu_ptr(icmp_statistics[!in_softirq()],\
-					 smp_processor_id())) + offt))++;
+					 smp_processor_id()) + offt)))++
 #define ICMP_INC_STATS_BH_FIELD(offt)					\
 	(*((unsigned long *) ((void *)					\
 			     per_cpu_ptr(icmp_statistics[0],		\
-					 smp_processor_id())) + offt))++;
+					 smp_processor_id()) + offt)))++
 #define ICMP_INC_STATS_USER_FIELD(offt)					\
 	(*((unsigned long *) ((void *)					\
 			     per_cpu_ptr(icmp_statistics[1],		\
-					 smp_processor_id())) + offt))++;
+					 smp_processor_id()) + offt)))++
 
 extern void	icmp_send(struct sk_buff *skb_in,  int type, int code, u32 info);
 extern int	icmp_rcv(struct sk_buff *skb);

             reply	other threads:[~2003-04-01 14:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-01 14:57 Ivan Kokshaysky [this message]
2003-04-01 17:04 ` David S. Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030401185707.A955@jurassic.park.msu.ru \
    --to=ink@jurassic.park.msu.ru \
    --cc=davem@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®