fs: Fix filename init after recent refactoring
PATCH 1/1 fs: Fix filename init after recent refactoring
getname_flags() should save __user pointer "filename" in filename->uptr. However, this logic is broken by a recent refactoring. Fix it by passing __user pointer filename to helper initname().
--- fs/namei.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/namei.c +4 -4
@@ -125,9 +125,9 @@#define EMBEDDED_NAME_MAX (PATH_MAX - offsetof(struct filename, iname)) -static inline void initname (struct filename *name) +static inline void initname (struct filename *name,const char __user *uptr) { - name->uptr =NULL ; + name->uptr = uptr; name->aname =NULL ;atomic_set (&name->refcnt,1 ); }
@@ -210,7 +210,7 @@ getname_flags(const char __user *filename, int flags)return ERR_PTR (-ENAMETOOLONG ); } } -initname (result); +initname (result, filename);audit_getname (result);return result; }
@@ -268,7 +268,7 @@ struct filename *getname_kernel(const char * filename)return ERR_PTR (-ENAMETOOLONG ); }memcpy ((char *)result->name, filename, len); -initname (result); +initname (result,NULL );audit_getname (result);return result; }
Signature · 1 line
2.47.1
ouch, I'm so sorry :)
Quoted 50 lines · Song Liu
getname_flags()should save__userpointer "filename" infilename->uptr. However, this logic is broken by a recent refactoring. Fix it by passing__userpointer filename to helperinitname().Fixes 611851010c74 ("fs: dedup handling of struct filename init and refcounts bumps")Cc Mateusz Guzik <[email protected]>Cc Christian Brauner <[email protected]>Signed-off-by Song Liu <[email protected]>--- fs/namei.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)fs/namei.c +4
-5@@ -125,9 +125,9 @@#define EMBEDDED_NAME_MAX (PATH_MAX - offsetof(struct filename, iname)) -static inline void initname (struct filename *name) +static inline void initname (struct filename *name,const char __user *uptr) { - name->uptr =NULL ; + name->uptr = uptr; name->aname =NULL ;atomic_set (&name->refcnt,1 ); }@@ -210,7 +210,7 @@ getname_flags(const char __user *filename, int flags)return ERR_PTR (-ENAMETOOLONG ); } } -initname (result); +initname (result, filename);audit_getname (result);return result; }@@ -268,7 +268,7 @@ struct filename *getname_kernel(const char * filename)return ERR_PTR (-ENAMETOOLONG ); }memcpy ((char *)result->name, filename, len); -initname (result); +initname (result,NULL );audit_getname (result);return result; } --2.47.1
Signature · 1 line
Mateusz Guzik <mjguzik gmail.com>
Quoted 5 lines · Song Liu
getname_flags()should save__userpointer "filename" infilename->uptr. However, this logic is broken by a recent refactoring. Fix it by passing__userpointer filename to helperinitname().
Applied to the vfs.fixes branch of the vfs/vfs.git tree. Patches in the vfs.fixes 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.fixes
[1/1] fs: Fix filename init after recent refactoring
https://git.kernel.org/vfs/vfs/c/b463d7fd118b