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 4/4] blkid: probe_exfat: clamp untrusted label->length to valid size
Date: Thu, 24 Sep 2026 16:02:48 -0500 [thread overview]
Message-ID: <20260924210421.3631790-5-sandeen@redhat.com> (raw)
In-Reply-To: <20260924210421.3631790-1-sandeen@redhat.com>
From: Eric Sandeen <esandeen@redhat.com>
A corrupted or invalid label->length in an exfat filesystem may cause
probing to read past the end of label->name. Limit it in the same manner
as util-linux uses, and add a min() macro here to match.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
lib/blkid/probe.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c
index 87167171..c371acea 100644
--- a/lib/blkid/probe.c
+++ b/lib/blkid/probe.c
@@ -38,6 +38,8 @@
#include "uuid/uuid.h"
#include "probe.h"
+#define min(a, b) ((a) < (b) ? (a) : (b))
+
static int figure_label_len(const unsigned char *label, int len)
{
const unsigned char *end = label + len - 1;
@@ -1535,7 +1537,8 @@ static int probe_exfat(struct blkid_probe *probe,
label = find_exfat_entry_label(probe, sb);
if (label) {
unsigned char utf8_label[128];
- unicode_16le_to_utf8(utf8_label, sizeof(utf8_label), label->name, label->length * 2);
+ unicode_16le_to_utf8(utf8_label, sizeof(utf8_label), label->name,
+ min((size_t) label->length * 2, sizeof(label->name)));
blkid_set_tag(probe->dev, "LABEL", (char *) utf8_label, 0);
} else {
blkid_set_tag(probe->dev, "LABEL", "disk", 4);
--
2.55.0
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 ` [PATCH 2/4] blkid: probe_ntfs: validate on-disk attribute size/length Eric Sandeen
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 ` Eric Sandeen [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=20260924210421.3631790-5-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