Skip to content

Commit e910c8e

Browse files
arndbkees
authored andcommitted
autofs: use flexible array in ioctl structure
Commit df8fc4e ("kbuild: Enable -fstrict-flex-arrays=3") introduced a warning for the autofs_dev_ioctl structure: In function 'check_name', inlined from 'validate_dev_ioctl' at fs/autofs/dev-ioctl.c:131:9, inlined from '_autofs_dev_ioctl' at fs/autofs/dev-ioctl.c:624:8: fs/autofs/dev-ioctl.c:33:14: error: 'strchr' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread] 33 | if (!strchr(name, '/')) | ^~~~~~~~~~~~~~~~~ In file included from include/linux/auto_dev-ioctl.h:10, from fs/autofs/autofs_i.h:10, from fs/autofs/dev-ioctl.c:14: include/uapi/linux/auto_dev-ioctl.h: In function '_autofs_dev_ioctl': include/uapi/linux/auto_dev-ioctl.h:112:14: note: source object 'path' of size 0 112 | char path[0]; | ^~~~ This is easily fixed by changing the gnu 0-length array into a c99 flexible array. Since this is a uapi structure, we have to be careful about possible regressions but this one should be fine as they are equivalent here. While it would break building with ancient gcc versions that predate c99, it helps building with --std=c99 and -Wpedantic builds in user space, as well as non-gnu compilers. This means we probably also want it fixed in stable kernels. Cc: [email protected] Cc: Kees Cook <[email protected]> Cc: Gustavo A. R. Silva" <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b45861e commit e910c8e

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

Documentation/filesystems/autofs-mount-control.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ information and return operation results::
196196
struct args_ismountpoint ismountpoint;
197197
};
198198

199-
char path[0];
199+
char path[];
200200
};
201201

202202
The ioctlfd field is a mount point file descriptor of an autofs mount

Documentation/filesystems/autofs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ Each ioctl is passed a pointer to an `autofs_dev_ioctl` structure::
467467
struct args_ismountpoint ismountpoint;
468468
};
469469

470-
char path[0];
470+
char path[];
471471
};
472472

473473
For the **OPEN_MOUNT** and **IS_MOUNTPOINT** commands, the target

include/uapi/linux/auto_dev-ioctl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ struct autofs_dev_ioctl {
109109
struct args_ismountpoint ismountpoint;
110110
};
111111

112-
char path[0];
112+
char path[];
113113
};
114114

115115
static inline void init_autofs_dev_ioctl(struct autofs_dev_ioctl *in)

0 commit comments

Comments
 (0)