fs: move initializing f_mode before file_ref_init()
PATCH 1/1 fs: move initializing f_mode before file_ref_init()
The comment above file_ref_init() says:
"We're SLAB_TYPESAFE_BY_RCU so initialize f_ref last." but file_set_fsnotify_mode() was added after file_ref_init().
Move it right after setting f_mode, where it makes more sense.
--- fs/file_table.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/file_table.c +5 -5
@@ -176,6 +176,11 @@ static int init_file(struct file *f, int flags, const struct cred *cred) f->f_flags = flags; f->f_mode =OPEN_FMODE (flags); +/* +* Disable permission and pre-content events for all files by default. +* They may be enabled later by fsnotify_open_perm_and_set_mode(). +*/ +file_set_fsnotify_mode (f,FMODE_NONOTIFY_PERM ); f->f_op =NULL ; f->f_mapping =NULL ;
@@ -197,11 +202,6 @@ static int init_file(struct file *f, int flags, const struct cred *cred)* refcount bumps we should reinitialize the reused file first. */ file_ref_init (&f->f_ref,1 ); -/* -* Disable permission and pre-content events for all files by default. -* They may be enabled later by fsnotify_open_perm_and_set_mode(). -*/ -file_set_fsnotify_mode (f,FMODE_NONOTIFY_PERM );return 0 ; }
Signature · 1 line
2.52.0
Quoted 8 lines · Amir Goldstein
The comment above
file_ref_init()says:
"We'reSLAB_TYPESAFE_BY_RCUso initializef_reflast." butfile_set_fsnotify_mode()was added afterfile_ref_init().Move it right after setting
f_mode, where it makes more sense.Fixes 711f9b8fbe4f4 ("fsnotify: disable pre-content and permission events by default")Signed-off-by Amir Goldstein <[email protected]>
I agree logically this place makes more sense (although functionally it doesn't really matter). Feel free to add:
Honza
Quoted 35 lines
--- fs/file_table.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)fs/file_table.c +5
-5@@ -176,6 +176,11 @@ static int init_file(struct file *f, int flags, const struct cred *cred) f->f_flags = flags; f->f_mode =OPEN_FMODE (flags); +/* +* Disable permission and pre-content events for all files by default. +* They may be enabled later by fsnotify_open_perm_and_set_mode(). +*/ +file_set_fsnotify_mode (f,FMODE_NONOTIFY_PERM ); f->f_op =NULL ; f->f_mapping =NULL ;@@ -197,11 +202,6 @@ static int init_file(struct file *f, int flags, const struct cred *cred)* refcount bumps we should reinitialize the reused file first. */ file_ref_init (&f->f_ref,1 ); -/* -* Disable permission and pre-content events for all files by default. -* They may be enabled later by fsnotify_open_perm_and_set_mode(). -*/ -file_set_fsnotify_mode (f,FMODE_NONOTIFY_PERM );return 0 ; }Signature · 1 line
2.52.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 8 lines · Amir Goldstein
The comment above
file_ref_init()says:
"We'reSLAB_TYPESAFE_BY_RCUso initializef_reflast." butfile_set_fsnotify_mode()was added afterfile_ref_init().Move it right after setting
f_mode, where it makes more sense.[...]
Applied to the vfs-7.0.misc branch of the vfs/vfs.git tree. Patches in the vfs-7.0.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs-7.0.misc
[1/1] fs: move initializing f_mode before file_ref_init()
https://git.kernel.org/vfs/vfs/c/cb3e4998cb16