mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
zonefs: handle integer overflow in zonefs_fname_to_fno
[ Upstream commit3a8389d42b] 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> Fixes:d207794aba("zonefs: Dynamically create file inodes when needed") Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
9525e3a6fb
commit
eba8af785f
+5
-1
@@ -610,10 +610,14 @@ 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;
|
||||
if (check_add_overflow(fno, digit, &fno))
|
||||
return -ENOENT;
|
||||
shift *= 10;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user