netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] netfilter: potential NULL dereference in get_inner_hdr()
@ 2012-05-12 11:00 Dan Carpenter
  2012-05-14  7:36 ` Hans Schillstrom
  2012-05-14  8:24 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 8+ messages in thread
From: Dan Carpenter @ 2012-05-12 11:00 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: Patrick McHardy, David S. Miller, netfilter-devel, netfilter,
	coreteam, netdev, kernel-janitors

There is a typo in the error checking and "&&" was used instead of "||".
If skb_header_pointer() returns NULL then it leads to a NULL
dereference.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Btw, this is new code and Sparse complains about endian bugs.

diff --git a/net/netfilter/xt_HMARK.c b/net/netfilter/xt_HMARK.c
index 32fbd73..5817d03 100644
--- a/net/netfilter/xt_HMARK.c
+++ b/net/netfilter/xt_HMARK.c
@@ -223,7 +223,7 @@ static int get_inner_hdr(const struct sk_buff *skb, int iphsz, int *nhoff)
 
 	/* Not enough header? */
 	icmph = skb_header_pointer(skb, *nhoff + iphsz, sizeof(_ih), &_ih);
-	if (icmph == NULL && icmph->type > NR_ICMP_TYPES)
+	if (icmph == NULL || icmph->type > NR_ICMP_TYPES)
 		return 0;
 
 	/* Error message? */

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

end of thread, other threads:[~2012-05-14  8:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-12 11:00 [patch] netfilter: potential NULL dereference in get_inner_hdr() Dan Carpenter
2012-05-14  7:36 ` Hans Schillstrom
2012-05-14  7:38   ` David Miller
2012-05-14  7:53     ` Eric Dumazet
2012-05-14  8:00       ` Hans Schillstrom
2012-05-14  8:22         ` Pablo Neira Ayuso
2012-05-14  8:39   ` Dan Carpenter
2012-05-14  8:24 ` Pablo Neira Ayuso

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).