Re: [PATCH v2] btrfs: assert sizes of ioctl structures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 15, 2020 at 07:12:09AM +0000, Johannes Thumshirn wrote:
> On 14/07/2020 16:56, David Sterba wrote:
> > On Tue, Jul 14, 2020 at 02:49:31PM +0000, Johannes Thumshirn wrote:
> >> On 14/07/2020 14:33, David Sterba wrote:
> >>> On Tue, Jul 14, 2020 at 06:32:36PM +0900, Johannes Thumshirn wrote:
> >>>> When expanding ioctl interfaces we want to make sure we're not changing
> >>>> the size of the structures, otherwise it can lead to incorrect transfers
> >>>> between kernel and user-space.
> >>>>
> >>>> Build time assert the size of each structure so we're not running into any
> >>>> incompatibilities.
> >>>>
> >>>> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@xxxxxxx>
> >>>
> >>> I've tried 32bit build and the assertion fails for many structures, but
> >>> I was expecting only the send one because it contains the pointer.
> >>
> >> I wonder if we should have two different asserts for 32 and 64bit for 
> >> these structures or remove the asserts from them.
> >>
> >> Having a 32 and 64bit assert will add some ifdeffery, let me see how 
> >> ugly this will get.
> > 
> > Progs do the switch using sizeof(long) and ?: operator but I don't know
> > if this works with _Static_assert as progs use the struct + bitfield
> > way.
> > 
> 
> I can try but it's ugly as hell IMHO

Or we can add macros like

ASSERT_STRUCT_SIZE(struct name, 64);

ASSERT_STRUCT_SIZE_32_64(struct name, 32, 64);

and then do the ifdefs at the definition time.




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux