Commit f6046319 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong

xfs: lift common checks into xfs_ioc_attr_list

Lift the flags and bufsize checks from both callers into the common code
in xfs_ioc_attr_list.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChandan Rajendra <chandanrlinux@gmail.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 17e1dd83
...@@ -361,6 +361,18 @@ xfs_ioc_attr_list( ...@@ -361,6 +361,18 @@ xfs_ioc_attr_list(
struct xfs_attrlist *alist; struct xfs_attrlist *alist;
int error; int error;
if (bufsize < sizeof(struct xfs_attrlist) ||
bufsize > XFS_XATTR_LIST_MAX)
return -EINVAL;
/*
* Reject flags, only allow namespaces.
*/
if (flags & ~(ATTR_ROOT | ATTR_SECURE))
return -EINVAL;
if (flags == (ATTR_ROOT | ATTR_SECURE))
return -EINVAL;
/* /*
* Validate the cursor. * Validate the cursor.
*/ */
...@@ -415,17 +427,6 @@ xfs_attrlist_by_handle( ...@@ -415,17 +427,6 @@ xfs_attrlist_by_handle(
return -EPERM; return -EPERM;
if (copy_from_user(&al_hreq, arg, sizeof(xfs_fsop_attrlist_handlereq_t))) if (copy_from_user(&al_hreq, arg, sizeof(xfs_fsop_attrlist_handlereq_t)))
return -EFAULT; return -EFAULT;
if (al_hreq.buflen < sizeof(struct xfs_attrlist) ||
al_hreq.buflen > XFS_XATTR_LIST_MAX)
return -EINVAL;
/*
* Reject flags, only allow namespaces.
*/
if (al_hreq.flags & ~(ATTR_ROOT | ATTR_SECURE))
return -EINVAL;
if (al_hreq.flags == (ATTR_ROOT | ATTR_SECURE))
return -EINVAL;
dentry = xfs_handlereq_to_dentry(parfilp, &al_hreq.hreq); dentry = xfs_handlereq_to_dentry(parfilp, &al_hreq.hreq);
if (IS_ERR(dentry)) if (IS_ERR(dentry))
......
...@@ -366,17 +366,6 @@ xfs_compat_attrlist_by_handle( ...@@ -366,17 +366,6 @@ xfs_compat_attrlist_by_handle(
if (copy_from_user(&al_hreq, arg, if (copy_from_user(&al_hreq, arg,
sizeof(compat_xfs_fsop_attrlist_handlereq_t))) sizeof(compat_xfs_fsop_attrlist_handlereq_t)))
return -EFAULT; return -EFAULT;
if (al_hreq.buflen < sizeof(struct xfs_attrlist) ||
al_hreq.buflen > XFS_XATTR_LIST_MAX)
return -EINVAL;
/*
* Reject flags, only allow namespaces.
*/
if (al_hreq.flags & ~(ATTR_ROOT | ATTR_SECURE))
return -EINVAL;
if (al_hreq.flags == (ATTR_ROOT | ATTR_SECURE))
return -EINVAL;
dentry = xfs_compat_handlereq_to_dentry(parfilp, &al_hreq.hreq); dentry = xfs_compat_handlereq_to_dentry(parfilp, &al_hreq.hreq);
if (IS_ERR(dentry)) if (IS_ERR(dentry))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment