diff mbox series

[02/33] xfs: reject invalid flags combinations in XFS_IOC_ATTRMULTI_BY_HANDLE

Message ID 20191212105433.1692-3-hch@lst.de (mailing list archive)
State Superseded
Headers show
Series [01/33] xfs: clear kernel only flags in XFS_IOC_ATTRMULTI_BY_HANDLE | expand

Commit Message

Christoph Hellwig Dec. 12, 2019, 10:54 a.m. UTC
While the flags field in the ABI and the on-disk format allows for
multiple namespace flags, that is a logically invalid combination that
scrub complains about.  Reject it at the ioctl level, as all other
interface already get this right at higher levels.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_ioctl.c   | 5 +++++
 fs/xfs/xfs_ioctl32.c | 5 +++++
 2 files changed, 10 insertions(+)

Comments

Darrick J. Wong Dec. 18, 2019, 9:29 p.m. UTC | #1
On Thu, Dec 12, 2019 at 11:54:02AM +0100, Christoph Hellwig wrote:
> While the flags field in the ABI and the on-disk format allows for
> multiple namespace flags, that is a logically invalid combination that
> scrub complains about.  Reject it at the ioctl level, as all other
> interface already get this right at higher levels.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks ok I think.  We never have attrs in two namespaces at once...
assuming that "attr_multi(3)" is the right manpage for all this?

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

--D

> ---
>  fs/xfs/xfs_ioctl.c   | 5 +++++
>  fs/xfs/xfs_ioctl32.c | 5 +++++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 2f76d0a7b818..f3a53e0db2cf 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -462,6 +462,11 @@ xfs_attrmulti_by_handle(
>  
>  	error = 0;
>  	for (i = 0; i < am_hreq.opcount; i++) {
> +		if ((ops[i].am_flags & ATTR_ROOT) &&
> +		    (ops[i].am_flags & ATTR_SECURE)) {
> +			ops[i].am_error = -EINVAL;
> +			continue;
> +		}
>  		ops[i].am_flags &= ATTR_KERNEL_FLAGS;
>  
>  		ops[i].am_error = strncpy_from_user((char *)attr_name,
> diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
> index 8b5acf8c42e1..720eb72f3be3 100644
> --- a/fs/xfs/xfs_ioctl32.c
> +++ b/fs/xfs/xfs_ioctl32.c
> @@ -450,6 +450,11 @@ xfs_compat_attrmulti_by_handle(
>  
>  	error = 0;
>  	for (i = 0; i < am_hreq.opcount; i++) {
> +		if ((ops[i].am_flags & ATTR_ROOT) &&
> +		    (ops[i].am_flags & ATTR_SECURE)) {
> +			ops[i].am_error = -EINVAL;
> +			continue;
> +		}
>  		ops[i].am_flags &= ATTR_KERNEL_FLAGS;
>  
>  		ops[i].am_error = strncpy_from_user((char *)attr_name,
> -- 
> 2.20.1
>
Christoph Hellwig Dec. 24, 2019, 11:56 a.m. UTC | #2
On Wed, Dec 18, 2019 at 01:29:52PM -0800, Darrick J. Wong wrote:
> On Thu, Dec 12, 2019 at 11:54:02AM +0100, Christoph Hellwig wrote:
> > While the flags field in the ABI and the on-disk format allows for
> > multiple namespace flags, that is a logically invalid combination that
> > scrub complains about.  Reject it at the ioctl level, as all other
> > interface already get this right at higher levels.
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Looks ok I think.  We never have attrs in two namespaces at once...
> assuming that "attr_multi(3)" is the right manpage for all this?

Yes, that is the man page for the interface.
diff mbox series

Patch

diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 2f76d0a7b818..f3a53e0db2cf 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -462,6 +462,11 @@  xfs_attrmulti_by_handle(
 
 	error = 0;
 	for (i = 0; i < am_hreq.opcount; i++) {
+		if ((ops[i].am_flags & ATTR_ROOT) &&
+		    (ops[i].am_flags & ATTR_SECURE)) {
+			ops[i].am_error = -EINVAL;
+			continue;
+		}
 		ops[i].am_flags &= ATTR_KERNEL_FLAGS;
 
 		ops[i].am_error = strncpy_from_user((char *)attr_name,
diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
index 8b5acf8c42e1..720eb72f3be3 100644
--- a/fs/xfs/xfs_ioctl32.c
+++ b/fs/xfs/xfs_ioctl32.c
@@ -450,6 +450,11 @@  xfs_compat_attrmulti_by_handle(
 
 	error = 0;
 	for (i = 0; i < am_hreq.opcount; i++) {
+		if ((ops[i].am_flags & ATTR_ROOT) &&
+		    (ops[i].am_flags & ATTR_SECURE)) {
+			ops[i].am_error = -EINVAL;
+			continue;
+		}
 		ops[i].am_flags &= ATTR_KERNEL_FLAGS;
 
 		ops[i].am_error = strncpy_from_user((char *)attr_name,