mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* Various Squashfs Issues
@ 2024-07-16 15:49 Richard Weinberger
  2024-07-17  7:36 ` Ahmad Fatoum
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Weinberger @ 2024-07-16 15:49 UTC (permalink / raw)
  To: barebox

Hi!

While inspecting the squashfs implementation of Barebox I noticed
some issues and was able trigger heap corruptions using crafted filesystems.

e.g.
==30712==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7f07bdaff800 at pc 0x0000004af3e2 bp 0x7ffdf8374a40 sp 0x7ffdf8374a38
WRITE of size 1 at 0x7f07bdaff800 thread T0
    #0 0x4af3e1 in __default_memcpy lib/string.c:638
    #1 0x534791 in squashfs_copy_data fs/squashfs/cache.c:257
    #2 0x534948 in squashfs_read_metadata fs/squashfs/cache.c:299
    #3 0x539d46 in squashfs_get_link fs/squashfs/symlink.c:62
    #4 0x509153 in get_link fs/fs.c:1919
    #5 0x512395 in trailing_symlink fs/fs.c:2230
    #6 0x512395 in openat fs/fs.c:2600
    #7 0x49926b in barebox_open include/fcntl.h:45
    #8 0x49926b in do_cat commands/cat.c:40
    #9 0x415e99 in execute_command common/command.c:62
    #10 0x40f25e in execute_binfmt common/binfmt.c:67
    #11 0x42cef4 in run_pipe_real common/hush.c:845
    #12 0x42cef4 in run_list_real common/hush.c:969
    #13 0x42b14e in run_list common/hush.c:1107
    #14 0x42b14e in parse_stream_outer common/hush.c:1734
    #15 0x42db7e in run_shell common/hush.c:1957
    #16 0x40a718 in run_init common/startup.c:322
    #17 0x40a7f2 in start_barebox common/startup.c:368
    #18 0x5490f3 in main (/home/rw/barebox/barebox+0x5490f3)
    #19 0x7f07c083e24c in __libc_start_main (/lib64/libc.so.6+0x3524c)
    #20 0x406f69 in _start ../sysdeps/x86_64/start.S:120

0x7f07bdaff800 is located 0 bytes to the right of 16777216-byte region [0x7f07bcaff800,0x7f07bdaff800)
allocated by thread T0 here:
    #0 0x7f07c0adc110 in malloc (/usr/lib64/libasan.so.4+0xdc110)
    #1 0x548e44 in main (/home/rw/barebox/barebox+0x548e44)
    #2 0x7f07c083e24c in __libc_start_main (/lib64/libc.so.6+0x3524c)


While implementing fixes for them I realized that these are all known
and fixed in Linux.

I suggest backporting at least these Linux fixes for squashfs:

01cfb7937a9af ("squashfs: be more careful about metadata corruption")
d512584780d3e ("squashfs: more metadata hardening")
cdbb65c4c7ead ("squashfs metadata 2: electric boogaloo")
71755ee5350b6 ("squashfs: more metadata hardening")
a3f94cb99a854 ("Squashfs: Compute expected length from inode size rather than block length")

Thanks,
//richard

-- 
​​​​​sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT
UID/VAT Nr: ATU 66964118 | FN: 374287y





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

end of thread, other threads:[~2024-07-17  7:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-16 15:49 Various Squashfs Issues Richard Weinberger
2024-07-17  7:36 ` Ahmad Fatoum

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