* [PATCH] xfs: warn about inodes with project id of -1
@ 2022-01-04 23:43 Darrick J. Wong
2022-01-06 1:41 ` Dave Chinner
0 siblings, 1 reply; 2+ messages in thread
From: Darrick J. Wong @ 2022-01-04 23:43 UTC (permalink / raw)
To: xfs
From: Darrick J. Wong <djwong@kernel.org>
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>
---
fs/xfs/scrub/inode.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/fs/xfs/scrub/inode.c b/fs/xfs/scrub/inode.c
index 2405b09d03d0..eac15af7b08c 100644
--- a/fs/xfs/scrub/inode.c
+++ b/fs/xfs/scrub/inode.c
@@ -233,6 +233,7 @@ xchk_dinode(
unsigned long long isize;
uint64_t flags2;
uint32_t nextents;
+ prid_t prid;
uint16_t flags;
uint16_t mode;
@@ -267,6 +268,7 @@ xchk_dinode(
* so just mark this inode for preening.
*/
xchk_ino_set_preen(sc, ino);
+ prid = 0;
break;
case 2:
case 3:
@@ -279,12 +281,17 @@ xchk_dinode(
if (dip->di_projid_hi != 0 &&
!xfs_has_projid32(mp))
xchk_ino_set_corrupt(sc, ino);
+
+ prid = be16_to_cpu(dip->di_projid_lo);
break;
default:
xchk_ino_set_corrupt(sc, ino);
return;
}
+ if (xfs_has_projid32(mp))
+ prid |= (prid_t)be16_to_cpu(dip->di_projid_hi) << 16;
+
/*
* di_uid/di_gid -- -1 isn't invalid, but there's no way that
* userspace could have created that.
@@ -293,6 +300,13 @@ xchk_dinode(
dip->di_gid == cpu_to_be32(-1U))
xchk_ino_set_warning(sc, ino);
+ /*
+ * project id of -1 isn't supposed to be valid, but the kernel didn't
+ * always validate that.
+ */
+ if (prid == -1U)
+ xchk_ino_set_warning(sc, ino);
+
/* di_format */
switch (dip->di_format) {
case XFS_DINODE_FMT_DEV:
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] xfs: warn about inodes with project id of -1
2022-01-04 23:43 [PATCH] xfs: warn about inodes with project id of -1 Darrick J. Wong
@ 2022-01-06 1:41 ` Dave Chinner
0 siblings, 0 replies; 2+ messages in thread
From: Dave Chinner @ 2022-01-06 1:41 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: xfs
On Tue, Jan 04, 2022 at 03:43:25PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> 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>
> ---
> fs/xfs/scrub/inode.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/fs/xfs/scrub/inode.c b/fs/xfs/scrub/inode.c
> index 2405b09d03d0..eac15af7b08c 100644
> --- a/fs/xfs/scrub/inode.c
> +++ b/fs/xfs/scrub/inode.c
> @@ -233,6 +233,7 @@ xchk_dinode(
> unsigned long long isize;
> uint64_t flags2;
> uint32_t nextents;
> + prid_t prid;
> uint16_t flags;
> uint16_t mode;
>
> @@ -267,6 +268,7 @@ xchk_dinode(
> * so just mark this inode for preening.
> */
> xchk_ino_set_preen(sc, ino);
> + prid = 0;
> break;
> case 2:
> case 3:
> @@ -279,12 +281,17 @@ xchk_dinode(
> if (dip->di_projid_hi != 0 &&
> !xfs_has_projid32(mp))
> xchk_ino_set_corrupt(sc, ino);
> +
> + prid = be16_to_cpu(dip->di_projid_lo);
> break;
> default:
> xchk_ino_set_corrupt(sc, ino);
> return;
> }
>
> + if (xfs_has_projid32(mp))
> + prid |= (prid_t)be16_to_cpu(dip->di_projid_hi) << 16;
> +
> /*
> * di_uid/di_gid -- -1 isn't invalid, but there's no way that
> * userspace could have created that.
> @@ -293,6 +300,13 @@ xchk_dinode(
> dip->di_gid == cpu_to_be32(-1U))
> xchk_ino_set_warning(sc, ino);
>
> + /*
> + * project id of -1 isn't supposed to be valid, but the kernel didn't
> + * always validate that.
> + */
> + if (prid == -1U)
> + xchk_ino_set_warning(sc, ino);
> +
> /* di_format */
> switch (dip->di_format) {
> case XFS_DINODE_FMT_DEV:
Looks good.
Reviewed-by: Dave Chinner <dchinner@redhat.com>
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-06 1:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-04 23:43 [PATCH] xfs: warn about inodes with project id of -1 Darrick J. Wong
2022-01-06 1:41 ` Dave Chinner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox