netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* re: netfilter: nfnetlink_log: send complete hardware header
@ 2010-07-22 11:50 Dan Carpenter
  2010-07-22 12:09 ` [PATCH] netfilter: nfnetlink_log: Fix potential problem if skb->dev is null Eric Leblond
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2010-07-22 11:50 UTC (permalink / raw)
  To: eric; +Cc: netfilter-devel

Hi,

Smatch complains abbout 72961ecf84d67d6 "netfilter: nfnetlink_log: send
complete hardware header" which is net-next.
    
   462          if (indev && skb->dev) {
                             ^^^^^^^^
	skb->dev can be NULL here.

   463                  struct nfulnl_msg_packet_hw phw;
   464                  int len = dev_parse_header(skb, phw.hw_addr);
   465                  if (len > 0) {
   466                          phw.hw_addrlen = htons(len);
   467                          NLA_PUT(inst->skb, NFULA_HWADDR, sizeof(phw), &phw);
   468                  }
   469          }
   470  
   471          if (indev && skb_mac_header_was_set(skb)) {
   472                  NLA_PUT_BE16(inst->skb, NFULA_HWTYPE, htons(skb->dev->type));
                                                                    ^^^^^^^^
	It's dereferenced here.

   473                  NLA_PUT_BE16(inst->skb, NFULA_HWLEN,
   474                               htons(skb->dev->hard_header_len));

I'm not sure how you want to deal with this.

regards,
dan carpenter

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

* [PATCH] netfilter: nfnetlink_log: Fix potential problem if skb->dev is null
  2010-07-22 11:50 netfilter: nfnetlink_log: send complete hardware header Dan Carpenter
@ 2010-07-22 12:09 ` Eric Leblond
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Leblond @ 2010-07-22 12:09 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: netfilter-devel, Eric Leblond

This patch fixes a potentiel problem pointed out by Dan Carpenter
using smatch: skb->dev is used but there is no test on nullity
of pointer. It may not express as if mac header is filled we can
think that the dev is also set.
---
 net/netfilter/nfnetlink_log.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index 6a1572b..b5617c2 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -468,7 +468,7 @@ __build_packet_message(struct nfulnl_instance *inst,
 		}
 	}
 
-	if (indev && skb_mac_header_was_set(skb)) {
+	if (indev && skb->dev && skb_mac_header_was_set(skb)) {
 		NLA_PUT_BE16(inst->skb, NFULA_HWTYPE, htons(skb->dev->type));
 		NLA_PUT_BE16(inst->skb, NFULA_HWLEN,
 			     htons(skb->dev->hard_header_len));
-- 
1.6.1


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

end of thread, other threads:[~2010-07-22 12:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-22 11:50 netfilter: nfnetlink_log: send complete hardware header Dan Carpenter
2010-07-22 12:09 ` [PATCH] netfilter: nfnetlink_log: Fix potential problem if skb->dev is null Eric Leblond

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