All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] adfs: reject disc records smaller than one filesystem block
@ 2026-06-05 18:37 Samuel Moelius
  2026-06-10 20:24 ` Kees Cook
  0 siblings, 1 reply; 10+ messages in thread
From: Samuel Moelius @ 2026-06-05 18:37 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Samuel Moelius, Bae Yeonju, Christian Brauner, Kees Cook, Al Viro,
	open list

ADFS uses the on-disk disc size to report statfs block counts.  The disc
record validator checks the sector size, id length, high disc-size bits,
map zone count, and reserved bytes, but it accepts a declared disc size
smaller than one filesystem block.

A crafted one-zone image with log2secsize 9 and disc_size 1 can pass map
checksum validation and mount.  A subsequent statfs then reports zero
f_blocks from adfs_map_statfs(), and adfs_statfs() divides by that zero
while deriving f_ffree.

Reject disc records whose declared disc size is smaller than one
filesystem block.

Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <sam.moelius@trailofbits.com>
---
 fs/adfs/super.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index a4cd0a5159dd..cb8f3919e3bb 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -73,6 +73,10 @@ static int adfs_checkdiscrecord(struct adfs_discrecord *dr)
 	if (le32_to_cpu(dr->disc_size_high) >> dr->log2secsize)
 		return 1;
 
+	/* disc size must contain at least one filesystem block */
+	if (adfs_disc_size(dr) < (1ULL << dr->log2secsize))
+		return 1;
+
 	/*
 	 * Maximum idlen is limited to 16 bits for new directories by
 	 * the three-byte storage of an indirect disc address.  For
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-06-29 12:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-05 18:37 [PATCH] adfs: reject disc records smaller than one filesystem block Samuel Moelius
2026-06-10 20:24 ` Kees Cook
2026-06-28 22:01   ` [PATCH v2 0/2] " Samuel Moelius
2026-06-28 22:01     ` [PATCH v2 1/2] " Samuel Moelius
2026-06-28 23:16       ` Russell King
2026-06-29 11:07         ` Samuel Moelius
2026-06-29 11:34           ` Russell King
2026-06-29 11:45             ` Samuel Moelius
2026-06-29 12:07               ` Russell King
2026-06-28 22:01     ` [PATCH v2 2/2] selftests: filesystems: add ADFS mount validation test Samuel Moelius

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.