All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs/xattr: unify *at syscalls
@ 2024-04-30 15:19 Christian Göttsche
  2024-05-02 10:37 ` Jan Kara
  2024-05-02 13:02 ` Christian Brauner
  0 siblings, 2 replies; 4+ messages in thread
From: Christian Göttsche @ 2024-04-30 15:19 UTC (permalink / raw
  To: brauner
  Cc: Christian Göttsche, Jan Kara, Alexander Viro, Jan Kara,
	Arnd Bergmann, Thomas Gleixner, Kees Cook, Geert Uytterhoeven,
	Casey Schaufler, peterz@infradead.org, Sohil Mehta,
	Miklos Szeredi, Mark Rutland, linux-fsdevel, linux-kernel,
	linux-api

From: Christian Göttsche <cgzones@googlemail.com>

Use the same parameter ordering for all four newly added *xattrat
syscalls:

    dirfd, pathname, at_flags, ...

Also consistently use unsigned int as the type for at_flags.

Suggested-by: Jan Kara <jack@suse.com>
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 fs/xattr.c               | 36 +++++++++++++++++++-----------------
 include/linux/syscalls.h |  8 +++++---
 2 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/fs/xattr.c b/fs/xattr.c
index 45603e74c632..454304046d7d 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -931,17 +931,18 @@ listxattr(struct dentry *d, char __user *list, size_t size)
 	return error;
 }
 
-static ssize_t do_listxattrat(int dfd, const char __user *pathname, char __user *list,
-			      size_t size, int flags)
+static ssize_t do_listxattrat(int dfd, const char __user *pathname,
+			      unsigned int at_flags,
+			      char __user *list, size_t size)
 {
 	struct path path;
 	ssize_t error = 0;
 	int lookup_flags;
 
-	if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) != 0)
+	if ((at_flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) != 0)
 		return -EINVAL;
 
-	if (flags & AT_EMPTY_PATH && vfs_empty_path(dfd, pathname)) {
+	if (at_flags & AT_EMPTY_PATH && vfs_empty_path(dfd, pathname)) {
 		CLASS(fd, f)(dfd);
 
 		if (!f.file)
@@ -965,22 +966,23 @@ static ssize_t do_listxattrat(int dfd, const char __user *pathname, char __user
 	return error;
 }
 
-SYSCALL_DEFINE5(listxattrat, int, dfd, const char __user *, pathname, char __user *, list,
-		size_t, size, int, flags)
+SYSCALL_DEFINE5(listxattrat, int, dfd, const char __user *, pathname,
+		unsigned int, at_flags,
+		char __user *, list, size_t, size)
 {
-	return do_listxattrat(dfd, pathname, list, size, flags);
+	return do_listxattrat(dfd, pathname, at_flags, list, size);
 }
 
 SYSCALL_DEFINE3(listxattr, const char __user *, pathname, char __user *, list,
 		size_t, size)
 {
-	return do_listxattrat(AT_FDCWD, pathname, list, size, 0);
+	return do_listxattrat(AT_FDCWD, pathname, 0, list, size);
 }
 
 SYSCALL_DEFINE3(llistxattr, const char __user *, pathname, char __user *, list,
 		size_t, size)
 {
-	return do_listxattrat(AT_FDCWD, pathname, list, size, AT_SYMLINK_NOFOLLOW);
+	return do_listxattrat(AT_FDCWD, pathname, AT_SYMLINK_NOFOLLOW, list, size);
 }
 
 SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
@@ -1019,17 +1021,17 @@ removexattr(struct mnt_idmap *idmap, struct dentry *d,
 }
 
 static int do_removexattrat(int dfd, const char __user *pathname,
-			    const char __user *name, int flags)
+			    unsigned int at_flags, const char __user *name)
 {
 	struct path path;
 	int error;
 	int lookup_flags;
 
-	if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) != 0)
+	if ((at_flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) != 0)
 		return -EINVAL;
 
-	lookup_flags = (flags & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
-	if (flags & AT_EMPTY_PATH)
+	lookup_flags = (at_flags & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
+	if (at_flags & AT_EMPTY_PATH)
 		lookup_flags |= LOOKUP_EMPTY;
 retry:
 	error = user_path_at(dfd, pathname, lookup_flags, &path);
@@ -1049,21 +1051,21 @@ static int do_removexattrat(int dfd, const char __user *pathname,
 }
 
 SYSCALL_DEFINE4(removexattrat, int, dfd, const char __user *, pathname,
-		const char __user *, name, int, flags)
+		unsigned int, at_flags, const char __user *, name)
 {
-	return do_removexattrat(dfd, pathname, name, flags);
+	return do_removexattrat(dfd, pathname, at_flags, name);
 }
 
 SYSCALL_DEFINE2(removexattr, const char __user *, pathname,
 		const char __user *, name)
 {
-	return do_removexattrat(AT_FDCWD, pathname, name, 0);
+	return do_removexattrat(AT_FDCWD, pathname, 0, name);
 }
 
 SYSCALL_DEFINE2(lremovexattr, const char __user *, pathname,
 		const char __user *, name)
 {
-	return do_removexattrat(AT_FDCWD, pathname, name, AT_SYMLINK_NOFOLLOW);
+	return do_removexattrat(AT_FDCWD, pathname, AT_SYMLINK_NOFOLLOW, name);
 }
 
 SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index e06fffc48535..ca3cba698602 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -356,15 +356,17 @@ asmlinkage long sys_fgetxattr(int fd, const char __user *name,
 			      void __user *value, size_t size);
 asmlinkage long sys_listxattr(const char __user *path, char __user *list,
 			      size_t size);
-asmlinkage long sys_listxattrat(int dfd, const char __user *path, char __user *list,
-			      size_t size, int flags);
+asmlinkage long sys_listxattrat(int dfd, const char __user *path,
+				unsigned int at_flags,
+				char __user *list, size_t size);
 asmlinkage long sys_llistxattr(const char __user *path, char __user *list,
 			       size_t size);
 asmlinkage long sys_flistxattr(int fd, char __user *list, size_t size);
 asmlinkage long sys_removexattr(const char __user *path,
 				const char __user *name);
 asmlinkage long sys_removexattrat(int dfd, const char __user *path,
-				const char __user *name, int flags);
+				  unsigned int at_flags,
+				  const char __user *name);
 asmlinkage long sys_lremovexattr(const char __user *path,
 				 const char __user *name);
 asmlinkage long sys_fremovexattr(int fd, const char __user *name);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] fs/xattr: unify *at syscalls
  2024-04-30 15:19 [PATCH] fs/xattr: unify *at syscalls Christian Göttsche
@ 2024-05-02 10:37 ` Jan Kara
  2024-05-02 13:04   ` Christian Brauner
  2024-05-02 13:02 ` Christian Brauner
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Kara @ 2024-05-02 10:37 UTC (permalink / raw
  To: cgzones
  Cc: brauner, Jan Kara, Alexander Viro, Jan Kara, Arnd Bergmann,
	Thomas Gleixner, Kees Cook, Geert Uytterhoeven, Casey Schaufler,
	peterz@infradead.org, Sohil Mehta, Miklos Szeredi, Mark Rutland,
	linux-fsdevel, linux-kernel, linux-api

On Tue 30-04-24 17:19:14, Christian Göttsche wrote:
> From: Christian Göttsche <cgzones@googlemail.com>
> 
> Use the same parameter ordering for all four newly added *xattrat
> syscalls:
> 
>     dirfd, pathname, at_flags, ...
> 
> Also consistently use unsigned int as the type for at_flags.
> 
> Suggested-by: Jan Kara <jack@suse.com>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>

Thanks! The change looks good to me. Christian, do you plan to fold this
into the series you've taken to your tree?

								Honza

> ---
>  fs/xattr.c               | 36 +++++++++++++++++++-----------------
>  include/linux/syscalls.h |  8 +++++---
>  2 files changed, 24 insertions(+), 20 deletions(-)
> 
> diff --git a/fs/xattr.c b/fs/xattr.c
> index 45603e74c632..454304046d7d 100644
> --- a/fs/xattr.c
> +++ b/fs/xattr.c
> @@ -931,17 +931,18 @@ listxattr(struct dentry *d, char __user *list, size_t size)
>  	return error;
>  }
>  
> -static ssize_t do_listxattrat(int dfd, const char __user *pathname, char __user *list,
> -			      size_t size, int flags)
> +static ssize_t do_listxattrat(int dfd, const char __user *pathname,
> +			      unsigned int at_flags,
> +			      char __user *list, size_t size)
>  {
>  	struct path path;
>  	ssize_t error = 0;
>  	int lookup_flags;
>  
> -	if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) != 0)
> +	if ((at_flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) != 0)
>  		return -EINVAL;
>  
> -	if (flags & AT_EMPTY_PATH && vfs_empty_path(dfd, pathname)) {
> +	if (at_flags & AT_EMPTY_PATH && vfs_empty_path(dfd, pathname)) {
>  		CLASS(fd, f)(dfd);
>  
>  		if (!f.file)
> @@ -965,22 +966,23 @@ static ssize_t do_listxattrat(int dfd, const char __user *pathname, char __user
>  	return error;
>  }
>  
> -SYSCALL_DEFINE5(listxattrat, int, dfd, const char __user *, pathname, char __user *, list,
> -		size_t, size, int, flags)
> +SYSCALL_DEFINE5(listxattrat, int, dfd, const char __user *, pathname,
> +		unsigned int, at_flags,
> +		char __user *, list, size_t, size)
>  {
> -	return do_listxattrat(dfd, pathname, list, size, flags);
> +	return do_listxattrat(dfd, pathname, at_flags, list, size);
>  }
>  
>  SYSCALL_DEFINE3(listxattr, const char __user *, pathname, char __user *, list,
>  		size_t, size)
>  {
> -	return do_listxattrat(AT_FDCWD, pathname, list, size, 0);
> +	return do_listxattrat(AT_FDCWD, pathname, 0, list, size);
>  }
>  
>  SYSCALL_DEFINE3(llistxattr, const char __user *, pathname, char __user *, list,
>  		size_t, size)
>  {
> -	return do_listxattrat(AT_FDCWD, pathname, list, size, AT_SYMLINK_NOFOLLOW);
> +	return do_listxattrat(AT_FDCWD, pathname, AT_SYMLINK_NOFOLLOW, list, size);
>  }
>  
>  SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
> @@ -1019,17 +1021,17 @@ removexattr(struct mnt_idmap *idmap, struct dentry *d,
>  }
>  
>  static int do_removexattrat(int dfd, const char __user *pathname,
> -			    const char __user *name, int flags)
> +			    unsigned int at_flags, const char __user *name)
>  {
>  	struct path path;
>  	int error;
>  	int lookup_flags;
>  
> -	if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) != 0)
> +	if ((at_flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) != 0)
>  		return -EINVAL;
>  
> -	lookup_flags = (flags & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
> -	if (flags & AT_EMPTY_PATH)
> +	lookup_flags = (at_flags & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW;
> +	if (at_flags & AT_EMPTY_PATH)
>  		lookup_flags |= LOOKUP_EMPTY;
>  retry:
>  	error = user_path_at(dfd, pathname, lookup_flags, &path);
> @@ -1049,21 +1051,21 @@ static int do_removexattrat(int dfd, const char __user *pathname,
>  }
>  
>  SYSCALL_DEFINE4(removexattrat, int, dfd, const char __user *, pathname,
> -		const char __user *, name, int, flags)
> +		unsigned int, at_flags, const char __user *, name)
>  {
> -	return do_removexattrat(dfd, pathname, name, flags);
> +	return do_removexattrat(dfd, pathname, at_flags, name);
>  }
>  
>  SYSCALL_DEFINE2(removexattr, const char __user *, pathname,
>  		const char __user *, name)
>  {
> -	return do_removexattrat(AT_FDCWD, pathname, name, 0);
> +	return do_removexattrat(AT_FDCWD, pathname, 0, name);
>  }
>  
>  SYSCALL_DEFINE2(lremovexattr, const char __user *, pathname,
>  		const char __user *, name)
>  {
> -	return do_removexattrat(AT_FDCWD, pathname, name, AT_SYMLINK_NOFOLLOW);
> +	return do_removexattrat(AT_FDCWD, pathname, AT_SYMLINK_NOFOLLOW, name);
>  }
>  
>  SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
> diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
> index e06fffc48535..ca3cba698602 100644
> --- a/include/linux/syscalls.h
> +++ b/include/linux/syscalls.h
> @@ -356,15 +356,17 @@ asmlinkage long sys_fgetxattr(int fd, const char __user *name,
>  			      void __user *value, size_t size);
>  asmlinkage long sys_listxattr(const char __user *path, char __user *list,
>  			      size_t size);
> -asmlinkage long sys_listxattrat(int dfd, const char __user *path, char __user *list,
> -			      size_t size, int flags);
> +asmlinkage long sys_listxattrat(int dfd, const char __user *path,
> +				unsigned int at_flags,
> +				char __user *list, size_t size);
>  asmlinkage long sys_llistxattr(const char __user *path, char __user *list,
>  			       size_t size);
>  asmlinkage long sys_flistxattr(int fd, char __user *list, size_t size);
>  asmlinkage long sys_removexattr(const char __user *path,
>  				const char __user *name);
>  asmlinkage long sys_removexattrat(int dfd, const char __user *path,
> -				const char __user *name, int flags);
> +				  unsigned int at_flags,
> +				  const char __user *name);
>  asmlinkage long sys_lremovexattr(const char __user *path,
>  				 const char __user *name);
>  asmlinkage long sys_fremovexattr(int fd, const char __user *name);
> -- 
> 2.43.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fs/xattr: unify *at syscalls
  2024-04-30 15:19 [PATCH] fs/xattr: unify *at syscalls Christian Göttsche
  2024-05-02 10:37 ` Jan Kara
@ 2024-05-02 13:02 ` Christian Brauner
  1 sibling, 0 replies; 4+ messages in thread
From: Christian Brauner @ 2024-05-02 13:02 UTC (permalink / raw
  To: Christian Goettsche
  Cc: Christian Brauner, Christian Goettsche, Jan Kara, Alexander Viro,
	Jan Kara, Arnd Bergmann, Thomas Gleixner, Kees Cook,
	Geert Uytterhoeven, Casey Schaufler, peterz, Sohil Mehta,
	Miklos Szeredi, Mark Rutland, linux-fsdevel, linux-kernel,
	linux-api

On Tue, 30 Apr 2024 17:19:14 +0200, Christian Göttsche wrote:
> Use the same parameter ordering for all four newly added *xattrat
> syscalls:
> 
>     dirfd, pathname, at_flags, ...
> 
> Also consistently use unsigned int as the type for at_flags.
> 
> [...]

Applied to the vfs.xattr branch of the vfs/vfs.git tree.
Patches in the vfs.xattr 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.xattr

[1/1] fs/xattr: unify *at syscalls
      https://git.kernel.org/vfs/vfs/c/1d5e73c8c531

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fs/xattr: unify *at syscalls
  2024-05-02 10:37 ` Jan Kara
@ 2024-05-02 13:04   ` Christian Brauner
  0 siblings, 0 replies; 4+ messages in thread
From: Christian Brauner @ 2024-05-02 13:04 UTC (permalink / raw
  To: Jan Kara
  Cc: cgzones, Jan Kara, Alexander Viro, Arnd Bergmann, Thomas Gleixner,
	Kees Cook, Geert Uytterhoeven, Casey Schaufler,
	peterz@infradead.org, Sohil Mehta, Miklos Szeredi, Mark Rutland,
	linux-fsdevel, linux-kernel, linux-api

On Thu, May 02, 2024 at 12:37:16PM +0200, Jan Kara wrote:
> On Tue 30-04-24 17:19:14, Christian Göttsche wrote:
> > From: Christian Göttsche <cgzones@googlemail.com>
> > 
> > Use the same parameter ordering for all four newly added *xattrat
> > syscalls:
> > 
> >     dirfd, pathname, at_flags, ...
> > 
> > Also consistently use unsigned int as the type for at_flags.
> > 
> > Suggested-by: Jan Kara <jack@suse.com>
> > Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
> 
> Thanks! The change looks good to me. Christian, do you plan to fold this
> into the series you've taken to your tree?

Yep, that's the plan.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-02 13:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-30 15:19 [PATCH] fs/xattr: unify *at syscalls Christian Göttsche
2024-05-02 10:37 ` Jan Kara
2024-05-02 13:04   ` Christian Brauner
2024-05-02 13:02 ` Christian Brauner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.