netfilter: potential NULL dereference in get_inner_hdr()
Subsystems (4)
PATCH 1/1 netfilter: potential NULL dereference in get_inner_hdr()
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.
---
Btw, this is new code and Sparse complains about endian bugs.
net/netfilter/xt_HMARK.c +1 -1
@@ -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? */
Quoted 5 lines · On Saturday 12 May 2012 13:00:03 Dan Carpenter wrote:
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 <[email protected]>
Quoted 2 lines
---
Btw, this is new code and Sparse complains about endian bugs.
Can you give me some hints here, arch , compiler version etc. I guess it was input to hmark_addr_mask() that complains ?
Quoted 19 lines
net/netfilter/xt_HMARK.c +1
-2@@ -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? */ --To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Regards Hans Schillstrom <[email protected]>
David Miller
maintainerFrom: Hans Schillstrom <[email protected]>
Date: Mon, 14 May 2012 09:36:55 +0200
Quoted 5 lines · On Saturday 12 May 2012 13:00:03 Dan Carpenter wrote:
Quoted 4 lines
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.
Quoted 8 lines
Quoted 1 line
Signed-off-by Dan Carpenter <[email protected]>Quoted 2 lines
---
Btw, this is new code and Sparse complains about endian bugs.Can you give me some hints here, arch , compiler version etc. I guess it was input to
hmark_addr_mask()that complains ?
He said what he's using, "sparse", the semantic parser, which is largely arch agnostic.
I guarantee you will see the warnings if you run it on your system on this code.
Quoted 5 lines · David Miller
He said what he's using, "sparse", the semantic parser, which is largely arch agnostic.
I guarantee you will see the warnings if you run it on your system on this code.
Some more info :
http://lwn.net/Articles/205624/
make C=2 CF=-D__CHECK_ENDIAN__ net/netfilter/xt_HMARK.o
CHECK net/netfilter/xt_HMARK.cnet/netfilter/xt_HMARK.c:87:21: warning: incorrect type in assignment (different base types)net/netfilter/xt_HMARK.c:87:21: expected unsigned short [unsigned] [usertype] srcnet/netfilter/xt_HMARK.c:87:21: got restricted __be16 [usertype] allnet/netfilter/xt_HMARK.c:88:21: warning: incorrect type in assignment (different base types)net/netfilter/xt_HMARK.c:88:21: expected unsigned short [unsigned] [usertype] dstnet/netfilter/xt_HMARK.c:88:21: got restricted __be16 [usertype] allnet/netfilter/xt_HMARK.c:170:27: warning: incorrect type in argument 2 (different signedness)net/netfilter/xt_HMARK.c:170:27: expected int *offsetnet/netfilter/xt_HMARK.c:170:27: got unsigned int *<noident>net/netfilter/xt_HMARK.c:181:28: warning: incorrect type in argument 1 (different base types)net/netfilter/xt_HMARK.c:181:28: expected unsigned int const [usertype] *addr32net/netfilter/xt_HMARK.c:181:28: got restricted __be32 *<noident>net/netfilter/xt_HMARK.c:182:28: warning: incorrect type in argument 1 (different base types)net/netfilter/xt_HMARK.c:182:28: expected unsigned int const [usertype] *addr32net/netfilter/xt_HMARK.c:182:28: got restricted __be32 *<noident>net/netfilter/xt_HMARK.c:261:9: warning: invalid assignment: &net/netfilter/xt_HMARK.c:261:9: left side has type unsigned intnet/netfilter/xt_HMARK.c:261:9: right side has type restricted __be32net/netfilter/xt_HMARK.c:262:9: warning: invalid assignment: &net/netfilter/xt_HMARK.c:262:9: left side has type unsigned intnet/netfilter/xt_HMARK.c:262:9: right side has type restricted __be32
Quoted 25 lines · On Monday 14 May 2012 09:53:15 Eric Dumazet wrote:
Quoted 5 lines · David Miller
He said what he's using, "sparse", the semantic parser, which is largely arch agnostic.
I guarantee you will see the warnings if you run it on your system on this code.
Some more info :
http://lwn.net/Articles/205624/
make C=2 CF=-D__CHECK_ENDIAN__
net/netfilter/xt_HMARK.o
CHECKnet/netfilter/xt_HMARK.cnet/netfilter/xt_HMARK.c:87:21: warning: incorrect type in assignment (different base types)net/netfilter/xt_HMARK.c:87:21: expected unsigned short [unsigned] [usertype] srcnet/netfilter/xt_HMARK.c:87:21: got restricted__be16[usertype] allnet/netfilter/xt_HMARK.c:88:21: warning: incorrect type in assignment (different base types)net/netfilter/xt_HMARK.c:88:21: expected unsigned short [unsigned] [usertype] dstnet/netfilter/xt_HMARK.c:88:21: got restricted__be16[usertype] allnet/netfilter/xt_HMARK.c:170:27: warning: incorrect type in argument 2 (different signedness)net/netfilter/xt_HMARK.c:170:27: expected int *offsetnet/netfilter/xt_HMARK.c:170:27: got unsigned int *<noident>net/netfilter/xt_HMARK.c:181:28: warning: incorrect type in argument 1 (different base types)net/netfilter/xt_HMARK.c:181:28: expected unsigned int const [usertype] *addr32
Quoted 9 lines
net/netfilter/xt_HMARK.c:181:28: got restricted__be32*<noident>net/netfilter/xt_HMARK.c:182:28: warning: incorrect type in argument 1 (different base types)net/netfilter/xt_HMARK.c:182:28: expected unsigned int const [usertype] *addr32net/netfilter/xt_HMARK.c:182:28: got restricted__be32*<noident>net/netfilter/xt_HMARK.c:261:9: warning: invalid assignment: &>net/netfilter/xt_HMARK.c:261:9: left side has type unsigned intnet/netfilter/xt_HMARK.c:261:9: right side has type restricted__be32net/netfilter/xt_HMARK.c:262:9: warning: invalid assignment: &>net/netfilter/xt_HMARK.c:262:9: left side has type unsigned intnet/netfilter/xt_HMARK.c:262:9: right side has type restricted__be32
Thanks
I'll try to fix the warnings
Signature · 2 lines
Regards Hans Schillstrom <[email protected]>
Pablo Neira Ayuso
maintainerQuoted 8 lines · Hans Schillstrom
Quoted 8 lines
http://lwn.net/Articles/205624/
make C=2 CF=-D__CHECK_ENDIAN__
net/netfilter/xt_HMARK.o
CHECKnet/netfilter/xt_HMARK.cnet/netfilter/xt_HMARK.c:87:21: warning: incorrect type in assignment (different base types)net/netfilter/xt_HMARK.c:87:21: expected unsigned short [unsigned] [usertype] srcnet/netfilter/xt_HMARK.c:87:21: got restricted__be16[usertype] all
[...]
Quoted 3 lines
Thanks
I'll try to fix the warnings
Ok, wait for that patch, thanks.
Quoted 5 lines · Dan Carpenter
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 <[email protected]>
Applied, thanks Dan.
Quoted 5 lines · Hans Schillstrom
Quoted 4 lines · On Saturday 12 May 2012 13:00:03 Dan Carpenter wrote:
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.
Quoted 9 lines
Quoted 1 line
Signed-off-by Dan Carpenter <[email protected]>Quoted 2 lines
---
Btw, this is new code and Sparse complains about endian bugs.Can you give me some hints here, arch , compiler version etc. I guess it was input to
hmark_addr_mask()that complains ?
Yes. That was one of the warnings.
http://lwn.net/Articles/205624/
net/netfilter/xt_HMARK.c:87:35: warning: incorrect type in assignment (different base types)net/netfilter/xt_HMARK.c:87:35: expected unsigned short [unsigned] [usertype] srcnet/netfilter/xt_HMARK.c:87:35: got restricted __be16 [usertype] allnet/netfilter/xt_HMARK.c:88:35: warning: incorrect type in assignment (different base types)net/netfilter/xt_HMARK.c:88:35: expected unsigned short [unsigned] [usertype] dstnet/netfilter/xt_HMARK.c:88:35: got restricted __be16 [usertype] allnet/netfilter/xt_HMARK.c:181:35: warning: incorrect type in argument 1 (different base types)net/netfilter/xt_HMARK.c:181:35: expected unsigned int const [usertype] *addr32net/netfilter/xt_HMARK.c:181:35: got restricted __be32 *<noident>net/netfilter/xt_HMARK.c:182:35: warning: incorrect type in argument 1 (different base types)net/netfilter/xt_HMARK.c:182:35: expected unsigned int const [usertype] *addr32net/netfilter/xt_HMARK.c:182:35: got restricted __be32 *<noident>net/netfilter/xt_HMARK.c:261:16: warning: invalid assignment: &=net/netfilter/xt_HMARK.c:261:16: left side has type unsigned intnet/netfilter/xt_HMARK.c:261:16: right side has type restricted __be32net/netfilter/xt_HMARK.c:262:16: warning: invalid assignment: &=net/netfilter/xt_HMARK.c:262:16: left side has type unsigned intnet/netfilter/xt_HMARK.c:262:16: right side has type restricted __be32
regards,
dan carpenter