From: Dwight Engen <dwight.engen@oracle.com>
To: Dave Chinner <david@fromorbit.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH v4 5/7] xfs: create internal eofblocks structure with kuid_t types
Date: Fri, 19 Jul 2013 11:51:08 -0400 [thread overview]
Message-ID: <20130719115108.6c846a8c@oracle.com> (raw)
In-Reply-To: <20130719054618.GW11674@dastard>
On Fri, 19 Jul 2013 15:46:18 +1000
Dave Chinner <david@fromorbit.com> wrote:
> On Wed, Jul 17, 2013 at 11:47:40AM -0400, Dwight Engen wrote:
> > Have eofblocks ioctl convert uid_t to kuid_t into internal
> > structure. Update internal filter matching to compare ids with
> > kuid_t types.
> >
> > Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
> ....
> >
> > +static inline void
> > +xfs_fs_eofblocks_to_internal(
> > + struct xfs_fs_eofblocks *src,
> > + struct xfs_eofblocks *dst)
>
> I'd prefer that be named xfs_fs_eofblocks_from_user() to make it
> clear that we don't trust the contents of src at all...
Sure, I'll rename it.
> > +{
> > + dst->eof_flags = src->eof_flags;
> > + dst->eof_prid = src->eof_prid;
> > + dst->eof_min_file_size = src->eof_min_file_size;
> > + dst->eof_uid = make_kuid(current_user_ns(), src->eof_uid);
> > + dst->eof_gid = make_kgid(current_user_ns(), src->eof_gid);
> > +}
> > +
> > #endif
> > diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> > index 8edc780..abbbdcf 100644
> > --- a/fs/xfs/xfs_ioctl.c
> > +++ b/fs/xfs/xfs_ioctl.c
> > @@ -1610,7 +1610,8 @@ xfs_file_ioctl(
> > return -error;
> >
> > case XFS_IOC_FREE_EOFBLOCKS: {
> > - struct xfs_eofblocks eofb;
> > + struct xfs_fs_eofblocks eofb;
> > + struct xfs_eofblocks keofb;
> >
> > if (copy_from_user(&eofb, arg, sizeof(eofb)))
> > return -XFS_ERROR(EFAULT);
> > @@ -1625,7 +1626,17 @@ xfs_file_ioctl(
> > memchr_inv(eofb.pad64, 0, sizeof(eofb.pad64)))
> > return -XFS_ERROR(EINVAL);
> >
> > - error = xfs_icache_free_eofblocks(mp, &eofb);
> > + xfs_fs_eofblocks_to_internal(&eofb, &keofb);
> > +
> > + if (keofb.eof_flags & XFS_EOF_FLAGS_UID &&
> > + !uid_valid(keofb.eof_uid))
> > + return XFS_ERROR(EINVAL);
> > +
> > + if (keofb.eof_flags & XFS_EOF_FLAGS_GID &&
> > + !gid_valid(keofb.eof_gid))
> > + return XFS_ERROR(EINVAL);
>
> And I think these two checks should be in
> xfs_fs_eofblocks_from_user(), hence pushing all the conversion and
> validation of the user-supplied parameters into the one function.
>
> Also, we need to return negative errors from this function....
That is the way I originally had it in v3 but Brian had suggested
(http://oss.sgi.com/archives/xfs/2013-06/msg00952.html) it might be
better to move the policy out of the conversion function and put it in
ioctl itself. I agree with you that makes sense to have it all together
so I'm happy to put it back in xfs_fs_eofblocks_from_user().
> > + error = xfs_icache_free_eofblocks(mp, &keofb);
> > return -error;
>
> return -xfs_icache_free_eofblocks(mp, &keofb);
>
> Cheers,
>
> Dave.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2013-07-19 15:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-17 15:47 [PATCH v4 5/7] xfs: create internal eofblocks structure with kuid_t types Dwight Engen
2013-07-19 5:46 ` Dave Chinner
2013-07-19 15:51 ` Dwight Engen [this message]
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=20130719115108.6c846a8c@oracle.com \
--to=dwight.engen@oracle.com \
--cc=david@fromorbit.com \
--cc=xfs@oss.sgi.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