All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas De Schampheleire <patrickdepinguin@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: thomas.de_schampheleire@nokia.com
Subject: [ebtables PATCH 1/2] ebtables.h: restore KERNEL_64_USERSPACE_32 checks
Date: Tue, 18 May 2021 20:17:29 +0200	[thread overview]
Message-ID: <20210518181730.13436-1-patrickdepinguin@gmail.com> (raw)

From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>

Commit e6359eedfbf497e52d52451072aea4713ed80a88 replaced the file ebtables.h
but removed the usage of KERNEL_64_USERSPACE_32. This breaks boards where
such flag is relevant, with following messages:

[ 6364.971346] kernel msg: ebtables bug: please report to author: Standard target size too big

Unable to update the kernel. Two possible causes:
1. Multiple ebtables programs were executing simultaneously. The ebtables
   userspace tool doesn't by default support multiple ebtables programs running
   concurrently. The ebtables option --concurrent or a tool like flock can be
   used to support concurrent scripts that update the ebtables kernel tables.
2. The kernel doesn't support a certain ebtables extension, consider
   recompiling your kernel or insmod the extension.

Analysis shows that the structure 'ebt_replace' passed from userspace
ebtables to the kernel, is too small, i.e 80 bytes instead of 120 in case of
64-bit kernel.

Note that the ebtables build system seems to assume that 'sparc64' is the
only case where KERNEL_64_USERSPACE_32 is relevant, but this is not true.
This situation can happen on many architectures, especially in embedded
systems. For example, an Aarch64 processor with kernel in 64-bit but
userland built for 32-bit Arm. Or a 64-bit MIPS Octeon III processor, with
userland running in the 'n32' ABI.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
---
 include/linux/netfilter_bridge/ebtables.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/include/linux/netfilter_bridge/ebtables.h b/include/linux/netfilter_bridge/ebtables.h
index 5be75f2..3c2b61e 100644
--- a/include/linux/netfilter_bridge/ebtables.h
+++ b/include/linux/netfilter_bridge/ebtables.h
@@ -49,12 +49,21 @@ struct ebt_replace {
 	/* total size of the entries */
 	unsigned int entries_size;
 	/* start of the chains */
+#ifdef KERNEL_64_USERSPACE_32
+	uint64_t hook_entry[NF_BR_NUMHOOKS];
+#else
 	struct ebt_entries *hook_entry[NF_BR_NUMHOOKS];
+#endif
 	/* nr of counters userspace expects back */
 	unsigned int num_counters;
 	/* where the kernel will put the old counters */
+#ifdef KERNEL_64_USERSPACE_32
+	uint64_t counters;
+	uint64_t entries;
+#else
 	struct ebt_counter *counters;
 	char *entries;
+#endif
 };
 
 struct ebt_replace_kernel {
@@ -129,6 +138,9 @@ struct ebt_entry_match {
 	} u;
 	/* size of data */
 	unsigned int match_size;
+#ifdef KERNEL_64_USERSPACE_32
+	unsigned int pad;
+#endif
 	unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
 };
 
@@ -142,6 +154,9 @@ struct ebt_entry_watcher {
 	} u;
 	/* size of data */
 	unsigned int watcher_size;
+#ifdef KERNEL_64_USERSPACE_32
+	unsigned int pad;
+#endif
 	unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
 };
 
@@ -155,6 +170,9 @@ struct ebt_entry_target {
 	} u;
 	/* size of data */
 	unsigned int target_size;
+#ifdef KERNEL_64_USERSPACE_32
+	unsigned int pad;
+#endif
 	unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace))));
 };
 
@@ -162,6 +180,9 @@ struct ebt_entry_target {
 struct ebt_standard_target {
 	struct ebt_entry_target target;
 	int verdict;
+#ifdef KERNEL_64_USERSPACE_32
+	unsigned int pad;
+#endif
 };
 
 /* one entry */
-- 
2.26.3


             reply	other threads:[~2021-05-18 18:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-18 18:17 Thomas De Schampheleire [this message]
2021-05-18 18:17 ` [ebtables PATCH 2/2] configure.ac: add option --enable-kernel-64-userland-32 Thomas De Schampheleire
2021-05-24 15:26   ` Pablo Neira Ayuso
2021-05-25 11:52     ` Thomas De Schampheleire
2021-05-27 19:30       ` Pablo Neira Ayuso
2021-05-28 17:10         ` Florian Westphal
2021-05-31 12:11           ` Thomas De Schampheleire
2021-06-01 14:50             ` Florian Westphal

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=20210518181730.13436-1-patrickdepinguin@gmail.com \
    --to=patrickdepinguin@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=thomas.de_schampheleire@nokia.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.