fs: fat: Perform sanity checks on getsize in get_fatent()
PATCH 1/1 fs: fat: Perform sanity checks on getsize in get_fatent()
We do not perform a check on the value of getsize in get_fatent to ensure that it will fit within the allocated buffer. For safety sake, add a check now and if the value exceeds FATBUFBLOCKS use that value instead. While not currently actively exploitable, it was in the past so adding this check is worthwhile.
This addresses CVE-2025-24857 and was originally reported by Harvey Phillips of Amazon Element55
--- fs/fat/fat.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/fat/fat.c +5 -0
@@ -216,6 +216,11 @@ static __u32 get_fatent(fsdata *mydata, __u32 entry)if (flush_dirty_fat_buffer (mydata) <0 )return -1 ; +if (getsize >FATBUFBLOCKS ) { +debug ("getsize is too large for bufptr\n" ); + getsize =FATBUFBLOCKS ; + } +if (disk_read (startblock, getsize, bufptr) <0 ) {debug ("Error reading FAT blocks\n" );return ret;
Signature · 1 line
2.43.0
Quoted 10 lines · Tom Rini
We do not perform a check on the value of getsize in
get_fatentto ensure that it will fit within the allocated buffer. For safety sake, add a check now and if the value exceeds FATBUFBLOCKS use that value instead. While not currently actively exploitable, it was in the past so adding this check is worthwhile.This addresses CVE-2025-24857 and was originally reported by Harvey Phillips of Amazon Element55
[...]
Applied to u-boot/master, thanks!
[1/1] fs: fat: Perform sanity checks on getsize in get_fatent()
commit: 87d85139a96a39429120cca838e739408ef971a2
Signature · 1 line
Tom