mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Lee <david.lee@trailofbits.com>
To: Bob Copeland <me@bobcopeland.com>
Cc: David Lee <david.lee@trailofbits.com>,
	linux-karma-devel@lists.sourceforge.net,
	Dominik 'Disconnect3d' Czarnota
	<dominik.czarnota@trailofbits.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] omfs: avoid overread when printing volume label
Date: Tue, 14 Jul 2026 07:05:22 +0000	[thread overview]
Message-ID: <20260714070524.1699081-1-david.lee@trailofbits.com> (raw)

omfs_fill_super() prints the root-block volume label with %s.  The label is
the on-disk omfs_root_block::r_name field, a fixed OMFS_NAMELEN byte array
that need not contain a terminating NUL byte.

A crafted image can place a non-terminated label at the end of the root
block buffer.  The formatter then scans past the label while mounting the
image, and KASAN reports an out-of-bounds read from the formatting path.

Print the label with a precision capped at OMFS_NAMELEN.  This keeps
formatting from reading beyond the on-disk array.

Signed-off-by: David Lee <david.lee@trailofbits.com>
Assisted-by: Codex:gpt-5.5
---
Trail of Bits has a reproducer for this bug demonstrating Kernel Panic which can be shared further if needed.

 fs/omfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c
index 1d915ef72119..ea51c1bc3eee 100644
--- a/fs/omfs/inode.c
+++ b/fs/omfs/inode.c
@@ -590,7 +590,7 @@ static int omfs_fill_super(struct super_block *sb, struct fs_context *fc)
 		ret = -ENOMEM;
 		goto out_brelse_bh2;
 	}
-	printk(KERN_DEBUG "omfs: Mounted volume %s\n", omfs_rb->r_name);
+	pr_debug("Mounted volume %.*s\n", OMFS_NAMELEN, omfs_rb->r_name);
 
 	ret = 0;
 out_brelse_bh2:
-- 
2.43.0

                 reply	other threads:[~2026-07-14  7:05 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=20260714070524.1699081-1-david.lee@trailofbits.com \
    --to=david.lee@trailofbits.com \
    --cc=dominik.czarnota@trailofbits.com \
    --cc=linux-karma-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@bobcopeland.com \
    /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®