From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: Heming Zhao <heming.zhao@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>,
ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] ocfs2: restrict OCFS2_INVALID_SLOT suballoc slot to system inodes
Date: Tue, 1 Sep 2026 09:08:26 +0800 [thread overview]
Message-ID: <fdd373d2-0c70-4a64-b2da-50f2dac194b1@linux.alibaba.com> (raw)
In-Reply-To: <apWJLyCNwqfdiRQb@p15>
On 8/31/26 10:02 PM, Heming Zhao wrote:
> On Mon, Aug 31, 2026 at 02:28:45PM +0800, Joseph Qi wrote:
>> ocfs2_validate_inode_block() currently permits i_suballoc_slot to be
>> OCFS2_INVALID_SLOT for any dinode. Only system inodes created by
>> mkfs.ocfs2 are allocated from the global allocator and thus
>> legitimately carry this value; regular inodes are always allocated
>> from a per-slot suballocator and hence must have a valid slot.
>>
>> If a corrupted regular inode with OCFS2_INVALID_SLOT is accepted,
>> ocfs2_remove_inode() will pass the slot to ocfs2_get_system_file_inode()
>> and get_local_system_inode() will hit BUG_ON(slot == OCFS2_INVALID_SLOT)
>> when the inode is deleted. This can be triggered by an unprivileged
>> user unlinking such a corrupted file.
>>
>> Reject OCFS2_INVALID_SLOT for non-system dinodes during validation,
>> while still accepting it for system inodes.
>>
>> Fixes: fe7a283b3916 ("ocfs2: add suballoc slot check in ocfs2_validate_inode_block()")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
>
> LGTM.
> Reviewed-by: Heming Zhao <heming.zhao@suse.com>
Thanks, sashiko has some review comments, I'll fix them and send v2 later.
Joseph
>> ---
>> fs/ocfs2/inode.c | 19 +++++++++++++++++--
>> 1 file changed, 17 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
>> index 180107a11046..eda50f13ffb5 100644
>> --- a/fs/ocfs2/inode.c
>> +++ b/fs/ocfs2/inode.c
>> @@ -1520,8 +1520,23 @@ int ocfs2_validate_inode_block(struct super_block *sb,
>> goto bail;
>> }
>>
>> - if (le16_to_cpu(di->i_suballoc_slot) != (u16)OCFS2_INVALID_SLOT &&
>> - (u32)le16_to_cpu(di->i_suballoc_slot) > OCFS2_SB(sb)->max_slots - 1) {
>> + /*
>> + * Only system inodes created by mkfs.ocfs2 are allocated from the
>> + * global allocator and thus legitimately carry OCFS2_INVALID_SLOT.
>> + * Regular inodes are always allocated from a per-slot suballocator.
>> + * If a regular inode with OCFS2_INVALID_SLOT was accepted here,
>> + * deleting it would pass the slot to get_local_system_inode() via
>> + * ocfs2_remove_inode() and trigger BUG_ON(slot == OCFS2_INVALID_SLOT).
>> + */
>> + if (le16_to_cpu(di->i_suballoc_slot) == (u16)OCFS2_INVALID_SLOT) {
>> + if (!(le32_to_cpu(di->i_flags) & OCFS2_SYSTEM_FL)) {
>> + rc = ocfs2_error(sb,
>> + "Invalid dinode %llu: suballoc slot %u for non-system inode\n",
>> + (unsigned long long)bh->b_blocknr,
>> + le16_to_cpu(di->i_suballoc_slot));
>> + goto bail;
>> + }
>> + } else if ((u32)le16_to_cpu(di->i_suballoc_slot) > OCFS2_SB(sb)->max_slots - 1) {
>> rc = ocfs2_error(sb, "Invalid dinode %llu: suballoc slot %u\n",
>> (unsigned long long)bh->b_blocknr,
>> le16_to_cpu(di->i_suballoc_slot));
>> --
>> 2.39.3
>>
next prev parent reply other threads:[~2026-09-01 1:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 6:28 [PATCH 0/4] ocfs2: validate suballoc slot and bit of metadata blocks Joseph Qi
2026-08-31 6:28 ` [PATCH 1/4] ocfs2: restrict OCFS2_INVALID_SLOT suballoc slot to system inodes Joseph Qi
2026-08-31 14:02 ` Heming Zhao
2026-09-01 1:08 ` Joseph Qi [this message]
2026-09-01 1:16 ` Heming Zhao
2026-09-01 2:08 ` Joseph Qi
2026-08-31 6:28 ` [PATCH 2/4] ocfs2: validate suballoc bit during inode read Joseph Qi
2026-08-31 14:03 ` Heming Zhao
2026-08-31 6:28 ` [PATCH 3/4] ocfs2: validate suballoc slot of xattr and dir index blocks Joseph Qi
2026-08-31 14:04 ` Heming Zhao
2026-08-31 6:28 ` [PATCH 4/4] ocfs2: validate suballoc slot of extent blocks Joseph Qi
2026-08-31 14:04 ` Heming Zhao
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=fdd373d2-0c70-4a64-b2da-50f2dac194b1@linux.alibaba.com \
--to=joseph.qi@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=heming.zhao@suse.com \
--cc=jlbec@evilplan.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=ocfs2-devel@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®