Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1275170 > unrolled thread

nfnetlink warnings

Started byBorislav Petkov <bp@alien8.de>
First post2015-11-23 10:40 +0100
Last post2015-11-23 11:40 +0100
Articles 7 — 3 participants

Back to article view | Back to linux.kernel


Contents

  nfnetlink warnings Borislav Petkov <bp@alien8.de> - 2015-11-23 10:40 +0100
    Re: nfnetlink warnings Michael Wang <yun.wang@profitbricks.com> - 2015-11-23 10:50 +0100
      Re: nfnetlink warnings Borislav Petkov <bp@alien8.de> - 2015-11-23 11:00 +0100
        Re: nfnetlink warnings Michael Wang <yun.wang@profitbricks.com> - 2015-11-23 11:30 +0100
          Re: nfnetlink warnings Michael Wang <yun.wang@profitbricks.com> - 2015-11-23 11:40 +0100
          Re: nfnetlink warnings Pablo Neira Ayuso <pablo@netfilter.org> - 2015-11-23 11:40 +0100
          Re: nfnetlink warnings Borislav Petkov <bp@alien8.de> - 2015-11-23 11:40 +0100

#1275170 — nfnetlink warnings

FromBorislav Petkov <bp@alien8.de>
Date2015-11-23 10:40 +0100
Subjectnfnetlink warnings
Message-ID<qxVLl-8n9-37@gated-at.bofh.it>
Hey,

so I keep getting those since recently:

net/netfilter/nfnetlink_queue.c:519:19: warning: ‘nfnl_ct’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  if (ct && nfnl_ct->build(skb, ct, ctinfo, NFQA_CT, NFQA_CT_INFO) < 0)
                   ^
net/netfilter/nfnetlink_queue.c:316:23: note: ‘nfnl_ct’ was declared here
  struct nfnl_ct_hook *nfnl_ct;
                       ^
net/netfilter/nfnetlink_queue.c: In function ‘nfqnl_recv_verdict’:
net/netfilter/nfnetlink_queue.c:1083:11: warning: ‘nfnl_ct’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    nfnl_ct->seq_adjust(entry->skb, ct, ctinfo, diff);
           ^

and was thinking can we shut them up like this? I know, it is ugly :-\

I mean, it is obvious in both cases that nfnl_ct won't be used if ct is
not set but apparently gcc can't see that far...

---
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index 7d81d280cb4f..cd61b0b5c413 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -372,6 +372,8 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,
 			if (ct != NULL)
 				size += nfnl_ct->build_size(ct);
 		}
+	} else {
+		nfnl_ct = NULL;
 	}
 
 	if (queue->flags & NFQA_CFG_F_UID_GID) {
@@ -1069,6 +1071,8 @@ nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb,
 		nfnl_ct = rcu_dereference(nfnl_ct_hook);
 		if (nfnl_ct != NULL)
 			ct = nfqnl_ct_parse(nfnl_ct, nlh, nfqa, entry, &ctinfo);
+	} else {
+		nfnl_ct = NULL;
 	}
 
 	if (nfqa[NFQA_PAYLOAD]) {

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1275179

FromMichael Wang <yun.wang@profitbricks.com>
Date2015-11-23 10:50 +0100
Message-ID<qxVV1-8qv-15@gated-at.bofh.it>
In reply to#1275170
Hi, Borislav

Why not just initialized it as NULL, or mark it as uninitialized_var()?

Regards,
Michael Wang

On 11/23/2015 10:36 AM, Borislav Petkov wrote:
> Hey,
> 
> so I keep getting those since recently:
> 
> net/netfilter/nfnetlink_queue.c:519:19: warning: ‘nfnl_ct’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>   if (ct && nfnl_ct->build(skb, ct, ctinfo, NFQA_CT, NFQA_CT_INFO) < 0)
>                    ^
> net/netfilter/nfnetlink_queue.c:316:23: note: ‘nfnl_ct’ was declared here
>   struct nfnl_ct_hook *nfnl_ct;
>                        ^
> net/netfilter/nfnetlink_queue.c: In function ‘nfqnl_recv_verdict’:
> net/netfilter/nfnetlink_queue.c:1083:11: warning: ‘nfnl_ct’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>     nfnl_ct->seq_adjust(entry->skb, ct, ctinfo, diff);
>            ^
> 
> and was thinking can we shut them up like this? I know, it is ugly :-\
> 
> I mean, it is obvious in both cases that nfnl_ct won't be used if ct is
> not set but apparently gcc can't see that far...
> 
> ---
> diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
> index 7d81d280cb4f..cd61b0b5c413 100644
> --- a/net/netfilter/nfnetlink_queue.c
> +++ b/net/netfilter/nfnetlink_queue.c
> @@ -372,6 +372,8 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,
>  			if (ct != NULL)
>  				size += nfnl_ct->build_size(ct);
>  		}
> +	} else {
> +		nfnl_ct = NULL;
>  	}
>  
>  	if (queue->flags & NFQA_CFG_F_UID_GID) {
> @@ -1069,6 +1071,8 @@ nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb,
>  		nfnl_ct = rcu_dereference(nfnl_ct_hook);
>  		if (nfnl_ct != NULL)
>  			ct = nfqnl_ct_parse(nfnl_ct, nlh, nfqa, entry, &ctinfo);
> +	} else {
> +		nfnl_ct = NULL;
>  	}
>  
>  	if (nfqa[NFQA_PAYLOAD]) {
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1275187

FromBorislav Petkov <bp@alien8.de>
Date2015-11-23 11:00 +0100
Message-ID<qxW4G-8tT-7@gated-at.bofh.it>
In reply to#1275179
Hi Michael,

On Mon, Nov 23, 2015 at 10:49:34AM +0100, Michael Wang wrote:
> Why not just initialized it as NULL, or mark it as uninitialized_var()?

because I'd like us to save us the redundant NULL initialization in the
if-case.

I'm not saying any of the approaches are good visually, though. Who
knows, someone might have a better idea like, maybe "Oh, I wanted to
rewrite that code and this handlong is going to be different anyway ..."
or so. Or something to that effect.

Btw, please do not top-post.

Thanks.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1275220

FromMichael Wang <yun.wang@profitbricks.com>
Date2015-11-23 11:30 +0100
Message-ID<qxWxI-tE-11@gated-at.bofh.it>
In reply to#1275187

On 11/23/2015 10:54 AM, Borislav Petkov wrote:
> Hi Michael,
> 
> On Mon, Nov 23, 2015 at 10:49:34AM +0100, Michael Wang wrote:
>> Why not just initialized it as NULL, or mark it as uninitialized_var()?
> 
> because I'd like us to save us the redundant NULL initialization in the
> if-case.

Well, I would vote initialized with NULL, rather than use another else
branch to do the same thing.

> 
> I'm not saying any of the approaches are good visually, though. Who
> knows, someone might have a better idea like, maybe "Oh, I wanted to
> rewrite that code and this handlong is going to be different anyway ..."
> or so. Or something to that effect.

Who want to do that would take responsibility to make an else branch at
that time, but reserve the branch at this moment sounds unnecessary, and
not that pretty frankly speaking.

> 
> Btw, please do not top-post.

Enjoy ;-)

Regards,
Michael Wang

> 
> Thanks.
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1275227

FromMichael Wang <yun.wang@profitbricks.com>
Date2015-11-23 11:40 +0100
Message-ID<qxWHo-x4-3@gated-at.bofh.it>
In reply to#1275220

On 11/23/2015 11:32 AM, Borislav Petkov wrote:
> On Mon, Nov 23, 2015 at 11:20:18AM +0100, Michael Wang wrote:
>> Who want to do that would take responsibility to make an else branch at
>> that time, but reserve the branch at this moment sounds unnecessary, and
>> not that pretty frankly speaking.
> 
> Actually, I was looking for the better idea which doesn't uglify the
> code. And here it is:
> 
> https://lkml.kernel.org/r/5585663.OcpAQiytKY@wuerfel

Looks even better :-)

Regards,
Michael Wang

> 
> :-)
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1275233

FromPablo Neira Ayuso <pablo@netfilter.org>
Date2015-11-23 11:40 +0100
Message-ID<qxWHo-x4-19@gated-at.bofh.it>
In reply to#1275220
I have just applied this patch to resolve this issue.

http://git.kernel.org/cgit/linux/kernel/git/pablo/nf.git/commit/?id=8e662164abb4a8fde701a46e1431980f9e325742

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1275236

FromBorislav Petkov <bp@alien8.de>
Date2015-11-23 11:40 +0100
Message-ID<qxWHo-x4-5@gated-at.bofh.it>
In reply to#1275220
On Mon, Nov 23, 2015 at 11:20:18AM +0100, Michael Wang wrote:
> Who want to do that would take responsibility to make an else branch at
> that time, but reserve the branch at this moment sounds unnecessary, and
> not that pretty frankly speaking.

Actually, I was looking for the better idea which doesn't uglify the
code. And here it is:

https://lkml.kernel.org/r/5585663.OcpAQiytKY@wuerfel

:-)

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web