]> git.baikalelectronics.ru Git - kernel.git/commitdiff
netfilter: nft_byteorder: track register operations
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 26 Jan 2022 00:46:58 +0000 (01:46 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 26 Jan 2022 23:07:24 +0000 (00:07 +0100)
Cancel tracking for byteorder operation, otherwise selector + byteorder
operation is incorrectly reduced if source and destination registers are
the same.

Reported-by: kernel test robot <oliver.sang@intel.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_byteorder.c

index 9d5947ab8d4ef33531dd82fa42057d24273f1260..e646e9ee4a98754136681139010341d255829564 100644 (file)
@@ -167,12 +167,24 @@ nla_put_failure:
        return -1;
 }
 
+static bool nft_byteorder_reduce(struct nft_regs_track *track,
+                                const struct nft_expr *expr)
+{
+       struct nft_byteorder *priv = nft_expr_priv(expr);
+
+       track->regs[priv->dreg].selector = NULL;
+       track->regs[priv->dreg].bitwise = NULL;
+
+       return false;
+}
+
 static const struct nft_expr_ops nft_byteorder_ops = {
        .type           = &nft_byteorder_type,
        .size           = NFT_EXPR_SIZE(sizeof(struct nft_byteorder)),
        .eval           = nft_byteorder_eval,
        .init           = nft_byteorder_init,
        .dump           = nft_byteorder_dump,
+       .reduce         = nft_byteorder_reduce,
 };
 
 struct nft_expr_type nft_byteorder_type __read_mostly = {