1*4882a593SmuzhiyunFrom 7297a8ef3cab3b0faf1426622ee902a2144e2e89 Mon Sep 17 00:00:00 2001 2*4882a593SmuzhiyunFrom: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> 3*4882a593SmuzhiyunDate: Wed, 24 Mar 2021 11:27:14 +0100 4*4882a593SmuzhiyunSubject: [PATCH] ebtables.h: restore KERNEL_64_USERSPACE_32 checks 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunCommit e6359eedfbf497e52d52451072aea4713ed80a88 replaced the file ebtables.h 7*4882a593Smuzhiyunbut removed the usage of KERNEL_64_USERSPACE_32. This breaks boards where 8*4882a593Smuzhiyunsuch flag is relevant, with following messages: 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun[ 6364.971346] kernel msg: ebtables bug: please report to author: Standard target size too big 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunUnable to update the kernel. Two possible causes: 13*4882a593Smuzhiyun1. Multiple ebtables programs were executing simultaneously. The ebtables 14*4882a593Smuzhiyun userspace tool doesn't by default support multiple ebtables programs running 15*4882a593Smuzhiyun concurrently. The ebtables option --concurrent or a tool like flock can be 16*4882a593Smuzhiyun used to support concurrent scripts that update the ebtables kernel tables. 17*4882a593Smuzhiyun2. The kernel doesn't support a certain ebtables extension, consider 18*4882a593Smuzhiyun recompiling your kernel or insmod the extension. 19*4882a593Smuzhiyun 20*4882a593SmuzhiyunAnalysis shows that the structure 'ebt_replace' passed from userspace 21*4882a593Smuzhiyunebtables to the kernel, is too small, i.e 80 bytes instead of 120 in case of 22*4882a593Smuzhiyun64-bit kernel. 23*4882a593Smuzhiyun 24*4882a593SmuzhiyunNote that the ebtables build system seems to assume that 'sparc64' is the 25*4882a593Smuzhiyunonly case where KERNEL_64_USERSPACE_32 is relevant, but this is not true. 26*4882a593SmuzhiyunThis situation can happen on many architectures, especially in embedded 27*4882a593Smuzhiyunsystems. For example, an Aarch64 processor with kernel in 64-bit but 28*4882a593Smuzhiyunuserland build for 32-bit Arm. Or a 64-bit MIPS Octeon III processor, with 29*4882a593Smuzhiyunuserland running in the 'n32' ABI. 30*4882a593Smuzhiyun 31*4882a593SmuzhiyunSigned-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> 32*4882a593SmuzhiyunUpstream-Status: http://patchwork.ozlabs.org/project/netfilter-devel/patch/20210518181730.13436-1-patrickdepinguin@gmail.com/ 33*4882a593Smuzhiyun--- 34*4882a593Smuzhiyun include/linux/netfilter_bridge/ebtables.h | 21 +++++++++++++++++++++ 35*4882a593Smuzhiyun 1 file changed, 21 insertions(+) 36*4882a593Smuzhiyun 37*4882a593Smuzhiyundiff --git a/include/linux/netfilter_bridge/ebtables.h b/include/linux/netfilter_bridge/ebtables.h 38*4882a593Smuzhiyunindex 5be75f2..3c2b61e 100644 39*4882a593Smuzhiyun--- a/include/linux/netfilter_bridge/ebtables.h 40*4882a593Smuzhiyun+++ b/include/linux/netfilter_bridge/ebtables.h 41*4882a593Smuzhiyun@@ -49,12 +49,21 @@ struct ebt_replace { 42*4882a593Smuzhiyun /* total size of the entries */ 43*4882a593Smuzhiyun unsigned int entries_size; 44*4882a593Smuzhiyun /* start of the chains */ 45*4882a593Smuzhiyun+#ifdef KERNEL_64_USERSPACE_32 46*4882a593Smuzhiyun+ uint64_t hook_entry[NF_BR_NUMHOOKS]; 47*4882a593Smuzhiyun+#else 48*4882a593Smuzhiyun struct ebt_entries *hook_entry[NF_BR_NUMHOOKS]; 49*4882a593Smuzhiyun+#endif 50*4882a593Smuzhiyun /* nr of counters userspace expects back */ 51*4882a593Smuzhiyun unsigned int num_counters; 52*4882a593Smuzhiyun /* where the kernel will put the old counters */ 53*4882a593Smuzhiyun+#ifdef KERNEL_64_USERSPACE_32 54*4882a593Smuzhiyun+ uint64_t counters; 55*4882a593Smuzhiyun+ uint64_t entries; 56*4882a593Smuzhiyun+#else 57*4882a593Smuzhiyun struct ebt_counter *counters; 58*4882a593Smuzhiyun char *entries; 59*4882a593Smuzhiyun+#endif 60*4882a593Smuzhiyun }; 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun struct ebt_replace_kernel { 63*4882a593Smuzhiyun@@ -129,6 +138,9 @@ struct ebt_entry_match { 64*4882a593Smuzhiyun } u; 65*4882a593Smuzhiyun /* size of data */ 66*4882a593Smuzhiyun unsigned int match_size; 67*4882a593Smuzhiyun+#ifdef KERNEL_64_USERSPACE_32 68*4882a593Smuzhiyun+ unsigned int pad; 69*4882a593Smuzhiyun+#endif 70*4882a593Smuzhiyun unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); 71*4882a593Smuzhiyun }; 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun@@ -142,6 +154,9 @@ struct ebt_entry_watcher { 74*4882a593Smuzhiyun } u; 75*4882a593Smuzhiyun /* size of data */ 76*4882a593Smuzhiyun unsigned int watcher_size; 77*4882a593Smuzhiyun+#ifdef KERNEL_64_USERSPACE_32 78*4882a593Smuzhiyun+ unsigned int pad; 79*4882a593Smuzhiyun+#endif 80*4882a593Smuzhiyun unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); 81*4882a593Smuzhiyun }; 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun@@ -155,6 +170,9 @@ struct ebt_entry_target { 84*4882a593Smuzhiyun } u; 85*4882a593Smuzhiyun /* size of data */ 86*4882a593Smuzhiyun unsigned int target_size; 87*4882a593Smuzhiyun+#ifdef KERNEL_64_USERSPACE_32 88*4882a593Smuzhiyun+ unsigned int pad; 89*4882a593Smuzhiyun+#endif 90*4882a593Smuzhiyun unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); 91*4882a593Smuzhiyun }; 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun@@ -162,6 +180,9 @@ struct ebt_entry_target { 94*4882a593Smuzhiyun struct ebt_standard_target { 95*4882a593Smuzhiyun struct ebt_entry_target target; 96*4882a593Smuzhiyun int verdict; 97*4882a593Smuzhiyun+#ifdef KERNEL_64_USERSPACE_32 98*4882a593Smuzhiyun+ unsigned int pad; 99*4882a593Smuzhiyun+#endif 100*4882a593Smuzhiyun }; 101*4882a593Smuzhiyun 102*4882a593Smuzhiyun /* one entry */ 103*4882a593Smuzhiyun-- 104*4882a593Smuzhiyun2.26.2 105*4882a593Smuzhiyun 106