* [netfilter-nf-next:testing 2/9] ./usr/include/linux/netfilter_bridge/ebtables.h:163:26: warning: field 'target' with variable sized type 'struct ebt_entry_target' not at the end of a struct or class is a GNU extension
@ 2023-08-17 5:03 kernel test robot
2023-08-17 6:09 ` Kees Cook
0 siblings, 1 reply; 6+ messages in thread
From: kernel test robot @ 2023-08-17 5:03 UTC (permalink / raw)
To: GONG, Ruiqi; +Cc: llvm, oe-kbuild-all, Florian Westphal, Kees Cook
tree: git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next.git testing
head: 015e2d9101d3713c7bee16dccad171df04a3bbd5
commit: 61b9e6bd48a6317c0a44ee4f3fecdec9de5baa9e [2/9] netfilter: ebtables: replace zero-length array members
config: i386-buildonly-randconfig-r004-20230817 (https://download.01.org/0day-ci/archive/20230817/202308171249.g1ywxhII-lkp@intel.com/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce: (https://download.01.org/0day-ci/archive/20230817/202308171249.g1ywxhII-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308171249.g1ywxhII-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from <built-in>:1:
>> ./usr/include/linux/netfilter_bridge/ebtables.h:163:26: warning: field 'target' with variable sized type 'struct ebt_entry_target' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct ebt_entry_target target;
^
1 warning generated.
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [netfilter-nf-next:testing 2/9] ./usr/include/linux/netfilter_bridge/ebtables.h:163:26: warning: field 'target' with variable sized type 'struct ebt_entry_target' not at the end of a struct or class is a GNU extension 2023-08-17 5:03 [netfilter-nf-next:testing 2/9] ./usr/include/linux/netfilter_bridge/ebtables.h:163:26: warning: field 'target' with variable sized type 'struct ebt_entry_target' not at the end of a struct or class is a GNU extension kernel test robot @ 2023-08-17 6:09 ` Kees Cook 2023-08-17 8:26 ` Florian Westphal 0 siblings, 1 reply; 6+ messages in thread From: Kees Cook @ 2023-08-17 6:09 UTC (permalink / raw) To: GONG, Ruiqi Cc: kernel test robot, llvm, oe-kbuild-all, Florian Westphal, linux-hardening On Thu, Aug 17, 2023 at 01:03:20PM +0800, kernel test robot wrote: > tree: git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next.git testing > head: 015e2d9101d3713c7bee16dccad171df04a3bbd5 > commit: 61b9e6bd48a6317c0a44ee4f3fecdec9de5baa9e [2/9] netfilter: ebtables: replace zero-length array members > config: i386-buildonly-randconfig-r004-20230817 (https://download.01.org/0day-ci/archive/20230817/202308171249.g1ywxhII-lkp@intel.com/config) > compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) > reproduce: (https://download.01.org/0day-ci/archive/20230817/202308171249.g1ywxhII-lkp@intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <lkp@intel.com> > | Closes: https://lore.kernel.org/oe-kbuild-all/202308171249.g1ywxhII-lkp@intel.com/ > > All warnings (new ones prefixed by >>): > > In file included from <built-in>:1: > >> ./usr/include/linux/netfilter_bridge/ebtables.h:163:26: warning: field 'target' with variable sized type 'struct ebt_entry_target' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end] > struct ebt_entry_target target; > ^ > 1 warning generated. Eww, it looks like "struct ebt_entry_target" is used _within_ another struct: struct ebt_standard_target { struct ebt_entry_target target; int verdict; }; So "verdict" overlaps with the "data" FAM: struct ebt_entry_target { union { struct { char name[EBT_EXTENSION_MAXNAMELEN]; __u8 revision; }; struct xt_target *target; } u; /* size of data */ unsigned int target_size; unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); }; These have been fixed in the past in a variety of ways -- it all depends on how userspace is using them. In looking at Debian Code Search: https://codesearch.debian.net/search?q=struct+ebt_standard_target&literal=1 It is exclusively doing casts and looking at the "verdict" member. So the easiest conversion might be this: struct ebt_standard_target { - struct ebt_entry_target target; + unsigned char hdr[sizeof(struct ebt_entry_target)]; int verdict; }; Or this might work (not tested): diff --git a/include/uapi/linux/netfilter_bridge/ebtables.h b/include/uapi/linux/netfilter_bridge/ebtables.h index a494cf43a755..d6f10163b14a 100644 --- a/include/uapi/linux/netfilter_bridge/ebtables.h +++ b/include/uapi/linux/netfilter_bridge/ebtables.h @@ -146,23 +146,25 @@ struct ebt_entry_watcher { }; struct ebt_entry_target { - union { - struct { - char name[EBT_EXTENSION_MAXNAMELEN]; - __u8 revision; - }; - struct xt_target *target; - } u; - /* size of data */ - unsigned int target_size; - unsigned char data[0] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); + struct ebt_entry_target_hdr { + union { + struct { + char name[EBT_EXTENSION_MAXNAMELEN]; + __u8 revision; + }; + struct xt_target *target; + } u; + /* size of data */ + unsigned int target_size; + }; + unsigned char data[] __attribute__ ((aligned (__alignof__(struct ebt_replace)))); }; #define EBT_STANDARD_TARGET "standard" struct ebt_standard_target { - struct ebt_entry_target target; - int verdict; + struct ebt_entry_target_hdr target; + int verdict __attribute__ ((aligned (__alignof__(struct ebt_replace)))); }; /* one entry */ -- Kees Cook ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [netfilter-nf-next:testing 2/9] ./usr/include/linux/netfilter_bridge/ebtables.h:163:26: warning: field 'target' with variable sized type 'struct ebt_entry_target' not at the end of a struct or class is a GNU extension 2023-08-17 6:09 ` Kees Cook @ 2023-08-17 8:26 ` Florian Westphal 2023-08-17 17:02 ` Kees Cook 0 siblings, 1 reply; 6+ messages in thread From: Florian Westphal @ 2023-08-17 8:26 UTC (permalink / raw) To: Kees Cook Cc: GONG, Ruiqi, kernel test robot, llvm, oe-kbuild-all, Florian Westphal, linux-hardening Kees Cook <keescook@chromium.org> wrote: > On Thu, Aug 17, 2023 at 01:03:20PM +0800, kernel test robot wrote: > > tree: git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next.git testing > > head: 015e2d9101d3713c7bee16dccad171df04a3bbd5 > > commit: 61b9e6bd48a6317c0a44ee4f3fecdec9de5baa9e [2/9] netfilter: ebtables: replace zero-length array members > > config: i386-buildonly-randconfig-r004-20230817 (https://download.01.org/0day-ci/archive/20230817/202308171249.g1ywxhII-lkp@intel.com/config) > > compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) > > reproduce: (https://download.01.org/0day-ci/archive/20230817/202308171249.g1ywxhII-lkp@intel.com/reproduce) > > > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > > the same patch/commit), kindly add following tags > > | Reported-by: kernel test robot <lkp@intel.com> > > | Closes: https://lore.kernel.org/oe-kbuild-all/202308171249.g1ywxhII-lkp@intel.com/ > > > > All warnings (new ones prefixed by >>): > > > > In file included from <built-in>:1: > > >> ./usr/include/linux/netfilter_bridge/ebtables.h:163:26: warning: field 'target' with variable sized type 'struct ebt_entry_target' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end] > > struct ebt_entry_target target; > > ^ > > 1 warning generated. > > Eww, it looks like "struct ebt_entry_target" is used _within_ another > struct: > > struct ebt_standard_target { > struct ebt_entry_target target; > int verdict; > }; Yes, same as xt_standard_target. > These have been fixed in the past in a variety of ways -- it all depends > on how userspace is using them. In looking at Debian Code Search: > https://codesearch.debian.net/search?q=struct+ebt_standard_target&literal=1 > > It is exclusively doing casts and looking at the "verdict" member. So > the easiest conversion might be this: > > struct ebt_standard_target { > - struct ebt_entry_target target; > + unsigned char hdr[sizeof(struct ebt_entry_target)]; > int verdict; I don't think its worth doing all of this. Can't we just keep it as-is and drop the relevant hunk from the patch? ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [netfilter-nf-next:testing 2/9] ./usr/include/linux/netfilter_bridge/ebtables.h:163:26: warning: field 'target' with variable sized type 'struct ebt_entry_target' not at the end of a struct or class is a GNU extension 2023-08-17 8:26 ` Florian Westphal @ 2023-08-17 17:02 ` Kees Cook 2023-08-18 3:24 ` GONG, Ruiqi 0 siblings, 1 reply; 6+ messages in thread From: Kees Cook @ 2023-08-17 17:02 UTC (permalink / raw) To: Florian Westphal Cc: GONG, Ruiqi, kernel test robot, llvm, oe-kbuild-all, linux-hardening On Thu, Aug 17, 2023 at 10:26:18AM +0200, Florian Westphal wrote: > Kees Cook <keescook@chromium.org> wrote: > > On Thu, Aug 17, 2023 at 01:03:20PM +0800, kernel test robot wrote: > > > tree: git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next.git testing > > > head: 015e2d9101d3713c7bee16dccad171df04a3bbd5 > > > commit: 61b9e6bd48a6317c0a44ee4f3fecdec9de5baa9e [2/9] netfilter: ebtables: replace zero-length array members > > > config: i386-buildonly-randconfig-r004-20230817 (https://download.01.org/0day-ci/archive/20230817/202308171249.g1ywxhII-lkp@intel.com/config) > > > compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) > > > reproduce: (https://download.01.org/0day-ci/archive/20230817/202308171249.g1ywxhII-lkp@intel.com/reproduce) > > > > > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > > > the same patch/commit), kindly add following tags > > > | Reported-by: kernel test robot <lkp@intel.com> > > > | Closes: https://lore.kernel.org/oe-kbuild-all/202308171249.g1ywxhII-lkp@intel.com/ > > > > > > All warnings (new ones prefixed by >>): > > > > > > In file included from <built-in>:1: > > > >> ./usr/include/linux/netfilter_bridge/ebtables.h:163:26: warning: field 'target' with variable sized type 'struct ebt_entry_target' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end] > > > struct ebt_entry_target target; > > > ^ > > > 1 warning generated. > > > > Eww, it looks like "struct ebt_entry_target" is used _within_ another > > struct: > > > > struct ebt_standard_target { > > struct ebt_entry_target target; > > int verdict; > > }; > > Yes, same as xt_standard_target. > > > These have been fixed in the past in a variety of ways -- it all depends > > on how userspace is using them. In looking at Debian Code Search: > > https://codesearch.debian.net/search?q=struct+ebt_standard_target&literal=1 > > > > It is exclusively doing casts and looking at the "verdict" member. So > > the easiest conversion might be this: > > > > struct ebt_standard_target { > > - struct ebt_entry_target target; > > + unsigned char hdr[sizeof(struct ebt_entry_target)]; > > int verdict; > > I don't think its worth doing all of this. > > Can't we just keep it as-is and drop the relevant hunk from the patch? For now, yeah. But we'll need to find a solution as flex-array structures overlapping variables is considered deprecated (it can lead to ambiguous sizing results). But as long as the kernel itself doesn't use struct ebt_standard_target, we can kick the can down the road a bit more. :) -- Kees Cook ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [netfilter-nf-next:testing 2/9] ./usr/include/linux/netfilter_bridge/ebtables.h:163:26: warning: field 'target' with variable sized type 'struct ebt_entry_target' not at the end of a struct or class is a GNU extension 2023-08-17 17:02 ` Kees Cook @ 2023-08-18 3:24 ` GONG, Ruiqi 2023-08-18 5:23 ` GONG, Ruiqi 0 siblings, 1 reply; 6+ messages in thread From: GONG, Ruiqi @ 2023-08-18 3:24 UTC (permalink / raw) To: Kees Cook, Florian Westphal Cc: kernel test robot, llvm, oe-kbuild-all, linux-hardening On 2023/08/18 1:02, Kees Cook wrote: > On Thu, Aug 17, 2023 at 10:26:18AM +0200, Florian Westphal wrote: >> Kees Cook <keescook@chromium.org> wrote: >>> On Thu, Aug 17, 2023 at 01:03:20PM +0800, kernel test robot wrote: >>>> tree: git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next.git testing >>>> head: 015e2d9101d3713c7bee16dccad171df04a3bbd5 >>>> commit: 61b9e6bd48a6317c0a44ee4f3fecdec9de5baa9e [2/9] netfilter: ebtables: replace zero-length array members >>>> config: i386-buildonly-randconfig-r004-20230817 (https://download.01.org/0day-ci/archive/20230817/202308171249.g1ywxhII-lkp@intel.com/config) >>>> compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) >>>> reproduce: (https://download.01.org/0day-ci/archive/20230817/202308171249.g1ywxhII-lkp@intel.com/reproduce) >>>> >>>> If you fix the issue in a separate patch/commit (i.e. not just a new version of >>>> the same patch/commit), kindly add following tags >>>> | Reported-by: kernel test robot <lkp@intel.com> >>>> | Closes: https://lore.kernel.org/oe-kbuild-all/202308171249.g1ywxhII-lkp@intel.com/ >>>> >>>> All warnings (new ones prefixed by >>): >>>> >>>> In file included from <built-in>:1: >>>>>> ./usr/include/linux/netfilter_bridge/ebtables.h:163:26: warning: field 'target' with variable sized type 'struct ebt_entry_target' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end] >>>> struct ebt_entry_target target; >>>> ^ >>>> 1 warning generated. >>> >>> Eww, it looks like "struct ebt_entry_target" is used _within_ another >>> struct: >>> >>> struct ebt_standard_target { >>> struct ebt_entry_target target; >>> int verdict; >>> }; >> >> Yes, same as xt_standard_target. >> >>> These have been fixed in the past in a variety of ways -- it all depends >>> on how userspace is using them. In looking at Debian Code Search: >>> https://codesearch.debian.net/search?q=struct+ebt_standard_target&literal=1 >>> >>> It is exclusively doing casts and looking at the "verdict" member. So >>> the easiest conversion might be this: >>> >>> struct ebt_standard_target { >>> - struct ebt_entry_target target; >>> + unsigned char hdr[sizeof(struct ebt_entry_target)]; >>> int verdict; >> >> I don't think its worth doing all of this. >> >> Can't we just keep it as-is and drop the relevant hunk from the patch? > > For now, yeah. But we'll need to find a solution as flex-array > structures overlapping variables is considered deprecated (it can lead > to ambiguous sizing results). But as long as the kernel itself doesn't > use struct ebt_standard_target, we can kick the can down the road a bit > more. :) > I agree that we can complete the whole transformation step-by-step. I will make another patch without the problematic replacement. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [netfilter-nf-next:testing 2/9] ./usr/include/linux/netfilter_bridge/ebtables.h:163:26: warning: field 'target' with variable sized type 'struct ebt_entry_target' not at the end of a struct or class is a GNU extension 2023-08-18 3:24 ` GONG, Ruiqi @ 2023-08-18 5:23 ` GONG, Ruiqi 0 siblings, 0 replies; 6+ messages in thread From: GONG, Ruiqi @ 2023-08-18 5:23 UTC (permalink / raw) To: Kees Cook, Florian Westphal Cc: kernel test robot, llvm, oe-kbuild-all, linux-hardening On 2023/08/18 11:24, GONG, Ruiqi wrote: > > > On 2023/08/18 1:02, Kees Cook wrote: >> On Thu, Aug 17, 2023 at 10:26:18AM +0200, Florian Westphal wrote: >>> Kees Cook <keescook@chromium.org> wrote: >>>> On Thu, Aug 17, 2023 at 01:03:20PM +0800, kernel test robot wrote: >>>>> tree: git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next.git testing >>>>> head: 015e2d9101d3713c7bee16dccad171df04a3bbd5 >>>>> commit: 61b9e6bd48a6317c0a44ee4f3fecdec9de5baa9e [2/9] netfilter: ebtables: replace zero-length array members >>>>> config: i386-buildonly-randconfig-r004-20230817 (https://download.01.org/0day-ci/archive/20230817/202308171249.g1ywxhII-lkp@intel.com/config) >>>>> compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) >>>>> reproduce: (https://download.01.org/0day-ci/archive/20230817/202308171249.g1ywxhII-lkp@intel.com/reproduce) >>>>> >>>>> If you fix the issue in a separate patch/commit (i.e. not just a new version of >>>>> the same patch/commit), kindly add following tags >>>>> | Reported-by: kernel test robot <lkp@intel.com> >>>>> | Closes: https://lore.kernel.org/oe-kbuild-all/202308171249.g1ywxhII-lkp@intel.com/ >>>>> >>>>> All warnings (new ones prefixed by >>): >>>>> >>>>> In file included from <built-in>:1: >>>>>>> ./usr/include/linux/netfilter_bridge/ebtables.h:163:26: warning: field 'target' with variable sized type 'struct ebt_entry_target' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end] >>>>> struct ebt_entry_target target; >>>>> ^ >>>>> 1 warning generated. >>>> >>>> Eww, it looks like "struct ebt_entry_target" is used _within_ another >>>> struct: >>>> >>>> struct ebt_standard_target { >>>> struct ebt_entry_target target; >>>> int verdict; >>>> }; >>> >>> Yes, same as xt_standard_target. >>> >>>> These have been fixed in the past in a variety of ways -- it all depends >>>> on how userspace is using them. In looking at Debian Code Search: >>>> https://codesearch.debian.net/search?q=struct+ebt_standard_target&literal=1 >>>> >>>> It is exclusively doing casts and looking at the "verdict" member. So >>>> the easiest conversion might be this: >>>> >>>> struct ebt_standard_target { >>>> - struct ebt_entry_target target; >>>> + unsigned char hdr[sizeof(struct ebt_entry_target)]; >>>> int verdict; >>> >>> I don't think its worth doing all of this. >>> >>> Can't we just keep it as-is and drop the relevant hunk from the patch? >> >> For now, yeah. But we'll need to find a solution as flex-array >> structures overlapping variables is considered deprecated (it can lead >> to ambiguous sizing results). But as long as the kernel itself doesn't >> use struct ebt_standard_target, we can kick the can down the road a bit >> more. :) >> > > I agree that we can complete the whole transformation step-by-step. I > will make another patch without the problematic replacement. I didn't notice that the patch had been modified and merged into nf-next's testing branch. Let's use that and I won't send another one. Thanks Florian! XD ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-08-18 5:23 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-08-17 5:03 [netfilter-nf-next:testing 2/9] ./usr/include/linux/netfilter_bridge/ebtables.h:163:26: warning: field 'target' with variable sized type 'struct ebt_entry_target' not at the end of a struct or class is a GNU extension kernel test robot 2023-08-17 6:09 ` Kees Cook 2023-08-17 8:26 ` Florian Westphal 2023-08-17 17:02 ` Kees Cook 2023-08-18 3:24 ` GONG, Ruiqi 2023-08-18 5:23 ` GONG, Ruiqi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox