Linux filesystem development
 help / color / mirror / Atom feed
* [PATCH] zonefs: handle integer overflow in zonefs_fname_to_fno
@ 2026-04-29 20:58 Johannes Thumshirn
  2026-04-29 22:41 ` Damien Le Moal
  2026-05-11 22:55 ` Damien Le Moal
  0 siblings, 2 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2026-04-29 20:58 UTC (permalink / raw)
  To: Damien Le Moal
  Cc: Naohiro Aota, linux-fsdevel, Alexey Dobriyan, Johannes Thumshirn

In zonefs the file name in one of the two directories corresponds to the
zone number.

Here Alexey reported a possible integer overflow in zonefs_fname_to_fno(),
where the parsing of the zone number from the file name can overflow the
'long' data type.

Add a check for integer overflows and if the fno 'long' did overflow
return -ENOENT.

Reported-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/zonefs/super.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index 9b646cb5335d..c3b497707f82 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -610,11 +610,15 @@ static long zonefs_fname_to_fno(const struct qstr *fname)
 		return c - '0';
 
 	for (i = 0, rname = name + len - 1; i < len; i++, rname--) {
+		long digit;
+
 		c = *rname;
 		if (!isdigit(c))
 			return -ENOENT;
-		fno += (c - '0') * shift;
+		digit = (c - '0') * shift;
 		shift *= 10;
+		if (check_add_overflow(fno, digit, &fno))
+			return -ENOENT;
 	}
 
 	return fno;
-- 
2.53.0


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

end of thread, other threads:[~2026-05-11 22:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-29 20:58 [PATCH] zonefs: handle integer overflow in zonefs_fname_to_fno Johannes Thumshirn
2026-04-29 22:41 ` Damien Le Moal
2026-04-30 11:52   ` Johannes Thumshirn
2026-05-11 22:55 ` Damien Le Moal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox