public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: fix boundary test in xfs_attr_shortform_verify
@ 2020-08-25 20:25 Eric Sandeen
  2020-08-25 20:26 ` Darrick J. Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Eric Sandeen @ 2020-08-25 20:25 UTC (permalink / raw)
  To: linux-xfs

The boundary test for the fixed-offset parts of xfs_attr_sf_entry
in xfs_attr_shortform_verify is off by one.  endp is the address
just past the end of the valid data; to check the last byte of
a structure at offset of size "size" we must subtract one.
(i.e. for an object at offset 10, size 4, last byte is 13 not 14).

This can be shown by:

# touch file
# setfattr -n root.a file

and subsequent verifications will fail when it's reread from disk.

This only matters for a last attribute which has a single-byte name
and no value, otherwise the combination of namelen & valuelen will
push endp out and this test won't fail.

Fixes: 1e1bbd8e7ee06 ("xfs: create structure verifier function for shortform xattrs")
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index 8623c815164a..a0cf22f0c904 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -1037,7 +1037,7 @@ xfs_attr_shortform_verify(
 		 * Check the fixed-offset parts of the structure are
 		 * within the data buffer.
 		 */
-		if (((char *)sfep + sizeof(*sfep)) >= endp)
+		if (((char *)sfep + sizeof(*sfep)-1) >= endp)
 			return __this_address;
 
 		/* Don't allow names with known bad length. */


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-09-01 13:02 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-25 20:25 [PATCH] xfs: fix boundary test in xfs_attr_shortform_verify Eric Sandeen
2020-08-25 20:26 ` Darrick J. Wong
2020-08-25 22:41 ` Dave Chinner
2020-08-26 14:32   ` Eric Sandeen
2020-08-26 15:13     ` Darrick J. Wong
2020-08-26 15:39       ` Eric Sandeen
2020-08-26 15:43         ` Darrick J. Wong
2020-08-27  8:11       ` Christoph Hellwig
2020-08-26 16:19 ` [PATCH V2] " Eric Sandeen
2020-08-26 16:44   ` Darrick J. Wong
2020-08-26 17:07     ` Eric Sandeen
2020-09-01 12:59     ` Pavel Reichl
2020-08-27  8:12   ` Christoph Hellwig
2020-08-27 13:43     ` Eric Sandeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox