linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@dilger.ca>
To: Mark Salyzyn <salyzyn@android.com>
Cc: Latchesar Ionkov <lucho@ionkov.net>,
	Hugh Dickins <hughd@google.com>,
	Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
	Mike Marshall <hubcap@omnibond.com>,
	James Morris <jmorris@namei.org>,
	devel@lists.orangefs.org, Eric Van Hensbergen <ericvh@gmail.com>,
	Joel Becker <jlbec@evilplan.org>,
	Anna Schumaker <anna.schumaker@netapp.com>,
	Trond Myklebust <trond.myklebust@hammerspace.com>,
	Mathieu Malaterre <malat@debian.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Jan Kara <jack@suse.com>,
	Casey Schaufler <casey@schaufler-ca.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Dave Kleikamp <shaggy@kernel.org>,
	linux-doc@vger.kernel.org, Jeff Layton <jlayton@kernel.org>,
	Mimi Zohar <zohar@linux.ibm.com>,
	CIFS <linux-cifs@vger.kernel.org>,
	Paul Moore <paul@paul-moore.com>,
	"Darrick J . Wong" <darrick.wong@oracle.com>,
	Eric Sandeen <sandeen@sandeen.net>,
	kernel-team@android.com, selinux@vger.kernel.org,
	Brian Foster <bfoster@redhat.com>,
	reiserfs-devel@vger.kernel.org,
	Linux FS-devel Mailing List <linux-fsdevel@vger.kernel.org>,
	Jaegeuk Kim <jaegeuk@kernel.org>, Theodore Ts'o <tytso@mit.edu>,
	Jonathan Corbet <corbet@lwn.net>,
	linux-f2fs-devel@lists.sourceforge.net,
	Benjamin Coddington <bcodding@redhat.com>,
	linux-integrity@vger.kernel.org,
	Martin Brandenburg <martin@omnibond.com>,
	Chris Mason <clm@fb.com>,
	linux-mtd@lists.infradead.org, linux-afs@lists.infradead.org,
	Miklos Szeredi <miklos@szeredi.hu>,
	Ilya Dryomov <idryomov@gmail.com>,
	Ext4 Developers List <linux-ext4@vger.kernel.org>,
	Stephen Smalley <sds@tycho.nsa.gov>,
	Serge Hallyn <serge@hallyn.com>,
	Eric Paris <eparis@parisplace.org>,
	ceph-devel <ceph-devel@vger.kernel.org>,
	Gao Xiang <xiang@kernel.org>,
	linux-nfs <linux-nfs@vger.kernel.org>,
	Joseph Qi <joseph.qi@linux.alibaba.com>,
	samba-technical <samba-technical@lists.samba.org>,
	linux-xfs <linux-xfs@vger.kernel.org>,
	Bob Peterson <rpeterso@redhat.com>, Tejun Heo <tj@kernel.org>,
	linux-erofs@lists.ozlabs.org,
	"David S. Miller" <davem@davemloft.net>,
	ocfs2-devel@oss.oracle.com, jfs-discussion@lists.sourceforge.net,
	Jan Kara <jack@suse.cz>, Eric Biggers <ebiggers@google.com>,
	Dominique Martinet <asmadeus@codewreck.org>,
	overlayfs <linux-unionfs@vger.kernel.org>,
	David Howells <dhowells@redhat.com>,
	linux-mm <linux-mm@kvack.org>,
	Andreas Gruenbacher <agruenba@redhat.com>,
	Sage Weil <sage@redhat.com>, Richard Weinberger <richard@nod.at>,
	Mark Fasheh <mark@fasheh.com>,
	cluster-devel@redhat.com, Steve French <sfrench@samba.org>,
	v9fs-developer@lists.sourceforge.net,
	Bharath Vedartham <linux.bhar@gmail.com>,
	Jann Horn <jannh@google.com>,
	ecryptfs@vger.kernel.org, Josef Bacik <josef@toxicpanda.com>,
	Dave Chinner <dchinner@redhat.com>,
	David Sterba <dsterba@suse.com>,
	Artem Bityutskiy <dedekind1@gmail.com>,
	netdev@vger.kernel.org, Adrian Hunter <adrian.hunter@intel.com>,
	Tyler Hicks <tyhicks@canonical.com>,
	linux-security-module@vger.kernel.org,
	Phillip Lougher <phillip@squashfs.org.uk>,
	David Woodhouse <dwmw2@infradead.org>,
	linux-btrfs <linux-btrfs@vger.kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH v14 1/5] Add flags option to get xattr method paired to __vfs_getxattr
Date: Tue, 22 Oct 2019 16:13:53 -0600	[thread overview]
Message-ID: <8CE5B6E8-DCB7-4F0B-91C1-48030947F585@dilger.ca> (raw)
In-Reply-To: <20191022204453.97058-2-salyzyn@android.com>

[-- Attachment #1: Type: text/plain, Size: 2337 bytes --]


On Oct 22, 2019, at 2:44 PM, Mark Salyzyn <salyzyn@android.com> wrote:
> 
> Replace arguments for get and set xattr methods, and __vfs_getxattr
> and __vfs_setaxtr functions with a reference to the following now
> common argument structure:
> 
> struct xattr_gs_args {
> 	struct dentry *dentry;
> 	struct inode *inode;
> 	const char *name;
> 	union {
> 		void *buffer;
> 		const void *value;
> 	};
> 	size_t size;
> 	int flags;
> };

As part of this change (which is touching all of the uses of these
fields anyway) it would be useful to give these structure fields a
prefix like "xga_" so that they can be easily found with tags.
Otherwise, there are so many different "dentry" and "inode" fields
in various structures that it is hard to find the right one.

> #define __USE_KERNEL_XATTR_DEFS
> 
> -#define XATTR_CREATE	0x1	/* set value, fail if attr already exists */
> -#define XATTR_REPLACE	0x2	/* set value, fail if attr does not exist */
> +#define XATTR_CREATE	 0x1	/* set value, fail if attr already exists */
> +#define XATTR_REPLACE	 0x2	/* set value, fail if attr does not exist */
> +#ifdef __KERNEL__ /* following is kernel internal, colocated for maintenance */
> +#define XATTR_NOSECURITY 0x4	/* get value, do not involve security check */
> +#endif

Now that these arguments are separated out into their own structure,
rather than using "int flags" (there are a million different flags in
the kernel and easily confused) it would be immediately clear *which*
flags are used here with a named enum, like:

enum xattr_flags {
	XATTR_CREATE	= 0x1,	/* set value, fail if attr already exists */
	XATTR_REPLACE	= 0x2,	/* set value, fail if attr does not exist */
#ifdef __KERNEL__ /* following is kernel internal, colocated for maintenance */
	XATTR_NOSECURITY= 0x4,  /* get value, do not involve security check */
#endif
};

and use this in the struct like:

struct xattr_gs_args {
	struct dentry	*xga_dentry;
	struct inode	*xga_inode;
	const char	*xga_name;
	union {
		void		*xga_buffer;
		const void	*xga_value;
	};
	size_t		 xga_size;
	enum xattr_flags xga_flags;
};

Beyond the benefit for the reader to understand the code better, this
can also allow the compiler to warn if incorrect values are being
assigned to this field.

Cheers, Andreas






[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 873 bytes --]

  reply	other threads:[~2019-10-22 22:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20191022204453.97058-1-salyzyn@android.com>
2019-10-22 20:44 ` [PATCH v14 1/5] Add flags option to get xattr method paired to __vfs_getxattr Mark Salyzyn via Linux-erofs
2019-10-22 22:13   ` Andreas Dilger [this message]
2019-10-25  4:39   ` e984eb5108: BUG:kernel_NULL_pointer_dereference,address kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8CE5B6E8-DCB7-4F0B-91C1-48030947F585@dilger.ca \
    --to=adilger@dilger.ca \
    --cc=adrian.hunter@intel.com \
    --cc=agruenba@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=anna.schumaker@netapp.com \
    --cc=asmadeus@codewreck.org \
    --cc=bcodding@redhat.com \
    --cc=bfoster@redhat.com \
    --cc=casey@schaufler-ca.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=clm@fb.com \
    --cc=cluster-devel@redhat.com \
    --cc=corbet@lwn.net \
    --cc=darrick.wong@oracle.com \
    --cc=davem@davemloft.net \
    --cc=dchinner@redhat.com \
    --cc=dedekind1@gmail.com \
    --cc=devel@lists.orangefs.org \
    --cc=dhowells@redhat.com \
    --cc=dsterba@suse.com \
    --cc=dwmw2@infradead.org \
    --cc=ebiggers@google.com \
    --cc=ecryptfs@vger.kernel.org \
    --cc=eparis@parisplace.org \
    --cc=ericvh@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hubcap@omnibond.com \
    --cc=hughd@google.com \
    --cc=idryomov@gmail.com \
    --cc=jack@suse.com \
    --cc=jack@suse.cz \
    --cc=jaegeuk@kernel.org \
    --cc=jannh@google.com \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=jlayton@kernel.org \
    --cc=jlbec@evilplan.org \
    --cc=jmorris@namei.org \
    --cc=josef@toxicpanda.com \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=kernel-team@android.com \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=linux.bhar@gmail.com \
    --cc=lucho@ionkov.net \
    --cc=malat@debian.org \
    --cc=mark@fasheh.com \
    --cc=martin@omnibond.com \
    --cc=mchehab+samsung@kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=netdev@vger.kernel.org \
    --cc=ocfs2-devel@oss.oracle.com \
    --cc=paul@paul-moore.com \
    --cc=phillip@squashfs.org.uk \
    --cc=reiserfs-devel@vger.kernel.org \
    --cc=richard@nod.at \
    --cc=rpeterso@redhat.com \
    --cc=sage@redhat.com \
    --cc=salyzyn@android.com \
    --cc=samba-technical@lists.samba.org \
    --cc=sandeen@sandeen.net \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@vger.kernel.org \
    --cc=serge@hallyn.com \
    --cc=sfrench@samba.org \
    --cc=shaggy@kernel.org \
    --cc=tj@kernel.org \
    --cc=trond.myklebust@hammerspace.com \
    --cc=tyhicks@canonical.com \
    --cc=tytso@mit.edu \
    --cc=v9fs-developer@lists.sourceforge.net \
    --cc=viro@zeniv.linux.org.uk \
    --cc=xiang@kernel.org \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).