Message ID | 20190509112420.15671-2-roberto.sassu@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | initramfs: add support for xattrs in the initial ram disk | expand |
On Thu, May 09, 2019 at 01:24:18PM +0200, Roberto Sassu wrote: > Similarly to commit 03450e271a16 ("fs: add ksys_fchmod() and do_fchmodat() > helpers and ksys_chmod() wrapper; remove in-kernel calls to syscall"), this > patch introduces the ksys_lsetxattr() helper to avoid in-kernel calls to > the sys_lsetxattr() syscall. > > Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> [...] > +int ksys_lsetxattr(const char __user *pathname, > + const char __user *name, const void __user *value, > + size_t size, int flags) > +{ > + return path_setxattr(pathname, name, value, size, flags, 0); > +} Instead of exposing ksys_lsetxattr(), wouldn't it be cleaner to use kern_path() and vfs_setxattr(), or something like that? Otherwise you're adding more code that has to cast between kernel and user pointers.
diff --git a/fs/xattr.c b/fs/xattr.c index 0d6a6a4af861..422b3d481edb 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -484,11 +484,18 @@ SYSCALL_DEFINE5(setxattr, const char __user *, pathname, return path_setxattr(pathname, name, value, size, flags, LOOKUP_FOLLOW); } +int ksys_lsetxattr(const char __user *pathname, + const char __user *name, const void __user *value, + size_t size, int flags) +{ + return path_setxattr(pathname, name, value, size, flags, 0); +} + SYSCALL_DEFINE5(lsetxattr, const char __user *, pathname, const char __user *, name, const void __user *, value, size_t, size, int, flags) { - return path_setxattr(pathname, name, value, size, flags, 0); + return ksys_lsetxattr(pathname, name, value, size, flags); } SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name, diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index e446806a561f..b639f13cd1f8 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -1260,6 +1260,9 @@ int ksys_ipc(unsigned int call, int first, unsigned long second, unsigned long third, void __user * ptr, long fifth); int compat_ksys_ipc(u32 call, int first, int second, u32 third, u32 ptr, u32 fifth); +int ksys_lsetxattr(const char __user *pathname, + const char __user *name, const void __user *value, + size_t size, int flags); /* * The following kernel syscall equivalents are just wrappers to fs-internal
Similarly to commit 03450e271a16 ("fs: add ksys_fchmod() and do_fchmodat() helpers and ksys_chmod() wrapper; remove in-kernel calls to syscall"), this patch introduces the ksys_lsetxattr() helper to avoid in-kernel calls to the sys_lsetxattr() syscall. Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> --- fs/xattr.c | 9 ++++++++- include/linux/syscalls.h | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-)