From: Eric Sandeen <sandeen@redhat.com>
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu, Eric Sandeen <esandeen@redhat.com>,
Eric Sandeen <sandeen@redhat.com>
Subject: [PATCH 2/4] blkid: probe_ntfs: validate on-disk attribute size/length
Date: Thu, 24 Sep 2026 16:02:46 -0500 [thread overview]
Message-ID: <20260924210421.3631790-3-sandeen@redhat.com> (raw)
In-Reply-To: <20260924210421.3631790-1-sandeen@redhat.com>
From: Eric Sandeen <esandeen@redhat.com>
Ensure that the attribute length itself is valid, and that it does not
extend past the mft_record_size, which would result in OOB reads past
the mft buffer.
For tidiness, move attr_off advance to end of the loop.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
lib/blkid/probe.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c
index 31d048db..ae769a77 100644
--- a/lib/blkid/probe.c
+++ b/lib/blkid/probe.c
@@ -751,16 +751,22 @@ static int probe_ntfs(struct blkid_probe *probe,
label_str[0] = 0;
while (1) {
+ /* Don't read past mft_record_size buf on invalid offset */
+ if (attr_off > mft_record_size || sizeof(*attr) > mft_record_size - attr_off)
+ break;
+
attr = (struct file_attribute *) (buf_mft + attr_off);
attr_len = blkid_le32(attr->len);
attr_type = blkid_le32(attr->type);
val_off = blkid_le16(attr->value_offset);
val_len = blkid_le32(attr->value_len);
- attr_off += attr_len;
+ /* Attribute length must be at least as large as header */
+ if (attr_len < sizeof(*attr))
+ break;
- if ((attr_off > mft_record_size) ||
- (attr_len == 0))
+ /* End of this attribute must be within total record size */
+ if (attr_len > mft_record_size - attr_off)
break;
if (attr_type == MFT_RECORD_ATTR_END)
@@ -778,6 +784,8 @@ static int probe_ntfs(struct blkid_probe *probe,
}
*cp = 0;
}
+
+ attr_off += attr_len;
}
sprintf(uuid_str, "%016llX", blkid_le64(ns->volume_serial));
--
2.55.0
next prev parent reply other threads:[~2026-09-24 21:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 21:02 [PATCH 0/4] e2fsprogs: blkid: misc fixes Eric Sandeen
2026-09-24 21:02 ` [PATCH 1/4] blkid: probe_ntfs: fix attr->len endian swap size Eric Sandeen
2026-09-24 21:02 ` Eric Sandeen [this message]
2026-09-24 21:02 ` [PATCH 3/4] blkid: probe_ntfs: validate offset and length of volume name Eric Sandeen
2026-09-24 21:02 ` [PATCH 4/4] blkid: probe_exfat: clamp untrusted label->length to valid size Eric Sandeen
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=20260924210421.3631790-3-sandeen@redhat.com \
--to=sandeen@redhat.com \
--cc=esandeen@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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