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.
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
CC [M] fs/btrfs/super.o
In file included from ./include/linux/bits.h:22,
from ./include/linux/bitops.h:5,
from ./include/linux/kernel.h:12,
from ./arch/x86/include/asm/percpu.h:45,
from ./arch/x86/include/asm/current.h:6,
from ./include/linux/sched.h:12,
from ./include/linux/blkdev.h:5,
from fs/btrfs/super.c:6:
./include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct btrfs_ioctl_dev_replace_start_params) == 2072"
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~~~~~~~~~~~
./include/linux/build_bug.h:77:34: note: in expansion of macro ‘__static_assert’
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ^~~~~~~~~~~~~~~
./include/uapi/linux/btrfs.h:213:1: note: in expansion of macro ‘static_assert’
213 | static_assert(sizeof(struct btrfs_ioctl_dev_replace_start_params) == 2072);
| ^~~~~~~~~~~~~
./include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct btrfs_ioctl_dev_replace_args) == 2600"
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~~~~~~~~~~~
./include/linux/build_bug.h:77:34: note: in expansion of macro ‘__static_assert’
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ^~~~~~~~~~~~~~~
./include/uapi/linux/btrfs.h:248:1: note: in expansion of macro ‘static_assert’
248 | static_assert(sizeof(struct btrfs_ioctl_dev_replace_args) == 2600);
| ^~~~~~~~~~~~~
./include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct btrfs_ioctl_received_subvol_args) == 200"
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~~~~~~~~~~~
./include/linux/build_bug.h:77:34: note: in expansion of macro ‘__static_assert’
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ^~~~~~~~~~~~~~~
./include/uapi/linux/btrfs.h:781:1: note: in expansion of macro ‘static_assert’
781 | static_assert(sizeof(struct btrfs_ioctl_received_subvol_args) == 200);
| ^~~~~~~~~~~~~
./include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct btrfs_ioctl_send_args) == 72"
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~~~~~~~~~~~
./include/linux/build_bug.h:77:34: note: in expansion of macro ‘__static_assert’
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ^~~~~~~~~~~~~~~
./include/uapi/linux/btrfs.h:816:1: note: in expansion of macro ‘static_assert’
816 | static_assert(sizeof(struct btrfs_ioctl_send_args) == 72);
| ^~~~~~~~~~~~~
make[2]: *** [scripts/Makefile.build:281: fs/btrfs/super.o] Error 1
make[1]: *** [scripts/Makefile.build:497: fs/btrfs] Error 2
make: *** [Makefile:1756: fs] Error 2