From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Subject: [PATCH nf-next] netfilter: nft_payload: restrict l4 checksum updates to l3 header mangling
Date: Tue, 6 Dec 2016 11:27:18 +0100 [thread overview]
Message-ID: <1481020038-3235-1-git-send-email-pablo@netfilter.org> (raw)
Allow layer 4 header checksum updates if the layer 3 header was modified.
net/netfilter/nft_payload.c:261:15: note: 'tsum' was declared here
__wsum fsum, tsum;
^
In file included from include/linux/skbuff.h:31:0,
from include/linux/if_ether.h:23,
from include/uapi/linux/ethtool.h:18,
from include/linux/ethtool.h:17,
from include/linux/netdevice.h:42,
from include/linux/if_vlan.h:15,
from net/netfilter/nft_payload.c:13:
include/net/checksum.h:71:9: warning: 'fsum' may be used uninitialized in this function [-Wmaybe-uninitialized]
return csum_add(csum, ~addend);
^
net/netfilter/nft_payload.c:261:9: note: 'fsum' was declared here
__wsum fsum, tsum;
Fixes: 556c291b3a1b ("netfilter: nft_payload: layer 4 checksum adjustment for pseudoheader fields")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nft_payload.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c
index 30d296340f9a..fe0fe2d3e73b 100644
--- a/net/netfilter/nft_payload.c
+++ b/net/netfilter/nft_payload.c
@@ -257,6 +257,7 @@ static void nft_payload_set_eval(const struct nft_expr *expr,
const struct nft_payload_set *priv = nft_expr_priv(expr);
struct sk_buff *skb = pkt->skb;
const u32 *src = ®s->data[priv->sreg];
+ bool csum_mangled = false;
int offset, csum_offset;
__wsum fsum, tsum;
__sum16 sum;
@@ -295,9 +296,11 @@ static void nft_payload_set_eval(const struct nft_expr *expr,
if (!skb_make_writable(skb, csum_offset + sizeof(sum)) ||
skb_store_bits(skb, csum_offset, &sum, sizeof(sum)) < 0)
goto err;
+
+ csum_mangled = true;
}
- if (priv->csum_flags &&
+ if (priv->csum_flags && csum_mangled &&
nft_payload_l4csum_update(pkt, skb, fsum, tsum) < 0)
goto err;
--
2.1.4
reply other threads:[~2016-12-06 10:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1481020038-3235-1-git-send-email-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=sfr@canb.auug.org.au \
/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).