linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH -next] mux: convert mux_chip->mux to flexible array
       [not found] <20230223014221.1710307-1-jacob.e.keller@intel.com>
@ 2023-02-27 20:28 ` Jesse Brandeburg
  2024-02-19  5:04   ` Kees Cook
  0 siblings, 1 reply; 4+ messages in thread
From: Jesse Brandeburg @ 2023-02-27 20:28 UTC (permalink / raw)
  To: Jacob Keller, Peter Rosin, keescook, gustavoars; +Cc: linux-kernel, linux-i2c

On 2/22/2023 5:42 PM, Jacob Keller wrote:
> The mux_chip structure size is over allocated to additionally include both
> the array of mux controllers as well as a device specific private area.
> The controllers array is then pointed to by assigning mux_chip->mux to the
> first block of extra memory, while the private area is extracted via
> mux_chip_priv() and points to the area just after the controllers.
> 
> The size of the mux_chip allocation uses direct multiplication and addition
> rather than the <linux/overflow.h> helpers. In addition, the mux_chip->mux
> struct member wastes space by having to store the pointer as part of the
> structures.
> 
> Convert struct mux_chip to use a flexible array member for the mux
> controller array. Use struct_size() and size_add() to compute the size of
> the structure while protecting against overflow.
> 
> After converting the mux pointer, notice that two 4-byte holes remain in
> the structure layout due to the alignment requirements for the dev
> sub-structure and the ops pointer.
> 
> These can be easily fixed through re-ordering the id field to the 4-byte
> hole just after the controllers member.

Looks good to me (just a driver dev, not a mux dev!). Also added
linux-i2c mailing list and a couple others for more review.

Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>

related thread (cocci script) at [1]

[1]
https://lore.kernel.org/all/20230227202428.3657443-1-jacob.e.keller@intel.com/




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] mux: convert mux_chip->mux to flexible array
  2023-02-27 20:28 ` [PATCH -next] mux: convert mux_chip->mux to flexible array Jesse Brandeburg
@ 2024-02-19  5:04   ` Kees Cook
  2024-02-20 21:27     ` Jacob Keller
  0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2024-02-19  5:04 UTC (permalink / raw)
  To: Jesse Brandeburg
  Cc: Jacob Keller, Peter Rosin, gustavoars, linux-kernel, linux-i2c

On Mon, Feb 27, 2023 at 12:28:43PM -0800, Jesse Brandeburg wrote:
> On 2/22/2023 5:42 PM, Jacob Keller wrote:
> > The mux_chip structure size is over allocated to additionally include both
> > the array of mux controllers as well as a device specific private area.
> > The controllers array is then pointed to by assigning mux_chip->mux to the
> > first block of extra memory, while the private area is extracted via
> > mux_chip_priv() and points to the area just after the controllers.
> > 
> > The size of the mux_chip allocation uses direct multiplication and addition
> > rather than the <linux/overflow.h> helpers. In addition, the mux_chip->mux
> > struct member wastes space by having to store the pointer as part of the
> > structures.
> > 
> > Convert struct mux_chip to use a flexible array member for the mux
> > controller array. Use struct_size() and size_add() to compute the size of
> > the structure while protecting against overflow.
> > 
> > After converting the mux pointer, notice that two 4-byte holes remain in
> > the structure layout due to the alignment requirements for the dev
> > sub-structure and the ops pointer.
> > 
> > These can be easily fixed through re-ordering the id field to the 4-byte
> > hole just after the controllers member.
> 
> Looks good to me (just a driver dev, not a mux dev!). Also added
> linux-i2c mailing list and a couple others for more review.
> 
> Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
> 
> related thread (cocci script) at [1]
> 
> [1]
> https://lore.kernel.org/all/20230227202428.3657443-1-jacob.e.keller@intel.com/

*thread necromancy*

Can we land this? It's the last struct_size() instance that the above
Coccinelle script flags.

Reviewed-by: Kees Cook <keescook@chromium.org>

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] mux: convert mux_chip->mux to flexible array
  2024-02-19  5:04   ` Kees Cook
@ 2024-02-20 21:27     ` Jacob Keller
  2024-02-23 23:52       ` Kees Cook
  0 siblings, 1 reply; 4+ messages in thread
From: Jacob Keller @ 2024-02-20 21:27 UTC (permalink / raw)
  To: Kees Cook, Jesse Brandeburg
  Cc: Peter Rosin, gustavoars, linux-kernel, linux-i2c



On 2/18/2024 9:04 PM, Kees Cook wrote:
> On Mon, Feb 27, 2023 at 12:28:43PM -0800, Jesse Brandeburg wrote:
>> On 2/22/2023 5:42 PM, Jacob Keller wrote:
>>> The mux_chip structure size is over allocated to additionally include both
>>> the array of mux controllers as well as a device specific private area.
>>> The controllers array is then pointed to by assigning mux_chip->mux to the
>>> first block of extra memory, while the private area is extracted via
>>> mux_chip_priv() and points to the area just after the controllers.
>>>
>>> The size of the mux_chip allocation uses direct multiplication and addition
>>> rather than the <linux/overflow.h> helpers. In addition, the mux_chip->mux
>>> struct member wastes space by having to store the pointer as part of the
>>> structures.
>>>
>>> Convert struct mux_chip to use a flexible array member for the mux
>>> controller array. Use struct_size() and size_add() to compute the size of
>>> the structure while protecting against overflow.
>>>
>>> After converting the mux pointer, notice that two 4-byte holes remain in
>>> the structure layout due to the alignment requirements for the dev
>>> sub-structure and the ops pointer.
>>>
>>> These can be easily fixed through re-ordering the id field to the 4-byte
>>> hole just after the controllers member.
>>
>> Looks good to me (just a driver dev, not a mux dev!). Also added
>> linux-i2c mailing list and a couple others for more review.
>>
>> Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
>>
>> related thread (cocci script) at [1]
>>
>> [1]
>> https://lore.kernel.org/all/20230227202428.3657443-1-jacob.e.keller@intel.com/
> 
> *thread necromancy*
> 
> Can we land this? It's the last struct_size() instance that the above
> Coccinelle script flags.
> 
> Reviewed-by: Kees Cook <keescook@chromium.org>
> 

I'm happy to send a v2 if we need.

Thanks,
Jake

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH -next] mux: convert mux_chip->mux to flexible array
  2024-02-20 21:27     ` Jacob Keller
@ 2024-02-23 23:52       ` Kees Cook
  0 siblings, 0 replies; 4+ messages in thread
From: Kees Cook @ 2024-02-23 23:52 UTC (permalink / raw)
  To: Jacob Keller
  Cc: Jesse Brandeburg, Peter Rosin, gustavoars, linux-kernel,
	linux-i2c

On Tue, Feb 20, 2024 at 01:27:45PM -0800, Jacob Keller wrote:
> 
> 
> On 2/18/2024 9:04 PM, Kees Cook wrote:
> > On Mon, Feb 27, 2023 at 12:28:43PM -0800, Jesse Brandeburg wrote:
> >> On 2/22/2023 5:42 PM, Jacob Keller wrote:
> >>> The mux_chip structure size is over allocated to additionally include both
> >>> the array of mux controllers as well as a device specific private area.
> >>> The controllers array is then pointed to by assigning mux_chip->mux to the
> >>> first block of extra memory, while the private area is extracted via
> >>> mux_chip_priv() and points to the area just after the controllers.
> >>>
> >>> The size of the mux_chip allocation uses direct multiplication and addition
> >>> rather than the <linux/overflow.h> helpers. In addition, the mux_chip->mux
> >>> struct member wastes space by having to store the pointer as part of the
> >>> structures.
> >>>
> >>> Convert struct mux_chip to use a flexible array member for the mux
> >>> controller array. Use struct_size() and size_add() to compute the size of
> >>> the structure while protecting against overflow.
> >>>
> >>> After converting the mux pointer, notice that two 4-byte holes remain in
> >>> the structure layout due to the alignment requirements for the dev
> >>> sub-structure and the ops pointer.
> >>>
> >>> These can be easily fixed through re-ordering the id field to the 4-byte
> >>> hole just after the controllers member.
> >>
> >> Looks good to me (just a driver dev, not a mux dev!). Also added
> >> linux-i2c mailing list and a couple others for more review.
> >>
> >> Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
> >>
> >> related thread (cocci script) at [1]
> >>
> >> [1]
> >> https://lore.kernel.org/all/20230227202428.3657443-1-jacob.e.keller@intel.com/
> > 
> > *thread necromancy*
> > 
> > Can we land this? It's the last struct_size() instance that the above
> > Coccinelle script flags.
> > 
> > Reviewed-by: Kees Cook <keescook@chromium.org>
> > 
> 
> I'm happy to send a v2 if we need.

Since it's been a while, yeah, can you send a v2?

Thanks!

-Kees

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-23 23:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20230223014221.1710307-1-jacob.e.keller@intel.com>
2023-02-27 20:28 ` [PATCH -next] mux: convert mux_chip->mux to flexible array Jesse Brandeburg
2024-02-19  5:04   ` Kees Cook
2024-02-20 21:27     ` Jacob Keller
2024-02-23 23:52       ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).