mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Siddh Raman Pant <siddh.raman.pant@oracle.com>
To: Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>,
	Joseph Qi <joseph.qi@linux.alibaba.com>,
	Heming Zhao <heming.zhao@suse.com>
Cc: ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
	sashiko-reviews@lists.linux.dev
Subject: [PATCH v2 2/2] ocfs2: reject xattr names at the end of their storage
Date: Fri,  4 Dec 2026 20:56:49 +0530	[thread overview]
Message-ID: <20261204152650.349289-2-siddh.raman.pant@oracle.com> (raw)
In-Reply-To: <20261204152650.349289-1-siddh.raman.pant@oracle.com>

ocfs2_validate_xattr_entries_flat() allows xe_name_offset to equal
region_size when both the name and local value are empty.

When another xattr no longer fits in the block, the empty entry is
copied into a bucket by ocfs2_cp_xattr_block_to_bucket() and the
offset of entry is changed to OCFS2_XATTR_BUCKET_SIZE. On the next
read, ocfs2_validate_xattr_bucket() rejects the entry and makes the
filesystem read-only.

Require name_offset to be less than nv_limit before accepting the
entry. Empty names and values at valid offsets remain allowed.

A Sashiko review of another patch exposed this missing bounds check.

Reported-by: Sashiko AI <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20261204120536.161006-1-siddh.raman.pant@oracle.com?part=1
Fixes: 8914a3330b72 ("ocfs2: validate inline xattrs during inode block validation")
Signed-off-by: Siddh Raman Pant <siddh.raman.pant@oracle.com>
---
 fs/ocfs2/xattr.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 1b013ca43efb..277a63542ad6 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -1123,7 +1123,7 @@ static int ocfs2_validate_xattr_entries_flat(struct super_block *sb, u64 blkno,
 		if (ret)
 			return ret;
 
-		if (name_offset > nv_limit ||
+		if (name_offset >= nv_limit ||
 		    xe->xe_name_len > nv_limit - name_offset)
 			return ocfs2_error(sb,
 					   "Invalid xattr in block %llu: entry %d name is out of bounds\n",
@@ -4802,15 +4802,7 @@ static void ocfs2_xattr_update_xattr_search(struct inode *inode,
 		if (xe->xe_name_len != xi->xi_name_len)
 			continue;
 
-		/**
-		 * An empty local name/value pair takes no space, so
-		 * ocfs2_validate_xattr_entries_flat() allows offsets
-		 * just past the old storage. ocfs2_cp_xattr_block_to_bucket()
-		 * moves the data to the end of the bucket and adjusts each
-		 * offset. The empty pair then points just past the bucket.
-		 * Its name already matches, so don't look up a nonexistent
-		 * buffer.
-		 */
+		/* Empty names already match; no buffer access is needed. */
 		if (xi->xi_name_len) {
 			const char *name;
 
-- 
2.53.0


  reply	other threads:[~2026-12-04 15:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <sashiko-outbox-249784@kernel.org>
2026-12-04 15:26 ` [PATCH v2 1/2] ocfs2: use the bucket accessor when restoring xattr search Siddh Raman Pant
2026-12-04 15:26   ` Siddh Raman Pant [this message]
2026-12-05  8:08 ` [PATCH v3 0/9] Sashiko inspired OCFS2 fixes Siddh Raman Pant
2026-12-05  8:08   ` [PATCH v3 1/9] ocfs2: reject local xattrs with both an empty name and an empty value Siddh Raman Pant
2026-12-05  8:08   ` [PATCH v3 2/9] ocfs2: reject xattr names that overlap the header or entries Siddh Raman Pant
2026-12-05  8:08   ` [PATCH v3 3/9] ocfs2: reject short nonempty external xattr values Siddh Raman Pant
2026-12-05  8:08   ` [PATCH v3 4/9] ocfs2: check the space used by xattr values and value roots Siddh Raman Pant
2026-12-05  8:08   ` [PATCH v3 5/9] ocfs2: reject misaligned xattr name offsets Siddh Raman Pant
2026-12-05  8:08   ` [PATCH v3 6/9] ocfs2: reject overlapping entries in xattr blocks Siddh Raman Pant
2026-12-05  8:08   ` [PATCH v3 7/9] ocfs2: copy all xattr names and values when converting a block Siddh Raman Pant
2026-12-05  8:08   ` [PATCH v3 8/9] ocfs2: exclude holes from the xattr bucket's name/value length Siddh Raman Pant
2026-12-05  8:09   ` [PATCH v3 9/9] ocfs2: use the bucket accessor when restoring xattr search Siddh Raman Pant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261204152650.349289-2-siddh.raman.pant@oracle.com \
    --to=siddh.raman.pant@oracle.com \
    --cc=heming.zhao@suse.com \
    --cc=jlbec@evilplan.org \
    --cc=joseph.qi@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark@fasheh.com \
    --cc=ocfs2-devel@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®