mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marouane El Moufid <eun0us@espilon.net>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] fs/adfs: bound F+ directory entry name length
Date: Sun, 25 Oct 2026 22:03:57 +0000 (UTC)	[thread overview]
Message-ID: <179296581973.931625.5260582703376775024@espilon.net> (raw)

adfs_fplus_getnext() reads the entry name length (bigdirobnamelen, u32)
from disk and passes it to adfs_dir_copyfrom() as the length to copy into
the fixed 260-byte on-stack obj->name buffer. adfs_dir_copyfrom() bounds
only the source, so a crafted F+ directory entry overflows the stack
(KASAN: stack-out-of-bounds, write; stack-protector panic), reachable
from a mounted crafted ADFS image by a readdir (ls).

Reject an entry whose name does not fit in obj->name, leaving room for
the optional ",xyz" filetype suffix appended by adfs_object_fixup().

Signed-off-by: Marouane El Moufid <eun0us@espilon.net>
---
 fs/adfs/dir_fplus.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/adfs/dir_fplus.c b/fs/adfs/dir_fplus.c
--- a/fs/adfs/dir_fplus.c
+++ b/fs/adfs/dir_fplus.c
@@ -192,6 +192,8 @@
 	obj->indaddr  = le32_to_cpu(bde.bigdirindaddr);
 	obj->attr     = le32_to_cpu(bde.bigdirattr);
 	obj->name_len = le32_to_cpu(bde.bigdirobnamelen);
+	if (obj->name_len > ADFS_MAX_NAME_LEN - 4)
+		return -EINVAL;

 	offset = adfs_fplus_offset(h, le32_to_cpu(h->bigdirentries));
 	offset += le32_to_cpu(bde.bigdirobnameptr);

                 reply	other threads:[~2026-10-25 22:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=179296581973.931625.5260582703376775024@espilon.net \
    --to=eun0us@espilon.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®