lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 23 Nov 2020 11:43:03 -0500
From:   Jeff Layton <jlayton@...nel.org>
To:     Luis Henriques <lhenriques@...e.de>,
        Ilya Dryomov <idryomov@...il.com>
Cc:     ceph-devel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH] ceph: add ceph.caps vxattr

On Mon, 2020-11-23 at 14:53 +0000, Luis Henriques wrote:
> Add a new vxattr that allows userspace to list the caps for a specific
> directory or file.
> 
> Signed-off-by: Luis Henriques <lhenriques@...e.de>
> ---
>  fs/ceph/xattr.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
> index 197cb1234341..996512e05513 100644
> --- a/fs/ceph/xattr.c
> +++ b/fs/ceph/xattr.c
> @@ -303,6 +303,18 @@ static ssize_t ceph_vxattrcb_snap_btime(struct ceph_inode_info *ci, char *val,
>  				ci->i_snap_btime.tv_nsec);
>  }
>  
> 
> 
> 
> +static ssize_t ceph_vxattrcb_caps(struct ceph_inode_info *ci, char *val,
> +					size_t size)
> +{
> +	int issued;
> +
> +	spin_lock(&ci->i_ceph_lock);
> +	issued = __ceph_caps_issued(ci, NULL);
> +	spin_unlock(&ci->i_ceph_lock);
> +
> +	return ceph_fmt_xattr(val, size, "%s", ceph_cap_string(issued));
> +}

I wonder if we ought to print a numerical (hex) representation of the
cap set here in addition to the ceph_cap_string. A main use-case for
this will be in testcases, and determining whether (e.g.) Fs is in the
mask may be easier to do with a bitwise AND rather than having to parse
a string of text.

> +
>  #define CEPH_XATTR_NAME(_type, _name)	XATTR_CEPH_PREFIX #_type "." #_name
>  #define CEPH_XATTR_NAME2(_type, _name, _name2)	\
>  	XATTR_CEPH_PREFIX #_type "." #_name "." #_name2
> @@ -378,6 +390,13 @@ static struct ceph_vxattr ceph_dir_vxattrs[] = {
>  		.exists_cb = ceph_vxattrcb_snap_btime_exists,
>  		.flags = VXATTR_FLAG_READONLY,
>  	},
> +	{
> +		.name = "ceph.caps",
> +		.name_size = sizeof("ceph.caps"),
> +		.getxattr_cb = ceph_vxattrcb_caps,
> +		.exists_cb = NULL,
> +		.flags = VXATTR_FLAG_HIDDEN,
> +	},
>  	{ .name = NULL, 0 }	/* Required table terminator */
>  };
>  
> 
> 
> 
> @@ -403,6 +422,13 @@ static struct ceph_vxattr ceph_file_vxattrs[] = {
>  		.exists_cb = ceph_vxattrcb_snap_btime_exists,
>  		.flags = VXATTR_FLAG_READONLY,
>  	},
> +	{
> +		.name = "ceph.caps",
> +		.name_size = sizeof("ceph.caps"),
> +		.getxattr_cb = ceph_vxattrcb_caps,
> +		.exists_cb = NULL,
> +		.flags = VXATTR_FLAG_HIDDEN,
> +	},
>  	{ .name = NULL, 0 }	/* Required table terminator */
>  };
>  
> 
> 
> 

-- 
Jeff Layton <jlayton@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ