Skip to contentSkip to conversation

xfs: fix inverted clearance of inode junk flags

PATCH Applied Andrey Albershteyn 3 participants 3 messages Jul 22 – Aug 3 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: fix inverted clearance of inode junk flags

sashiko.dev noticed that these checks clear all the valid flags instead of invalid. This probably was never hit as it only executed on invalid flag presence.

Fixes 2d295fe65776 ("xfs: repair inode records")
---
 fs/xfs/scrub/inode_repair.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/xfs/scrub/inode_repair.c +2 -2
index 3ec41c198351..3fc9a12b494a 100644
@@ -1797,7 +1797,7 @@ xrep_inode_flags(
 
 	/* Clear junk flags */
 	if (sc->ip->i_diflags & ~XFS_DIFLAG_ANY)
-		sc->ip->i_diflags &= ~XFS_DIFLAG_ANY;
+		sc->ip->i_diflags &= XFS_DIFLAG_ANY;
 
 	/* NEWRTBM only applies to realtime bitmaps */
 	if (I_INO(sc->ip) == sc->mp->m_sb.sb_rbmino)
@@ -1828,7 +1828,7 @@ xrep_inode_flags(
 
 	/* Clear junk flags. */
 	if (sc->ip->i_diflags2 & ~XFS_DIFLAG2_ANY)
-		sc->ip->i_diflags2 &= ~XFS_DIFLAG2_ANY;
+		sc->ip->i_diflags2 &= XFS_DIFLAG2_ANY;
 
 	/* No reflink flag unless we support it and it's a file. */
 	if (!xfs_has_reflink(sc->mp) || !S_ISREG(mode))
Signature · 1 line
2.54.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Andrey Albershteyn

sashiko.dev noticed that these checks clear all the valid flags instead of invalid. This probably was never hit as it only executed on invalid flag presence.

Fixes 2d295fe65776 ("xfs: repair inode records")

Heh, I have an identical patch in my pending fixes branch. That makes things easy:

--D

Quoted 30 lines
---
 fs/xfs/scrub/inode_repair.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/xfs/scrub/inode_repair.c +2 -2
index 3ec41c198351..3fc9a12b494a 100644
@@ -1797,7 +1797,7 @@ xrep_inode_flags(
 
 	/* Clear junk flags */
 	if (sc->ip->i_diflags & ~XFS_DIFLAG_ANY)
-		sc->ip->i_diflags &= ~XFS_DIFLAG_ANY;
+		sc->ip->i_diflags &= XFS_DIFLAG_ANY;
 
 	/* NEWRTBM only applies to realtime bitmaps */
 	if (I_INO(sc->ip) == sc->mp->m_sb.sb_rbmino)
@@ -1828,7 +1828,7 @@ xrep_inode_flags(
 
 	/* Clear junk flags. */
 	if (sc->ip->i_diflags2 & ~XFS_DIFLAG2_ANY)
-		sc->ip->i_diflags2 &= ~XFS_DIFLAG2_ANY;
+		sc->ip->i_diflags2 &= XFS_DIFLAG2_ANY;
 
 	/* No reflink flag unless we support it and it's a file. */
 	if (!xfs_has_reflink(sc->mp) || !S_ISREG(mode))
Signature · 1 line
2.54.0
maintainer Applied
#2 lore raw
In reply to Andrey Albershteyn
Quoted 5 lines · Andrey Albershteyn

sashiko.dev noticed that these checks clear all the valid flags instead of invalid. This probably was never hit as it only executed on invalid flag presence.

Applied to for-next, thanks!

[1/1] xfs: fix inverted clearance of inode junk flags

      commit: fb082235c67551d526704e07a4efb82ac3a9ba48

Best regards,

Signature · 1 line
Carlos Maiolino <[email protected]>