]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
netlink_linearize: use div_round_up in byteorder length
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 6 Jul 2023 08:26:39 +0000 (10:26 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 23 Jan 2025 00:35:36 +0000 (01:35 +0100)
commit 25e7b99cc450490c38becb03d8bddd0199cfd3f9 upstream.

Use div_round_up() to calculate the byteorder length, otherwise fields
that take % BITS_PER_BYTE != 0 are not considered by the byteorder
expression.

Reported-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/netlink_linearize.c

index 527f3fc5471d63e3f7084f8f1b2b5d404550580a..1aaa12847cef8228f2de186efc9035db0bb18ce3 100644 (file)
@@ -740,7 +740,7 @@ static void netlink_gen_unary(struct netlink_linearize_ctx *ctx,
        netlink_put_register(nle, NFTNL_EXPR_BYTEORDER_SREG, dreg);
        netlink_put_register(nle, NFTNL_EXPR_BYTEORDER_DREG, dreg);
        nftnl_expr_set_u32(nle, NFTNL_EXPR_BYTEORDER_LEN,
-                          expr->len / BITS_PER_BYTE);
+                          div_round_up(expr->len, BITS_PER_BYTE));
        nftnl_expr_set_u32(nle, NFTNL_EXPR_BYTEORDER_SIZE,
                           byte_size);
        nftnl_expr_set_u32(nle, NFTNL_EXPR_BYTEORDER_OP,