Messages in this thread | | | From | "Romanowski, Rafal" <> | Subject | RE: [Intel-wired-lan] [PATCH net-next 2/3] virtchnl: fix fake 1-elem arrays in structures allocated as `nents + 1` | Date | Wed, 16 Aug 2023 12:49:35 +0000 |
| |
> -----Original Message----- > From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of > Kees Cook > Sent: piątek, 4 sierpnia 2023 10:29 > To: Lobakin, Aleksander <aleksander.lobakin@intel.com> > Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>; Zaremba, > Larysa <larysa.zaremba@intel.com>; netdev@vger.kernel.org; Gustavo A. R. > Silva <gustavoars@kernel.org>; linux-kernel@vger.kernel.org; Eric Dumazet > <edumazet@google.com>; intel-wired-lan@lists.osuosl.org; linux- > hardening@vger.kernel.org; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni > <pabeni@redhat.com>; David S. Miller <davem@davemloft.net> > Subject: Re: [Intel-wired-lan] [PATCH net-next 2/3] virtchnl: fix fake 1-elem > arrays in structures allocated as `nents + 1` > > On Fri, Jul 28, 2023 at 05:52:06PM +0200, Alexander Lobakin wrote: > > There are five virtchnl structures, which are allocated and checked in > > the code as `nents + 1`, meaning that they always have memory for one > > excessive element regardless of their actual number. This comes from > > that their sizeof() includes space for 1 element and then they get > > allocated via struct_size() or its open-coded equivalents, passing the > > actual number of elements. > > Expand virtchnl_struct_size() to handle such structures and replace > > those 1-elem arrays with proper flex ones. Also fix several places > > which open-code %IAVF_VIRTCHNL_VF_RESOURCE_SIZE. Finally, let the > > virtchnl_ether_addr_list size be computed automatically when there's > > no enough space for the whole list, otherwise we have to open-code > > reverse struct_size() logics. > > > > Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com> > > I remain a fan of _Generic uses. :) > > Reviewed-by: Kees Cook <keescook@chromium.org> > > -- > Kees Cook > _______________________________________________ > Intel-wired-lan mailing list > Intel-wired-lan@osuosl.org > https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Tested-by: Rafal Romanowski <rafal.romanowski@intel.com>
| |