From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nf-next] netfilter: nft_payload: only cancel tracking for clobbered dregs
Date: Sat, 12 Mar 2022 01:15:38 +0100 [thread overview]
Message-ID: <20220312001538.23128-1-pablo@netfilter.org> (raw)
payload expression might use more than one single register and clobber
previous data, reset tracking for the remaining registers too.
Fixes: a7c176bf9f0e ("netfilter: nft_payload: track register operations")
Reported-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nft_payload.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c
index 5cc06aef4345..431f70c8bc15 100644
--- a/net/netfilter/nft_payload.c
+++ b/net/netfilter/nft_payload.c
@@ -210,6 +210,23 @@ static int nft_payload_dump(struct sk_buff *skb, const struct nft_expr *expr)
return -1;
}
+static void nft_update_reg_track(struct nft_regs_track *track,
+ const struct nft_expr *expr, u8 dreg, u8 len)
+{
+ unsigned int regcount;
+ int i;
+
+ track->regs[dreg].selector = expr;
+ track->regs[dreg].bitwise = NULL;
+
+ dreg++;
+ regcount = DIV_ROUND_UP(len, NFT_REG32_SIZE);
+ for (i = 1; i < regcount; i++, dreg++) {
+ track->regs[dreg].selector = NULL;
+ track->regs[dreg].bitwise = NULL;
+ }
+}
+
static bool nft_payload_reduce(struct nft_regs_track *track,
const struct nft_expr *expr)
{
@@ -218,8 +235,7 @@ static bool nft_payload_reduce(struct nft_regs_track *track,
if (!track->regs[priv->dreg].selector ||
track->regs[priv->dreg].selector->ops != expr->ops) {
- track->regs[priv->dreg].selector = expr;
- track->regs[priv->dreg].bitwise = NULL;
+ nft_update_reg_track(track, expr, priv->dreg, priv->len);
return false;
}
@@ -227,8 +243,7 @@ static bool nft_payload_reduce(struct nft_regs_track *track,
if (priv->base != payload->base ||
priv->offset != payload->offset ||
priv->len != payload->len) {
- track->regs[priv->dreg].selector = expr;
- track->regs[priv->dreg].bitwise = NULL;
+ nft_update_reg_track(track, expr, priv->dreg, priv->len);
return false;
}
--
2.30.2
reply other threads:[~2022-03-12 0:15 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=20220312001538.23128-1-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
/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).