vfs: renumber FMODE_NONOTIFY and add to uniqueness check
v2 cover vfs: renumber FMODE_NONOTIFY and add to uniqueness check
Changes since v1:
- reword commit to indicate origin of clash [Heinrich Schuchardt]
- remove comment fix [Heinrich Schuchardt]
- acked-by [David S. Miller]
Against v3.18-rc5.
Tested by running fatrace on x86_64, and by cross-compiling against sparc, arm, arm64, m68k, mips, powerpc, alpha, parisc, blackfin.
David Drysdale (1):
vfs: renumber FMODE_NONOTIFY and add to uniqueness check
fs/fcntl.c | 5 +++-- include/linux/fs.h | 2 +- include/uapi/asm-generic/fcntl.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-)
Signature · 1 line
2.1.0.rc2.206.gedb03e5
PATCH v2 1/1 vfs: renumber FMODE_NONOTIFY and add to uniqueness check
Fix clashing values for O_PATH and FMODE_NONOTIFY on sparc. The clashing O_PATH value was added in 5229645bdc35f1cc43eb ("vfs: add nonconflicting values for O_PATH") but this can't be changed as it is user-visible.
FMODE_NONOTIFY is only used internally in the kernel, but it is in the same numbering space as the other O_* flags, as indicated by the comment at the top of include/uapi/asm-generic/fcntl.h (and its use in fs/notify/fanotify/fanotify_user.c). So renumber it to avoid the clash.
All of this has happened before (12ed2e36c98aec6c4155, "fanotify:FMODE_NONOTIFY and __O_SYNC in sparc conflict"), and all of this will happen again -- so update the uniqueness check in fcntl_init() to include __FMODE_NONOTIFY.
--- fs/fcntl.c | 5 +++-- include/linux/fs.h | 2 +- include/uapi/asm-generic/fcntl.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-)
fs/fcntl.c +3 -2
@@ -740,14 +740,15 @@ static int __init fcntl_init(void)* Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY * is defined as O_NONBLOCK on some platforms and not on others. */ -BUILD_BUG_ON (20 -1 /* for O_RDONLY being 0 */ !=HWEIGHT32 ( +BUILD_BUG_ON (21 -1 /* for O_RDONLY being 0 */ !=HWEIGHT32 (O_RDONLY |O_WRONLY |O_RDWR |O_CREAT |O_EXCL |O_NOCTTY |O_TRUNC |O_APPEND |/* O_NONBLOCK | */ __O_SYNC |O_DSYNC |FASYNC |O_DIRECT |O_LARGEFILE |O_DIRECTORY |O_NOFOLLOW |O_NOATIME |O_CLOEXEC | - __FMODE_EXEC |O_PATH | __O_TMPFILE + __FMODE_EXEC |O_PATH | __O_TMPFILE | + __FMODE_NONOTIFY )); fasync_cache = kmem_cache_create("fasync_cache",
include/linux/fs.h +1 -1
@@ -134,7 +134,7 @@ typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset,#define FMODE_CAN_WRITE ((__force fmode_t)0x40000)/* File was opened by fanotify and shouldn't generate fanotify events */ -#define FMODE_NONOTIFY ((__force fmode_t)0x1000000) +#define FMODE_NONOTIFY ((__force fmode_t)0x4000000)/* * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector
include/uapi/asm-generic/fcntl.h +1 -1
@@ -5,7 +5,7 @@/* * FMODE_EXEC is 0x20 -* FMODE_NONOTIFY is 0x1000000 +* FMODE_NONOTIFY is 0x4000000 * These cannot be used by userspace O_* until internal and external open * flags are split. * -Eric Paris
Signature · 1 line
2.1.0.rc2.206.gedb03e5
Quoted 11 lines · David Drysdale
Fix clashing values for
O_PATHandFMODE_NONOTIFYon sparc. The clashingO_PATHvalue was added in5229645bdc35f1cc43eb("vfs: add nonconflicting values forO_PATH") but this can't be changed as it is user-visible.
FMODE_NONOTIFYis only used internally in the kernel, but it is in the same numbering space as the other O_* flags, as indicated by the comment at the top ofinclude/uapi/asm-generic/fcntl.h(and its use infs/notify/fanotify/fanotify_user.c). So renumber it to avoid the clash.
Quoted 7 lines
All of this has happened before (
12ed2e36c98aec6c4155, "fanotify:FMODE_NONOTIFYand__O_SYNCin sparc conflict"), and all of this will happen again -- so update the uniqueness check infcntl_init()to include__FMODE_NONOTIFY.Signed-off-by David Drysdale <[email protected]>Acked-by David S. Miller <[email protected]>
Looks good. You can add:
Honza
Quoted 57 lines
--- fs/fcntl.c | 5 +++-- include/linux/fs.h | 2 +- include/uapi/asm-generic/fcntl.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-)fs/fcntl.c +3
-2@@ -740,14 +740,15 @@ static int __init fcntl_init(void)* Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY * is defined as O_NONBLOCK on some platforms and not on others. */ -BUILD_BUG_ON (20 -1 /* for O_RDONLY being 0 */ !=HWEIGHT32 ( +BUILD_BUG_ON (21 -1 /* for O_RDONLY being 0 */ !=HWEIGHT32 (O_RDONLY |O_WRONLY |O_RDWR |O_CREAT |O_EXCL |O_NOCTTY |O_TRUNC |O_APPEND |/* O_NONBLOCK | */ __O_SYNC |O_DSYNC |FASYNC |O_DIRECT |O_LARGEFILE |O_DIRECTORY |O_NOFOLLOW |O_NOATIME |O_CLOEXEC | - __FMODE_EXEC |O_PATH | __O_TMPFILE + __FMODE_EXEC |O_PATH | __O_TMPFILE | + __FMODE_NONOTIFY )); fasync_cache = kmem_cache_create("fasync_cache",include/linux/fs.h +1
-1@@ -134,7 +134,7 @@ typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset,#define FMODE_CAN_WRITE ((__force fmode_t)0x40000)/* File was opened by fanotify and shouldn't generate fanotify events */ -#define FMODE_NONOTIFY ((__force fmode_t)0x1000000) +#define FMODE_NONOTIFY ((__force fmode_t)0x4000000)/* * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector include/uapi/asm-generic/fcntl.h +1
-1@@ -5,7 +5,7 @@/* * FMODE_EXEC is 0x20 -* FMODE_NONOTIFY is 0x1000000 +* FMODE_NONOTIFY is 0x4000000 * These cannot be used by userspace O_* until internal and external open * flags are split. * -Eric Paris Signature · 1 line
2.1.0.rc2.206.gedb03e5
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Hello Andrew,
could you, please, consider the patch proposed in
https://lkml.org/lkml/2014/11/24/196
for inclusion into the mm-tree.
This 2nd version of the patch considers the review comments in the thread starting at https://lkml.org/lkml/2014/11/21/141.
Best regards
Heinrich Schuchardt
Quoted 81 lines · Jan Kara
Quoted 11 lines · David Drysdale
Fix clashing values for
O_PATHandFMODE_NONOTIFYon sparc. The clashingO_PATHvalue was added in5229645bdc35f1cc43eb("vfs: add nonconflicting values forO_PATH") but this can't be changed as it is user-visible.
FMODE_NONOTIFYis only used internally in the kernel, but it is in the same numbering space as the other O_* flags, as indicated by the comment at the top ofinclude/uapi/asm-generic/fcntl.h(and its use infs/notify/fanotify/fanotify_user.c). So renumber it to avoid the clash.Quoted 7 lines
All of this has happened before (
12ed2e36c98aec6c4155, "fanotify:FMODE_NONOTIFYand__O_SYNCin sparc conflict"), and all of this will happen again -- so update the uniqueness check infcntl_init()to include__FMODE_NONOTIFY.Signed-off-by David Drysdale <[email protected]>Acked-by David S. Miller <[email protected]>Looks good. You can add:
Acked-by Jan Kara <[email protected]>Honza
Quoted 57 lines
--- fs/fcntl.c | 5 +++-- include/linux/fs.h | 2 +- include/uapi/asm-generic/fcntl.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-)fs/fcntl.c +3
-2@@ -740,14 +740,15 @@ static int __init fcntl_init(void)* Exceptions: O_NONBLOCK is a two bit define on parisc; O_NDELAY * is defined as O_NONBLOCK on some platforms and not on others. */ -BUILD_BUG_ON (20 -1 /* for O_RDONLY being 0 */ !=HWEIGHT32 ( +BUILD_BUG_ON (21 -1 /* for O_RDONLY being 0 */ !=HWEIGHT32 (O_RDONLY |O_WRONLY |O_RDWR |O_CREAT |O_EXCL |O_NOCTTY |O_TRUNC |O_APPEND |/* O_NONBLOCK | */ __O_SYNC |O_DSYNC |FASYNC |O_DIRECT |O_LARGEFILE |O_DIRECTORY |O_NOFOLLOW |O_NOATIME |O_CLOEXEC | - __FMODE_EXEC |O_PATH | __O_TMPFILE + __FMODE_EXEC |O_PATH | __O_TMPFILE | + __FMODE_NONOTIFY )); fasync_cache = kmem_cache_create("fasync_cache",include/linux/fs.h +1
-1@@ -134,7 +134,7 @@ typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset,#define FMODE_CAN_WRITE ((__force fmode_t)0x40000)/* File was opened by fanotify and shouldn't generate fanotify events */ -#define FMODE_NONOTIFY ((__force fmode_t)0x1000000) +#define FMODE_NONOTIFY ((__force fmode_t)0x4000000)/* * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector include/uapi/asm-generic/fcntl.h +1
-2@@ -5,7 +5,7 @@/* * FMODE_EXEC is 0x20 -* FMODE_NONOTIFY is 0x1000000 +* FMODE_NONOTIFY is 0x4000000 * These cannot be used by userspace O_* until internal and external open * flags are split. * -Eric Paris -- 2.1.0.rc2.206.gedb03e5
Quoted 11 lines · On Mon, 24 Nov 2014 11:23:19 +0000 David Drysdale <[email protected]> wrote:
Fix clashing values for
O_PATHandFMODE_NONOTIFYon sparc. The clashingO_PATHvalue was added in5229645bdc35f1cc43eb("vfs: add nonconflicting values forO_PATH") but this can't be changed as it is user-visible.
FMODE_NONOTIFYis only used internally in the kernel, but it is in the same numbering space as the other O_* flags, as indicated by the comment at the top ofinclude/uapi/asm-generic/fcntl.h(and its use infs/notify/fanotify/fanotify_user.c). So renumber it to avoid the clash.
Quoted 4 lines
All of this has happened before (
12ed2e36c98aec6c4155, "fanotify:FMODE_NONOTIFYand__O_SYNCin sparc conflict"), and all of this will happen again -- so update the uniqueness check infcntl_init()to include__FMODE_NONOTIFY.
What are the user-visible runtime effects of the bug?
Please always include this info when fixing bugs, so people can work out which kernel version(s) need the fix.
Quoted 18 lines · Andrew Morton
Quoted 11 lines · On Mon, 24 Nov 2014 11:23:19 +0000 David Drysdale <[email protected]> wrote:
Fix clashing values for
O_PATHandFMODE_NONOTIFYon sparc. The clashingO_PATHvalue was added in5229645bdc35f1cc43eb("vfs: add nonconflicting values forO_PATH") but this can't be changed as it is user-visible.
FMODE_NONOTIFYis only used internally in the kernel, but it is in the same numbering space as the other O_* flags, as indicated by the comment at the top ofinclude/uapi/asm-generic/fcntl.h(and its use infs/notify/fanotify/fanotify_user.c). So renumber it to avoid the clash.Quoted 4 lines
All of this has happened before (
12ed2e36c98aec6c4155, "fanotify:FMODE_NONOTIFYand__O_SYNCin sparc conflict"), and all of this will happen again -- so update the uniqueness check infcntl_init()to include__FMODE_NONOTIFY.
Quoted 4 lines
What are the user-visible runtime effects of the bug?
Please always include this info when fixing bugs, so people can work out which kernel version(s) need the fix.
I don't know for sure what the user-visible effects are -- I noticed the problem from the source and I don't have a sparc system (the only affected architecture) to test with. But I'd guess that...
The likely user-visible effect (on sparc) of the clash would be that:
- Filesystem activity on files opened with O_PATH does not get reported via the fanotify(7) API.
- The file descriptors for accessed objects reported via the fanotify(7) API will effectively have O_PATH set, and so will have the limitations described for O_PATH in the open(2) manpage.
However, we'd need some intersection of sparc/fanotify folk to verify those guesses -- Eric / David, any thoughts?
Thanks,
David