[Top] [All Lists]

[PATCH] xfs: bulletfproof xfs_qm_scall_trunc_qfiles()

To: xfs-oss <xfs@xxxxxxxxxxx>
Subject: [PATCH] xfs: bulletfproof xfs_qm_scall_trunc_qfiles()
From: Eric Sandeen <sandeen@xxxxxxxxxx>
Date: Mon, 21 Apr 2014 15:45:08 -0500
Delivered-to: xfs@xxxxxxxxxxx
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.4.0
Coverity noticed that if we sent junk into
xfs_qm_scall_trunc_qfiles(), we could get back an
uninitialized error value.  So sanitize the flags we
will accept, and initialize error anyway for good measure.

(This bug may have been introduced via c61a9e39).

Should resolve Coverity CID 1163872.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>

diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
index 3daf5ea..17ec2c2 100644
--- a/fs/xfs/xfs_qm_syscalls.c
+++ b/fs/xfs/xfs_qm_syscalls.c
@@ -278,9 +279,10 @@ xfs_qm_scall_trunc_qfiles(
        xfs_mount_t     *mp,
        uint            flags)
-       int             error;
+       int             error = EINVAL;
-       if (!xfs_sb_version_hasquota(&mp->m_sb) || flags == 0) {
+       if (!xfs_sb_version_hasquota(&mp->m_sb) || flags == 0 ||
+           (flags & ~XFS_DQ_ALLTYPES)) {
                xfs_debug(mp, "%s: flags=%x m_qflags=%x",
                        __func__, flags, mp->m_qflags);
                return XFS_ERROR(EINVAL);

<Prev in Thread] Current Thread [Next in Thread>