Skip to contentSkip to conversation

xfs: bulletfproof xfs_qm_scall_trunc_qfiles()

PATCH In review Eric Sandeen 4 participants 4 messages Apr 21, 2014 – Apr 22, 2014 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: bulletfproof xfs_qm_scall_trunc_qfiles()

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.

---

fs/xfs/xfs_qm_syscalls.c +3 -2
index 3daf5ea..17ec2c2 100644
@@ -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);

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Eric Sandeen

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.

Looks good,

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by
#2 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Eric Sandeen

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).

Indeed, my mistake.

Quoted 8 lines
Quoted 4 lines

Should resolve Coverity CID 1163872.

Looks good,

Looks good to me too.

Thanks,
-Jeff

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw
Quoted 11 lines · Jeff Liu
Quoted 7 lines · Christoph Hellwig
Quoted 6 lines · Eric Sandeen

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).

Indeed, my mistake.

No worries, it's a very small thing, and programatically impossible. Not trying to point fingers, just looking for whether it's a new warning or an old one.

Thanks,
-Eric

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs