From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Li Qiong <liqiong@nfschina.com>
Cc: Jozsef Kadlecsik <kadlec@netfilter.org>,
Florian Westphal <fw@strlen.de>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
netfilter-devel@vger.kernel.org, kernel-janitors@vger.kernel.org,
coreteam@netfilter.org, Yu Zhe <yuzhe@nfschina.com>
Subject: Re: [PATCH] netfilter: initialize 'ret' variable
Date: Mon, 5 Dec 2022 15:26:16 +0100 [thread overview]
Message-ID: <Y43/iCzGY7qJckCe@salvia> (raw)
In-Reply-To: <20221202070331.10865-1-liqiong@nfschina.com>
On Fri, Dec 02, 2022 at 03:03:31PM +0800, Li Qiong wrote:
> The 'ret' should need to be initialized to 0, in case
> return a uninitialized value.
>
> Signed-off-by: Li Qiong <liqiong@nfschina.com>
> ---
> net/netfilter/nf_flow_table_ip.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/netfilter/nf_flow_table_ip.c b/net/netfilter/nf_flow_table_ip.c
> index b350fe9d00b0..225ff865d609 100644
> --- a/net/netfilter/nf_flow_table_ip.c
> +++ b/net/netfilter/nf_flow_table_ip.c
> @@ -351,7 +351,7 @@ nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb,
> struct rtable *rt;
> struct iphdr *iph;
> __be32 nexthop;
> - int ret;
> + int ret = 0;
>
> if (skb->protocol != htons(ETH_P_IP) &&
> !nf_flow_skb_encap_protocol(skb, htons(ETH_P_IP), &offset))
> @@ -613,7 +613,7 @@ nf_flow_offload_ipv6_hook(void *priv, struct sk_buff *skb,
> u32 hdrsize, offset = 0;
> struct ipv6hdr *ip6h;
> struct rt6_info *rt;
> - int ret;
> + int ret = 0;
>
> if (skb->protocol != htons(ETH_P_IPV6) &&
> !nf_flow_skb_encap_protocol(skb, htons(ETH_P_IPV6), &offset))
This can only happen with tuplehash->tuple.xmit_type:
- FLOW_OFFLOAD_XMIT_UNSPEC
- FLOW_OFFLOAD_XMIT_TC
but this should not ever happen in that path.
Instead, I'd suggest to add a 'default' case to the switch, set ret to
NF_DROP and WARN_ON_ONCE(1).
next prev parent reply other threads:[~2022-12-05 14:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-02 7:03 [PATCH] netfilter: initialize 'ret' variable Li Qiong
2022-12-02 7:13 ` Al Viro
2022-12-02 8:06 ` liqiong
2022-12-02 9:18 ` Jan Engelhardt
2022-12-05 14:26 ` Pablo Neira Ayuso [this message]
2022-12-06 0:29 ` liqiong
2022-12-06 7:44 ` [PATCH v2] netfilter: add a 'default' case to 'switch (tuplehash->tuple.xmit_type)' Li Qiong
2022-12-08 21:12 ` Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y43/iCzGY7qJckCe@salvia \
--to=pablo@netfilter.org \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=kadlec@netfilter.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liqiong@nfschina.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=yuzhe@nfschina.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).