Skip to contentSkip to conversation

e2fsck: fix precedence bug in built-in quota support

PATCH In review Theodore Ts'o 2 participants 2 messages May 22, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 e2fsck: fix precedence bug in built-in quota support

The operator precedence bug means that we might pay atteion to s_grp_quota_inum even if the RO_COMPAT_QUOTA feature flag is clear. However, fortunately, this is unlikely to happen in practice.

---
 e2fsck/pass1.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
e2fsck/pass1.c +2 -2
index c7645d1..c6aae6e 100644
@@ -928,8 +928,8 @@ void e2fsck_pass1(e2fsck_t ctx)
 			ext2fs_mark_inode_bitmap2(ctx->inode_used_map, ino);
 			if ((fs->super->s_feature_ro_compat &
 					EXT4_FEATURE_RO_COMPAT_QUOTA) &&
-			    (fs->super->s_usr_quota_inum == ino) ||
-			    (fs->super->s_grp_quota_inum == ino)) {
+			    ((fs->super->s_usr_quota_inum == ino) ||
+			     (fs->super->s_grp_quota_inum == ino))) {
 				if (!LINUX_S_ISREG(inode->i_mode) &&
 				    fix_problem(ctx, PR_1_QUOTA_BAD_MODE,
 							&pctx)) {
Signature · 1 line
1.7.10.rc3
Reviewed-by on v1 1/1
#1 lore raw

Oops. Thanks for the patch.

Quoted 6 lines · Theodore Ts'o

The operator precedence bug means that we might pay atteion to s_grp_quota_inum even if the RO_COMPAT_QUOTA feature flag is clear. However, fortunately, this is unlikely to happen in practice.

Quoted 22 lines

---
 e2fsck/pass1.c |    4 ++--

 1 file changed, 2 insertions(+), 2 deletions(-)
e2fsck/pass1.c +0 -0
index c7645d1..c6aae6e 100644
@@ -928,8 +928,8 @@ void e2fsck_pass1(e2fsck_t ctx)
                        ext2fs_mark_inode_bitmap2(ctx->inode_used_map, ino);

                       if ((fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_QUOTA) &&
-                           (fs->super->s_usr_quota_inum == ino) ||
-                           (fs->super->s_grp_quota_inum == ino)) {
+                           ((fs->super->s_usr_quota_inum == ino) ||
+                            (fs->super->s_grp_quota_inum == ino))) { if (!LINUX_S_ISREG(inode->i_mode) && fix_problem(ctx, PR_1_QUOTA_BAD_MODE, &pctx)) { --
1.7.10.rc3

Signature · 1 line
Aditya