Mailing List Archive

[PATCH v3 1/2] fs: rename struct xattr_ctx to kernel_xattr_ctx
From: Christian Göttsche <cgzones@googlemail.com>

Rename the struct xattr_ctx to increase distinction with the about to be
added user API struct xattr_args.

No functional change.

Suggested-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
v3: added based on feedback
---
fs/internal.h | 8 ++++----
fs/xattr.c | 10 +++++-----
io_uring/xattr.c | 2 +-
3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/fs/internal.h b/fs/internal.h
index 7ca738904e34..1caa6a8f666f 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -260,7 +260,7 @@ struct xattr_name {
char name[XATTR_NAME_MAX + 1];
};

-struct xattr_ctx {
+struct kernel_xattr_ctx {
/* Value of attribute */
union {
const void __user *cvalue;
@@ -276,11 +276,11 @@ struct xattr_ctx {

ssize_t do_getxattr(struct mnt_idmap *idmap,
struct dentry *d,
- struct xattr_ctx *ctx);
+ struct kernel_xattr_ctx *ctx);

-int setxattr_copy(const char __user *name, struct xattr_ctx *ctx);
+int setxattr_copy(const char __user *name, struct kernel_xattr_ctx *ctx);
int do_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
- struct xattr_ctx *ctx);
+ struct kernel_xattr_ctx *ctx);
int may_write_xattr(struct mnt_idmap *idmap, struct inode *inode);

#ifdef CONFIG_FS_POSIX_ACL
diff --git a/fs/xattr.c b/fs/xattr.c
index f8b643f91a98..941aab719da0 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -590,7 +590,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
* Extended attribute SET operations
*/

-int setxattr_copy(const char __user *name, struct xattr_ctx *ctx)
+int setxattr_copy(const char __user *name, struct kernel_xattr_ctx *ctx)
{
int error;

@@ -620,7 +620,7 @@ int setxattr_copy(const char __user *name, struct xattr_ctx *ctx)
}

int do_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
- struct xattr_ctx *ctx)
+ struct kernel_xattr_ctx *ctx)
{
if (is_posix_acl_xattr(ctx->kname->name))
return do_set_acl(idmap, dentry, ctx->kname->name,
@@ -636,7 +636,7 @@ setxattr(struct mnt_idmap *idmap, struct dentry *d,
int flags)
{
struct xattr_name kname;
- struct xattr_ctx ctx = {
+ struct kernel_xattr_ctx ctx = {
.cvalue = value,
.kvalue = NULL,
.size = size,
@@ -719,7 +719,7 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
*/
ssize_t
do_getxattr(struct mnt_idmap *idmap, struct dentry *d,
- struct xattr_ctx *ctx)
+ struct kernel_xattr_ctx *ctx)
{
ssize_t error;
char *kname = ctx->kname->name;
@@ -754,7 +754,7 @@ getxattr(struct mnt_idmap *idmap, struct dentry *d,
{
ssize_t error;
struct xattr_name kname;
- struct xattr_ctx ctx = {
+ struct kernel_xattr_ctx ctx = {
.value = value,
.kvalue = NULL,
.size = size,
diff --git a/io_uring/xattr.c b/io_uring/xattr.c
index 44905b82eea8..28b8f7b1af7c 100644
--- a/io_uring/xattr.c
+++ b/io_uring/xattr.c
@@ -18,7 +18,7 @@

struct io_xattr {
struct file *file;
- struct xattr_ctx ctx;
+ struct kernel_xattr_ctx ctx;
struct filename *filename;
};

--
2.43.0
Re: [PATCH v3 1/2] fs: rename struct xattr_ctx to kernel_xattr_ctx [ In reply to ]
On Fri 26-04-24 18:20:15, Christian G?ttsche wrote:
> From: Christian G?ttsche <cgzones@googlemail.com>
>
> Rename the struct xattr_ctx to increase distinction with the about to be
> added user API struct xattr_args.
>
> No functional change.
>
> Suggested-by: Christian Brauner <brauner@kernel.org>
> Signed-off-by: Christian G?ttsche <cgzones@googlemail.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

Honza

> ---
> v3: added based on feedback
> ---
> fs/internal.h | 8 ++++----
> fs/xattr.c | 10 +++++-----
> io_uring/xattr.c | 2 +-
> 3 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/fs/internal.h b/fs/internal.h
> index 7ca738904e34..1caa6a8f666f 100644
> --- a/fs/internal.h
> +++ b/fs/internal.h
> @@ -260,7 +260,7 @@ struct xattr_name {
> char name[XATTR_NAME_MAX + 1];
> };
>
> -struct xattr_ctx {
> +struct kernel_xattr_ctx {
> /* Value of attribute */
> union {
> const void __user *cvalue;
> @@ -276,11 +276,11 @@ struct xattr_ctx {
>
> ssize_t do_getxattr(struct mnt_idmap *idmap,
> struct dentry *d,
> - struct xattr_ctx *ctx);
> + struct kernel_xattr_ctx *ctx);
>
> -int setxattr_copy(const char __user *name, struct xattr_ctx *ctx);
> +int setxattr_copy(const char __user *name, struct kernel_xattr_ctx *ctx);
> int do_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
> - struct xattr_ctx *ctx);
> + struct kernel_xattr_ctx *ctx);
> int may_write_xattr(struct mnt_idmap *idmap, struct inode *inode);
>
> #ifdef CONFIG_FS_POSIX_ACL
> diff --git a/fs/xattr.c b/fs/xattr.c
> index f8b643f91a98..941aab719da0 100644
> --- a/fs/xattr.c
> +++ b/fs/xattr.c
> @@ -590,7 +590,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
> * Extended attribute SET operations
> */
>
> -int setxattr_copy(const char __user *name, struct xattr_ctx *ctx)
> +int setxattr_copy(const char __user *name, struct kernel_xattr_ctx *ctx)
> {
> int error;
>
> @@ -620,7 +620,7 @@ int setxattr_copy(const char __user *name, struct xattr_ctx *ctx)
> }
>
> int do_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
> - struct xattr_ctx *ctx)
> + struct kernel_xattr_ctx *ctx)
> {
> if (is_posix_acl_xattr(ctx->kname->name))
> return do_set_acl(idmap, dentry, ctx->kname->name,
> @@ -636,7 +636,7 @@ setxattr(struct mnt_idmap *idmap, struct dentry *d,
> int flags)
> {
> struct xattr_name kname;
> - struct xattr_ctx ctx = {
> + struct kernel_xattr_ctx ctx = {
> .cvalue = value,
> .kvalue = NULL,
> .size = size,
> @@ -719,7 +719,7 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
> */
> ssize_t
> do_getxattr(struct mnt_idmap *idmap, struct dentry *d,
> - struct xattr_ctx *ctx)
> + struct kernel_xattr_ctx *ctx)
> {
> ssize_t error;
> char *kname = ctx->kname->name;
> @@ -754,7 +754,7 @@ getxattr(struct mnt_idmap *idmap, struct dentry *d,
> {
> ssize_t error;
> struct xattr_name kname;
> - struct xattr_ctx ctx = {
> + struct kernel_xattr_ctx ctx = {
> .value = value,
> .kvalue = NULL,
> .size = size,
> diff --git a/io_uring/xattr.c b/io_uring/xattr.c
> index 44905b82eea8..28b8f7b1af7c 100644
> --- a/io_uring/xattr.c
> +++ b/io_uring/xattr.c
> @@ -18,7 +18,7 @@
>
> struct io_xattr {
> struct file *file;
> - struct xattr_ctx ctx;
> + struct kernel_xattr_ctx ctx;
> struct filename *filename;
> };
>
> --
> 2.43.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
Re: [PATCH v3 1/2] fs: rename struct xattr_ctx to kernel_xattr_ctx [ In reply to ]
On Fri, 26 Apr 2024 18:20:15 +0200, Christian Göttsche wrote:
> Rename the struct xattr_ctx to increase distinction with the about to be
> added user API struct xattr_args.
>
> No functional change.
>
>

So I've picked that series up as this is still a useful addition.
Obviously too late for this merge window.

However, I stated multiple times that we're not going to add *xattrat()
variants that allow to set or get xattrs with AT_EMPTY_PATH on O_PATH
file descriptors. Not just because conceptually setting and getting
xattrs should be treated akin to read/write wrt to O_PATH but also
because it makes the concept of an O_PATH more and more meaningless if
we can do ever more things we it.

But it will also break assumptions of code that would be surprised if an
O_PATH fd suddenly can be used to set and get xattr. So I'll fix it up
so AT_EMPTY_PATH is handled to exclude O_PATH file descriptors.

---

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/2] fs: rename struct xattr_ctx to kernel_xattr_ctx
https://git.kernel.org/vfs/vfs/c/836c8e8bb147
[2/2] fs/xattr: add *at family syscalls
https://git.kernel.org/vfs/vfs/c/71491cbe0205