[packages/ebtables] Rel 2. Fix parse_ip6_mask() overflow and ebtables-restore crash.
arekm
arekm at pld-linux.org
Thu Oct 29 08:32:42 CET 2026
commit aaca582d77f8f6fe3fdb96df541c69f1ec2d0edb
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Thu Oct 29 00:44:46 2026 +0100
Rel 2. Fix parse_ip6_mask() overflow and ebtables-restore crash.
ebtables-ip6-mask-overflow.patch | 54 +++++++++++++++++++++++++++++++++++++++
ebtables-restore-null-deref.patch | 39 ++++++++++++++++++++++++++++
ebtables.spec | 8 +++++-
3 files changed, 100 insertions(+), 1 deletion(-)
---
diff --git a/ebtables.spec b/ebtables.spec
index bde887e..27c71d8 100644
--- a/ebtables.spec
+++ b/ebtables.spec
@@ -2,13 +2,17 @@ Summary: Ethernet Bridge Tables
Summary(pl.UTF-8): Ethernet Bridge Tables - filtrowanie i translacja adresów dla Ethernetu
Name: ebtables
Version: 2.0.11
-Release: 1
+Release: 2
License: GPL v2+
Group: Networking/Daemons
Source0: https://ftp.netfilter.org/pub/ebtables/%{name}-%{version}.tar.gz
# Source0-md5: 071c8b0a59241667a0044fb040d4fc72
Source1: %{name}.init
Source2: %{name}-config
+# https://git.netfilter.org/ebtables/commit/?id=39d24cc47a2ccba293f6b6ad4209d2992570d67a
+Patch0: %{name}-ip6-mask-overflow.patch
+# https://git.netfilter.org/ebtables/commit/?id=a6f972845fcf3ef13a3481af1a8f5ca15ae96cfc
+Patch1: %{name}-restore-null-deref.patch
URL: https://ebtables.netfilter.org/
# <linux/netfilter/xt_AUDIT.h>
BuildRequires: linux-libc-headers >= 6:3.0
@@ -36,6 +40,8 @@ standardowych jąder Linuksa w wersjach 2.5.x i nowszych.
%prep
%setup -q
+%patch -P0 -p1
+%patch -P1 -p1
%build
%configure \
diff --git a/ebtables-ip6-mask-overflow.patch b/ebtables-ip6-mask-overflow.patch
new file mode 100644
index 0000000..d5b3a7c
--- /dev/null
+++ b/ebtables-ip6-mask-overflow.patch
@@ -0,0 +1,54 @@
+From 39d24cc47a2ccba293f6b6ad4209d2992570d67a Mon Sep 17 00:00:00 2001
+From: Phil Sutter <phil at nwl.cc>
+Date: Wed, 11 Feb 2026 20:29:33 +0100
+Subject: useful_functions: Fix for buffer overflow in parse_ip6_mask()
+
+Ilia wrote:
+> I have found several global buffer overflows in
+> useful_functions.c
+>
+> They both occur in the function parse_ip6_mask() and are caused by
+> unconditionally writing to p[16].
+>
+> The first overflow occurs when bits is equal to 128,
+> which causes p[bits / 8] = 0xff << (8 - (bits & 7)); to write at p[16].
+>
+> The second overflow occurs when bits is equal to 8,
+> which causes memset(p + (bits / 8) + 1, 0, (128 - bits) / 8); to write
+> 15 bytes starting at p + 2, which leads to the same issue.
+
+This patch contains a simplified version of his fix:
+
+- The original code attempted to div_round_up() for the second memset(),
+ to zero the fully empty mask bytes. It used the term '(bits / 8) + 1'
+ which misbehaves if bits is equal to 8.
+
+- Addressing p at offset 'bits / 8' is illegal if bits has the legal max
+ value of 128. Also, zeroing this byte is needed only if bits is not
+ divisible by 8.
+
+Reported-by: Ilia Kashintsev <ilia.kashintsev at gmail.com>
+Signed-off-by: Phil Sutter <phil at nwl.cc>
+---
+ useful_functions.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/useful_functions.c b/useful_functions.c
+index 133ae2f..7378fc9 100644
+--- a/useful_functions.c
++++ b/useful_functions.c
+@@ -364,8 +364,9 @@ static struct in6_addr *parse_ip6_mask(char *mask)
+ if (bits != 0) {
+ char *p = (char *)&maskaddr;
+ memset(p, 0xff, bits / 8);
+- memset(p + (bits / 8) + 1, 0, (128 - bits) / 8);
+- p[bits / 8] = 0xff << (8 - (bits & 7));
++ memset(p + (bits + 7) / 8, 0, (128 - bits) / 8);
++ if (bits & 7)
++ p[bits / 8] = 0xff << (8 - (bits & 7));
+ return &maskaddr;
+ }
+
+--
+2.56.0
+
diff --git a/ebtables-restore-null-deref.patch b/ebtables-restore-null-deref.patch
new file mode 100644
index 0000000..71d4fd5
--- /dev/null
+++ b/ebtables-restore-null-deref.patch
@@ -0,0 +1,39 @@
+From a6f972845fcf3ef13a3481af1a8f5ca15ae96cfc Mon Sep 17 00:00:00 2001
+From: Ilia Kashintsev <ilia.kashintsev at gmail.com>
+Date: Thu, 25 Dec 2025 15:32:34 +0300
+Subject: ebtables: fix null dereference in ebtables-restore
+
+Use strchrnul() instead of strchr() when trimming the trailing newline.
+This avoids NULL pointer dereference when newline is not present in the
+input.
+
+Signed-off-by: Ilia Kashintsev <ilia.kashintsev at gmail.com>
+Signed-off-by: Florian Westphal <fw at strlen.de>
+---
+ ebtables-restore.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/ebtables-restore.c b/ebtables-restore.c
+index bb4d0cf..d7df38c 100644
+--- a/ebtables-restore.c
++++ b/ebtables-restore.c
+@@ -17,6 +17,7 @@
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
++#define _GNU_SOURCE
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+@@ -76,7 +77,7 @@ int main(int argc_, char *argv_[])
+ line++;
+ if (*cmdline == '#' || *cmdline == '\n')
+ continue;
+- *strchr(cmdline, '\n') = '\0';
++ *strchrnul(cmdline, '\n') = '\0';
+ if (*cmdline == '*') {
+ if (table_nr != -1) {
+ ebt_deliver_table(&replace[table_nr]);
+--
+2.56.0
+
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/ebtables.git/commitdiff/aaca582d77f8f6fe3fdb96df541c69f1ec2d0edb
More information about the pld-cvs-commit
mailing list