From: Andrew Morton <akpm@linux-foundation.org>
To: Ibrahim Hashimov <security@auditcode.ai>
Cc: Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>,
Joseph Qi <joseph.qi@linux.alibaba.com>,
ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] ocfs2: validate rl_used against rl_count in refcount block validator
Date: Fri, 10 Jul 2026 13:33:55 -0700 [thread overview]
Message-ID: <20260710133355.7c0b0d781d148f1262138902@linux-foundation.org> (raw)
In-Reply-To: <20260709132609.44233-1-security@auditcode.ai>
On Thu, 9 Jul 2026 15:26:09 +0200 Ibrahim Hashimov <security@auditcode.ai> wrote:
> ocfs2_find_refcount_rec_in_rl() walks the on-disk refcount record
> array with:
>
> for (; i < le16_to_cpu(rb->rf_records.rl_used); i++) {
> rec = &rb->rf_records.rl_recs[i];
> ...
>
> rl_recs[] lives in a single metadata block (4096 bytes on the common
> configuration), so its real capacity is fixed by
> ocfs2_refcount_recs_per_rb(sb) (247 records for a 4K block with the
> 16-byte ocfs2_refcount_rec). rl_used and rl_count are both read
> directly off disk by ocfs2_validate_refcount_block() and are never
> checked against that capacity, nor against each other, before any
> refcount/reflink/CoW operation walks the array.
>
> A crafted (or corrupted) refcount block with rl_used == 0xffff makes
> the loop above walk far past the end of the block, dereferencing
> rl_recs[i] for i up to 65534. The resulting index is then handed to
> the sibling ocfs2_insert_refcount_rec(), whose insert-shift does:
>
> ...
>
> Add the equivalent pair of checks to ocfs2_validate_refcount_block():
>
Thanks. AI review might have found another bug in there:
https://sashiko.dev/#/patchset/20260709132609.44233-1-security@auditcode.ai
prev parent reply other threads:[~2026-07-10 20:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 13:26 [PATCH] ocfs2: validate rl_used against rl_count in refcount block validator Ibrahim Hashimov
2026-07-10 11:57 ` Joseph Qi
2026-07-10 13:18 ` Joseph Qi
2026-07-10 20:33 ` Andrew Morton [this message]
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=20260710133355.7c0b0d781d148f1262138902@linux-foundation.org \
--to=akpm@linux-foundation.org \
--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=security@auditcode.ai \
--cc=stable@vger.kernel.org \
/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