netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch v2 1/5] pktgen: fix crash when generating IPv6 packets
@ 2012-10-10  3:48 Cong Wang
  2012-10-10  3:48 ` [Patch v2 2/5] pktgen: set different default min_pkt_size for different protocols Cong Wang
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Cong Wang @ 2012-10-10  3:48 UTC (permalink / raw)
  To: netdev; +Cc: Cong Wang, stable, David S. Miller

For IPv6, sizeof(struct ipv6hdr) = 40, thus the following
expression will result negative:

        datalen = pkt_dev->cur_pkt_size - 14 -
                  sizeof(struct ipv6hdr) - sizeof(struct udphdr) -
                  pkt_dev->pkt_overhead;

And,  the check "if (datalen < sizeof(struct pktgen_hdr))" will be
passed as "datalen" is promoted to unsigned, therefore will cause
a crash later.

This is a quick fix by checking if "datalen" is negative. The following
patch will increase the default value of 'min_pkt_size' for IPv6.

This bug should exist for a long time, so Cc -stable too.

Cc: <stable@vger.kernel.org>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>
---
 net/core/pktgen.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 148e73d..e356b8d 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2927,7 +2927,7 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
 		  sizeof(struct ipv6hdr) - sizeof(struct udphdr) -
 		  pkt_dev->pkt_overhead;
 
-	if (datalen < sizeof(struct pktgen_hdr)) {
+	if (datalen < 0 || datalen < sizeof(struct pktgen_hdr)) {
 		datalen = sizeof(struct pktgen_hdr);
 		net_info_ratelimited("increased datalen to %d\n", datalen);
 	}
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-10-11  2:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-10  3:48 [Patch v2 1/5] pktgen: fix crash when generating IPv6 packets Cong Wang
2012-10-10  3:48 ` [Patch v2 2/5] pktgen: set different default min_pkt_size for different protocols Cong Wang
2012-10-11  2:34   ` David Miller
2012-10-10  3:48 ` [Patch v2 3/5] pktgen: display IPv4 address in human-readable format Cong Wang
2012-10-11  2:34   ` David Miller
2012-10-10  3:48 ` [Patch v2 4/5] pktgen: enable automatic IPv6 address setting Cong Wang
2012-10-11  2:34   ` David Miller
2012-10-10  3:48 ` [Patch v2 5/5] pktgen: replace scan_ip6() with in6_pton() Cong Wang
2012-10-11  2:34   ` David Miller
2012-10-11  2:33 ` [Patch v2 1/5] pktgen: fix crash when generating IPv6 packets David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).