Re: [PATCH] kernel.h: fix new warnings for container_of()

From: Kees Cook
Date: Tue Jun 20 2017 - 18:43:08 EST

On Tue, Jun 20, 2017 at 1:09 PM, Arnd Bergmann <arnd@xxxxxxxx> wrote:
> I see new warnings with gcc-7.0.1 with the modified container_of():
> fs/f2fs/dir.c: In function 'F2FS_I':
> fs/f2fs/f2fs.h:1122:385: note: found mismatched ssa struct pointer types: 'struct f2fs_inode_info' and 'struct inode'

This is actually from the randstruct plugin, not native gcc. I'll go
update the message reporting to include a "randstruct: " which should
make this more obvious.

> This seems to happen for all structures that have a zero offset
> between the member and the container structure, i.e. idential
> pointers.
> Reverting to an intermediate pointer avoids the warning, and using
> a void pointer instead of the target type should also avoid
> regressing on the previous patch again.
> Fixes: mmotm ("kernel.h: handle pointers to arrays better in container_of()")
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>


I'll take this into the kspp tree so all the fixes are in the same place.


Kees Cook
Pixel Security