From 21b20ead7d202dcbe4f9447db2b90ec818283831 Mon Sep 17 00:00:00 2001 From: zhanghao Date: Mon, 14 Aug 2023 20:51:18 +0800 Subject: [PATCH] netlink_linearize: use div_round_up in byteorder length (cherry picked from commit 07b379a5b35e4281e548c2ef5f83762f5f7766bb) --- ...use-div_round_up-in-byteorder-length.patch | 31 +++++++++++++++++++ nftables.spec | 10 +++++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 backport-netlink_linearize-use-div_round_up-in-byteorder-length.patch diff --git a/backport-netlink_linearize-use-div_round_up-in-byteorder-length.patch b/backport-netlink_linearize-use-div_round_up-in-byteorder-length.patch new file mode 100644 index 0000000..be781d0 --- /dev/null +++ b/backport-netlink_linearize-use-div_round_up-in-byteorder-length.patch @@ -0,0 +1,31 @@ +From 25e7b99cc450490c38becb03d8bddd0199cfd3f9 Mon Sep 17 00:00:00 2001 +From: Pablo Neira Ayuso +Date: Thu, 6 Jul 2023 10:26:39 +0200 +Subject: netlink_linearize: use div_round_up in byteorder length + +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 +Signed-off-by: Pablo Neira Ayuso +--- + src/netlink_linearize.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/netlink_linearize.c b/src/netlink_linearize.c +index 92f7e8e..237fb6d 100644 +--- a/src/netlink_linearize.c ++++ b/src/netlink_linearize.c +@@ -737,7 +737,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, +-- +2.33.0 + diff --git a/nftables.spec b/nftables.spec index 0334f04..a39e403 100644 --- a/nftables.spec +++ b/nftables.spec @@ -1,6 +1,6 @@ Name: nftables Version: 1.0.0 -Release: 8 +Release: 9 Epoch: 1 Summary: A subsystem of the Linux kernel processing network data License: GPLv2 @@ -34,6 +34,8 @@ Patch19: backport-evaluate-fix-shift-exponent-underflow-in-concatenation- Patch20: backport-netlink-Fix-for-potential-NULL-pointer-deref.patch Patch21: backport-mnl-dump_nf_hooks-leaks-memory-in-error-path.patch +Patch22: backport-netlink_linearize-use-div_round_up-in-byteorder-length.patch + BuildRequires: gcc flex bison libmnl-devel gmp-devel readline-devel libnftnl-devel docbook2X systemd BuildRequires: iptables-devel jansson-devel python3-devel BuildRequires: chrpath @@ -132,6 +134,12 @@ echo "%{_libdir}" > %{buildroot}/etc/ld.so.conf.d/%{name}-%{_arch}.conf %{python3_sitelib}/nftables/ %changelog +* Mon Aug 14 2023 zhanghao - 1:1.0.0-9 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:netlink_linearize: use div_round_up in byteorder length + * Thu Apr 06 2023 zhanghao - 1:1.0.0-8 - Type:bugfix - CVE:NA