diff mbox series

xfs: Sanity check flags of Q_XQUOTARM call

Message ID 20191023103719.28117-1-jack@suse.cz (mailing list archive)
State New, archived
Headers show
Series xfs: Sanity check flags of Q_XQUOTARM call | expand

Commit Message

Jan Kara Oct. 23, 2019, 10:37 a.m. UTC
Flags passed to Q_XQUOTARM were not sanity checked for invalid values.
Fix that.

Fixes: 9da93f9b7cdf ("xfs: fix Q_XQUOTARM ioctl")
Reported-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/xfs/xfs_quotaops.c | 3 +++
 1 file changed, 3 insertions(+)

Strictly speaking this may cause user visible regression
(invalid flags are no longer getting ignored) but in this particular
case I think we could get away with it.

Comments

Eric Sandeen Oct. 23, 2019, 1:09 p.m. UTC | #1
On 10/23/19 5:37 AM, Jan Kara wrote:
> Flags passed to Q_XQUOTARM were not sanity checked for invalid values.
> Fix that.
> 
> Fixes: 9da93f9b7cdf ("xfs: fix Q_XQUOTARM ioctl")
> Reported-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> Signed-off-by: Jan Kara <jack@suse.cz>

Whoops, yep good call.

Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Darrick J. Wong Oct. 28, 2019, 4:33 p.m. UTC | #2
On Wed, Oct 23, 2019 at 12:37:19PM +0200, Jan Kara wrote:
> Flags passed to Q_XQUOTARM were not sanity checked for invalid values.
> Fix that.
> 
> Fixes: 9da93f9b7cdf ("xfs: fix Q_XQUOTARM ioctl")
> Reported-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> Signed-off-by: Jan Kara <jack@suse.cz>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/xfs_quotaops.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> Strictly speaking this may cause user visible regression
> (invalid flags are no longer getting ignored) but in this particular
> case I think we could get away with it.
> 
> 
> diff --git a/fs/xfs/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c
> index cd6c7210a373..c7de17deeae6 100644
> --- a/fs/xfs/xfs_quotaops.c
> +++ b/fs/xfs/xfs_quotaops.c
> @@ -201,6 +201,9 @@ xfs_fs_rm_xquota(
>  	if (XFS_IS_QUOTA_ON(mp))
>  		return -EINVAL;
>  
> +	if (uflags & ~(FS_USER_QUOTA | FS_GROUP_QUOTA | FS_PROJ_QUOTA))
> +		return -EINVAL;
> +
>  	if (uflags & FS_USER_QUOTA)
>  		flags |= XFS_DQ_USER;
>  	if (uflags & FS_GROUP_QUOTA)
> -- 
> 2.16.4
>
diff mbox series

Patch

diff --git a/fs/xfs/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c
index cd6c7210a373..c7de17deeae6 100644
--- a/fs/xfs/xfs_quotaops.c
+++ b/fs/xfs/xfs_quotaops.c
@@ -201,6 +201,9 @@  xfs_fs_rm_xquota(
 	if (XFS_IS_QUOTA_ON(mp))
 		return -EINVAL;
 
+	if (uflags & ~(FS_USER_QUOTA | FS_GROUP_QUOTA | FS_PROJ_QUOTA))
+		return -EINVAL;
+
 	if (uflags & FS_USER_QUOTA)
 		flags |= XFS_DQ_USER;
 	if (uflags & FS_GROUP_QUOTA)