aboutsummaryrefslogtreecommitdiff
path: root/include/linux/compiler-gcc.h
diff options
context:
space:
mode:
authorKees Cook <[email protected]>2022-05-03 13:54:58 -0700
committerKees Cook <[email protected]>2022-05-08 01:32:30 -0700
commit3b5eed3c71a2fb60aa4405ad92a2a6ad2677f220 (patch)
tree9f122f5c493ce4dfde5a4ebe01ecf16783623114 /include/linux/compiler-gcc.h
parente6f3b3c9c109ed57230996cf4a4c1b8ae7e36a81 (diff)
netfs: Eliminate Clang randstruct warning
Clang's structure layout randomization feature gets upset when it sees struct inode (which is randomized) cast to struct netfs_i_context. This is due to seeing the inode pointer as being treated as an array of inodes, rather than "something else, following struct inode". Since netfs can't use container_of() (since it doesn't know what the true containing struct is), it uses this direct offset instead. Adjust the code to better reflect what is happening: an arbitrary pointer is being adjusted and cast to something else: use a "void *" for the math. The resulting binary output is the same, but Clang no longer sees an unexpected cross-structure cast: In file included from ../fs/nfs/inode.c:50: In file included from ../fs/nfs/fscache.h:15: In file included from ../include/linux/fscache.h:18: ../include/linux/netfs.h:298:9: error: casting from randomized structure pointer type 'struct inode *' to 'struct netfs_i_context *' return (struct netfs_i_context *)(inode + 1); ^ 1 error generated. Cc: David Howells <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Jeff Layton <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]
Diffstat (limited to 'include/linux/compiler-gcc.h')
0 files changed, 0 insertions, 0 deletions