Skip to content

Commit 7e937bb

Browse files
author
Darrick J. Wong
committed
xfs: warn about inodes with project id of -1
Inodes aren't supposed to have a project id of -1U (aka 4294967295) but the kernel hasn't always validated FSSETXATTR correctly. Flag this as something for the sysadmin to check out. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent eae44cb commit 7e937bb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

fs/xfs/scrub/inode.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ xchk_dinode(
233233
unsigned long long isize;
234234
uint64_t flags2;
235235
uint32_t nextents;
236+
prid_t prid;
236237
uint16_t flags;
237238
uint16_t mode;
238239

@@ -267,6 +268,7 @@ xchk_dinode(
267268
* so just mark this inode for preening.
268269
*/
269270
xchk_ino_set_preen(sc, ino);
271+
prid = 0;
270272
break;
271273
case 2:
272274
case 3:
@@ -279,12 +281,17 @@ xchk_dinode(
279281
if (dip->di_projid_hi != 0 &&
280282
!xfs_has_projid32(mp))
281283
xchk_ino_set_corrupt(sc, ino);
284+
285+
prid = be16_to_cpu(dip->di_projid_lo);
282286
break;
283287
default:
284288
xchk_ino_set_corrupt(sc, ino);
285289
return;
286290
}
287291

292+
if (xfs_has_projid32(mp))
293+
prid |= (prid_t)be16_to_cpu(dip->di_projid_hi) << 16;
294+
288295
/*
289296
* di_uid/di_gid -- -1 isn't invalid, but there's no way that
290297
* userspace could have created that.
@@ -293,6 +300,13 @@ xchk_dinode(
293300
dip->di_gid == cpu_to_be32(-1U))
294301
xchk_ino_set_warning(sc, ino);
295302

303+
/*
304+
* project id of -1 isn't supposed to be valid, but the kernel didn't
305+
* always validate that.
306+
*/
307+
if (prid == -1U)
308+
xchk_ino_set_warning(sc, ino);
309+
296310
/* di_format */
297311
switch (dip->di_format) {
298312
case XFS_DINODE_FMT_DEV:

0 commit comments

Comments
 (0)