<feed xmlns='http://www.w3.org/2005/Atom'>
<title>u-boot.git/fs/squashfs, branch next</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.</subtitle>
<id>http://cgit.235523.xyz/u-boot.git/atom/fs/squashfs?h=next</id>
<link rel='self' href='http://cgit.235523.xyz/u-boot.git/atom/fs/squashfs?h=next'/>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/'/>
<updated>2026-07-25T13:55:35Z</updated>
<entry>
<title>Merge patch series "fs/squashfs: fix symlink load failure on large images"</title>
<updated>2026-07-25T13:55:35Z</updated>
<author>
<name>Tom Rini</name>
<email>trini@konsulko.com</email>
</author>
<published>2026-07-25T13:55:35Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=b635d43bca429500cb8ef20aa151cb5773b9a8a5'/>
<id>urn:sha1:b635d43bca429500cb8ef20aa151cb5773b9a8a5</id>
<content type='text'>
Allan ELKAIM &lt;allan.elkaim@gmail.com&gt; says:

sqfsload fails to load a file through a symlink when the squashfs
image contains a large number of inodes (e.g. a rootfs that includes
the tzdata timezone database).

Root cause: sqfs_read_nest() resolves the symlink by calling itself
recursively without first freeing the parent directory's inode and
directory table buffers. This causes a temporary double allocation
that can exhaust the U-Boot heap. When malloc() subsequently fails
inside sqfs_read_directory_table(), the error goes undetected and
sqfs_search_dir() is called with a NULL pos_list pointer, leading to:

  Error: invalid inode reference to directory table.
  Failed to load '/boot/Image'

Patch 1 fixes the structural problem (temporary double allocation)
and plugs the silent NULL pointer path in sqfs_read_directory_table().
Patch 2 adds the missing return-value checks on sqfs_dir_offset() that
turn any residual lookup failure into a clean error propagation.

Patch 3 (reworked in v3 following Richard Genoud's review) fixes
pre-existing leaks of dirs-&gt;entry on the error paths of
sqfs_search_dir(), by centralizing the cleanup at the 'out' label.

All patches are independent and can be reviewed separately.

The bug was first observed on U-Boot v2024.01 and is still present
on v2026.04. The patches have been tested on a Raspberry Pi CM4
running U-Boot v2026.04 (Yocto Scarthgap 5.0.17) with a 325 MB
squashfs rootfs containing 22 517 inodes. The symlink
/boot/Image -&gt; Image-6.6.63-v8 now resolves successfully.

This series addresses the bug reported at:
https://lists.u-boot-project.org/pipermail/u-boot/2026-May/618533.html

Link: https://lore.kernel.org/r/20260713142420.2618339-1-allan.elkaim@gmail.com
</content>
</entry>
<entry>
<title>fs/squashfs: fix dirs-&gt;entry leaks on sqfs_search_dir() error paths</title>
<updated>2026-07-25T00:39:29Z</updated>
<author>
<name>Allan ELKAIM</name>
<email>allan.elkaim@gmail.com</email>
</author>
<published>2026-07-13T14:22:47Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=171b604888537dd7112ffddaa13abb16932eabd0'/>
<id>urn:sha1:171b604888537dd7112ffddaa13abb16932eabd0</id>
<content type='text'>
Several error paths in sqfs_search_dir() return through 'goto out'
while a directory entry obtained from sqfs_readdir_nest() is still
held, leaking dirs-&gt;entry: the inode lookup failure, the symlink
nesting limit check, every allocation/tokenization failure during
symlink resolution, and the case where readdir aborts after an
entry was already read.

Instead of freeing dirs-&gt;entry at each error site, centralize the
cleanup at the 'out' label: on error, no valid entry may be handed
back to the caller, so it can be freed unconditionally there. On
success, dirs-&gt;entry is already NULL: it is freed at the end of
each token iteration and before recursing into a symlink target,
and the root directory path never allocates it.

Explicit frees remain only where a success path needs them:
between reads in the readdir loop, at the end of each token
iteration, and before the recursive call. The now-redundant frees
on individual error paths are removed.

Suggested-by: Richard Genoud &lt;richard.genoud@bootlin.com&gt;
Signed-off-by: Allan ELKAIM &lt;allan.elkaim@gmail.com&gt;
</content>
</entry>
<entry>
<title>fs/squashfs: add sqfs_dir_offset() error checks</title>
<updated>2026-07-25T00:39:29Z</updated>
<author>
<name>Allan ELKAIM</name>
<email>allan.elkaim@gmail.com</email>
</author>
<published>2026-07-13T14:22:45Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=57e0bb7bf00dadd7537f93609afb955108ce22c7'/>
<id>urn:sha1:57e0bb7bf00dadd7537f93609afb955108ce22c7</id>
<content type='text'>
sqfs_dir_offset() returns a negative errno on failure, but three
call sites in sqfs_search_dir() use the return value as an array
index without checking for errors first. If the lookup fails,
dirs-&gt;table is set to an invalid address, leading to undefined
behavior.

Add negative-value guards after each sqfs_dir_offset() call so
that any lookup failure propagates cleanly as an error rather
than producing incorrect results.

Note: the corresponding sqfs_find_inode() NULL checks and the
heap exhaustion fix during symlink resolution are applied in
separate patches.

Acked-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Reviewed-by: Richard Genoud &lt;richard.genoud@bootlin.com&gt;
Signed-off-by: Allan ELKAIM &lt;allan.elkaim@gmail.com&gt;
</content>
</entry>
<entry>
<title>fs/squashfs: fix heap exhaustion during symlink resolution</title>
<updated>2026-07-25T00:39:29Z</updated>
<author>
<name>Allan ELKAIM</name>
<email>allan.elkaim@gmail.com</email>
</author>
<published>2026-07-13T14:22:43Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=9a9d46cb5e1a8f600c52f3ddaeaca8d4f28f66ee'/>
<id>urn:sha1:9a9d46cb5e1a8f600c52f3ddaeaca8d4f28f66ee</id>
<content type='text'>
When sqfs_read_nest() encounters a symlink it resolves it by calling
itself recursively. In the unfixed code this looks like:

  // dirsp is open: inode_table + dir_table still on heap
  resolved = sqfs_resolve_symlink(symlink, filename);
  ret = sqfs_read_nest(resolved, ...); // recursive: allocates a new
                                       // inode_table + dir_table pair
  free(resolved);
  goto out;
  // out: sqfs_closedir(dirsp) &lt;- parent tables freed HERE, too late

There is no permanent leak: the parent's tables are freed at the
out: label once the recursive call returns. However, for the entire
duration of the recursive call both the parent's inode_table +
dir_table and the child's inode_table + dir_table are live on the
heap simultaneously. On large squashfs images these tables can be
significant in size, and this temporary double allocation may exhaust
the heap budget.

A superficial workaround would be to increase CONFIG_SYS_MALLOC_LEN,
but that wastes memory on all boards and does not address the
structural problem. The correct fix is to change the freeing order:
release the parent directory's resources before recursing. This way
only one set of inode and directory tables is live at any given time,
halving the peak heap usage during symlink resolution.

When heap exhaustion does occur and malloc returns NULL for dir_table
or pos_list inside sqfs_read_directory_table(), the failure is
currently silent and cascading:

  - metablks_count is not reset to -1 before the goto out, so the
    function returns a positive block count alongside a NULL pointer.
  - sqfs_opendir_nest() does not detect the failure (it only checks
    metablks_count &lt; 1) and calls sqfs_search_dir() with m_list=NULL.
  - sqfs_dir_offset() iterates over m_list[0..n], reading from
    addresses 0x0, 0x4, 0x8, ... None of those values match the
    inode's start_block, so the function returns -EINVAL.
  - The error propagates up as a load failure with no indication
    that the root cause was heap exhaustion:

      Error: invalid inode reference to directory table.
      Failed to load '&lt;symlink path&gt;'

Two fixes:
1. In sqfs_read_directory_table(), set metablks_count = -1 whenever
   malloc fails after sqfs_count_metablks() returns a positive value,
   so that the caller's "metablks_count &lt; 1" check correctly detects
   the failure and avoids calling sqfs_search_dir() with a NULL
   pos_list.
2. In sqfs_read_nest() and sqfs_size_nest(), call sqfs_closedir() on
   the parent dirsp before the recursive call so that the parent's
   inode and directory tables are freed before the child allocates
   its own. Only one set of tables is then live at any given time,
   halving peak heap usage during symlink resolution.

Link: https://lists.denx.de/pipermail/u-boot/2026-May/618533.html

Reviewed-by: Richard Genoud &lt;richard.genoud@bootlin.com&gt;
Acked-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Signed-off-by: Allan ELKAIM &lt;allan.elkaim@gmail.com&gt;
</content>
</entry>
<entry>
<title>fs/squashfs: Set ret to 0 on successful read</title>
<updated>2026-04-24T17:28:10Z</updated>
<author>
<name>Michael Zimmermann</name>
<email>sigmaepsilon92@gmail.com</email>
</author>
<published>2026-04-20T16:35:31Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=30885b01aaa4bcdfa3fee9ca3066d3af563e6688'/>
<id>urn:sha1:30885b01aaa4bcdfa3fee9ca3066d3af563e6688</id>
<content type='text'>
It might still be a positive number due to the call to sqfs_disk_read.
This only happens when reading a file from an uncompressed squashfs.

I found this by trying to boot using the extlinux bootmethod, where
positive values are treated as errors.

Signed-off-by: Michael Zimmermann &lt;sigmaepsilon92@gmail.com&gt;
Acked-by: Richard Genoud &lt;richard.genoud@bootlin.com&gt;
Reviewed-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
</entry>
<entry>
<title>spl: add squashfs support</title>
<updated>2026-03-26T17:04:28Z</updated>
<author>
<name>Richard Genoud</name>
<email>richard.genoud@bootlin.com</email>
</author>
<published>2026-03-13T10:42:26Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=6494e823b46ced400764b6203d7480c9e3badc20'/>
<id>urn:sha1:6494e823b46ced400764b6203d7480c9e3badc20</id>
<content type='text'>
Implement spl_load_image_sqfs() in spl code.

This will be used in MMC to read a file from a squashfs partition.

Also, loosen squashfs read checks on file size by not failing when a
bigger size than the actual file size is requested. (Just read the file)
This is needed for FIT loading, because the length is ALIGNed.

Signed-off-by: Richard Genoud &lt;richard.genoud@bootlin.com&gt;
Reviewed-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Reviewed-by: João Marcos Costa &lt;joaomarcos.costa@bootlin.com&gt;
</content>
</entry>
<entry>
<title>fs/squashfs: sqfs_decompressor: simplify code</title>
<updated>2026-03-26T17:04:28Z</updated>
<author>
<name>Richard Genoud</name>
<email>richard.genoud@bootlin.com</email>
</author>
<published>2026-03-13T10:42:24Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=0fe2801730edb99e24b601b043ec5595af319274'/>
<id>urn:sha1:0fe2801730edb99e24b601b043ec5595af319274</id>
<content type='text'>
Switch to if (CONFIG_IS_ENABLED()) instead of #if when possible and
remove unnecessary cases.

Signed-off-by: Richard Genoud &lt;richard.genoud@bootlin.com&gt;
Reviewed-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Reviewed-by: João Marcos Costa &lt;joaomarcos.costa@bootlin.com&gt;
</content>
</entry>
<entry>
<title>fs/squashfs: fix sqfs_decompressor.c build in SPL</title>
<updated>2026-03-26T17:04:28Z</updated>
<author>
<name>Richard Genoud</name>
<email>richard.genoud@bootlin.com</email>
</author>
<published>2026-03-13T10:42:23Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=f0b4f502bdd5f17da58aca9ebf86e16e96e0d347'/>
<id>urn:sha1:f0b4f502bdd5f17da58aca9ebf86e16e96e0d347</id>
<content type='text'>
CONFIG_IS_ENABLED() must be used in place of IS_ENABLED() for config
options that have a _SPL_ counterpart.

Signed-off-by: Richard Genoud &lt;richard.genoud@bootlin.com&gt;
Reviewed-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
Reviewed-by: João Marcos Costa &lt;joaomarcos.costa@bootlin.com&gt;
</content>
</entry>
<entry>
<title>fs/squashfs: fix heap buffer overflow in sqfs_frag_lookup()</title>
<updated>2026-02-23T18:45:50Z</updated>
<author>
<name>Eric Kilmer</name>
<email>eric.kilmer@trailofbits.com</email>
</author>
<published>2026-02-20T19:48:08Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=e365a269df5d01307390bdf7d6a1081d94b06470'/>
<id>urn:sha1:e365a269df5d01307390bdf7d6a1081d94b06470</id>
<content type='text'>
sqfs_frag_lookup() reads a 16-bit metadata block header whose lower
15 bits encode the data size. Unlike sqfs_read_metablock() in
sqfs_inode.c, this function does not validate that the decoded size is
within SQFS_METADATA_BLOCK_SIZE (8192). A malformed SquashFS image can
set the size field to any value up to 32767, causing memcpy to write
past the 8192-byte 'entries' heap buffer.

Add the same bounds check used by sqfs_read_metablock(): reject any
metadata block header with SQFS_METADATA_SIZE(header) exceeding
SQFS_METADATA_BLOCK_SIZE.

Found by fuzzing with libFuzzer + AddressSanitizer.

Signed-off-by: Eric Kilmer &lt;eric.kilmer@trailofbits.com&gt;
Reviewed-by: Miquel Raynal &lt;miquel.raynal@bootlin.com&gt;
</content>
</entry>
<entry>
<title>fs: prevent integer overflow in sqfs_concat</title>
<updated>2026-01-16T19:04:40Z</updated>
<author>
<name>Timo tp Preißl</name>
<email>t.preissl@proton.me</email>
</author>
<published>2026-01-09T11:24:59Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=870aff99a279ed428c5a2560b2441b3079ddb34b'/>
<id>urn:sha1:870aff99a279ed428c5a2560b2441b3079ddb34b</id>
<content type='text'>
An integer overflow in length calculation could lead to
under-allocation and buffer overcopy.

Signed-off-by: Timo tp Preißl &lt;t.preissl@proton.me&gt;
Reviewed-by: Tom Rini &lt;trini@konsulko.com&gt;
Reviewed-by: Simon Glass &lt;simon.glass@canonical.com&gt;
Reviewed-by: João Marcos Costa &lt;joaomarcos.costa@bootlin.com&gt;
</content>
</entry>
</feed>
