[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190626153542.GE5171@magnolia>
Date: Wed, 26 Jun 2019 08:35:42 -0700
From: "Darrick J. Wong" <darrick.wong@...cle.com>
To: Al Viro <viro@...iv.linux.org.uk>
Cc: matthew.garrett@...ula.com, yuchao0@...wei.com, tytso@....edu,
shaggy@...nel.org, ard.biesheuvel@...aro.org, josef@...icpanda.com,
hch@...radead.org, clm@...com, adilger.kernel@...ger.ca,
jk@...abs.org, jack@...e.com, dsterba@...e.com, jaegeuk@...nel.org,
cluster-devel@...hat.com, jfs-discussion@...ts.sourceforge.net,
linux-efi@...r.kernel.org, Jan Kara <jack@...e.cz>,
reiserfs-devel@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-f2fs-devel@...ts.sourceforge.net, linux-xfs@...r.kernel.org,
linux-nilfs@...r.kernel.org, linux-mtd@...ts.infradead.org,
ocfs2-devel@....oracle.com, linux-fsdevel@...r.kernel.org,
linux-ext4@...r.kernel.org, linux-btrfs@...r.kernel.org
Subject: Re: [PATCH 2/5] vfs: create a generic checking function for
FS_IOC_FSSETXATTR
On Wed, Jun 26, 2019 at 05:11:33AM +0100, Al Viro wrote:
> On Tue, Jun 25, 2019 at 07:32:18PM -0700, Darrick J. Wong wrote:
> > --- a/fs/btrfs/ioctl.c
> > +++ b/fs/btrfs/ioctl.c
> > @@ -373,10 +373,9 @@ static int check_xflags(unsigned int flags)
> > static int btrfs_ioctl_fsgetxattr(struct file *file, void __user *arg)
> > {
> > struct btrfs_inode *binode = BTRFS_I(file_inode(file));
> > - struct fsxattr fa;
> > -
> > - memset(&fa, 0, sizeof(fa));
> > - fa.fsx_xflags = btrfs_inode_flags_to_xflags(binode->flags);
> > + struct fsxattr fa = {
> > + .fsx_xflags = btrfs_inode_flags_to_xflags(binode->flags),
> > + };
>
> Umm... Sure, there's no padding, but still - you are going to copy that thing
> to userland... How about
>
> static inline void simple_fill_fsxattr(struct fsxattr *fa, unsigned xflags)
> {
> memset(fa, 0, sizeof(*fa));
> fa->fsx_xflags = xflags;
> }
>
> and let the compiler optimize the crap out?
The v2 series used to do that, but Christoph complained that having a
helper for a two-line memset and initialization was silly[1] so now we
have this version.
I don't mind reinstating it as a static inline helper, but I'd like some
input from any of the btrfs developers (or you, Al) about which form is
preferred.
--D
[1] https://lkml.org/lkml/2019/6/25/533
Powered by blists - more mailing lists