<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/fs/udf, branch master</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>Merge tag 'vfs-7.4-rc3.fixes.2' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs</title>
<updated>2026-11-12T00:48:56+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2026-11-12T00:48:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=9d66f26fefacebfeed15de31c1123451a17ff119'/>
<id>9d66f26fefacebfeed15de31c1123451a17ff119</id>
<content type='text'>
Pull more vfs fixes from Christian Brauner:

 - inode: Let the shrinker reclaim inodes with I_METADATA_WRITEBACK like
   any other clean inode and have evict() write out what the bit tracks
   unless the inode is being deleted.

   Since v7.3 ext2, ext4 without a journal, fat, udf and minix set
   I_METADATA_WRITEBACK when they copy an inode into its buffer and only
   fsync() and friends clear it again. inode_lru_isolate() took such
   inodes off the LRU expecting something to put them back once the bit
   was gone but nothing ever did. So they couldn't be reclaimed until
   something fsynced them or the filesystem was unmounted.

   On ext4 without a journal an atime update was enough to pin an inode,
   and creating 60000 small files in a memory cgroup limited to 96M got
   the task OOM killed after about 43000 of them. Now all 60000 get
   created.

 - dcache:

     - Give d_set_mounted() a seqlock of its own that d_invalidate()
       waits on after unhashing the dentry.

       Since v6.17 d_set_mounted() doesn't bump the seqcount of
       rename_lock anymore, so a mount racing d_invalidate() could end
       up below the unhashed directory. Nobody can reach it there and it
       pins the subtree until the mount namespace goes away. With a FUSE
       directory 3000 levels deep 151 of 200 bind mounts racing
       FUSE_NOTIFY_INVAL_ENTRY ended up there.

     - Only take busy secondary roots off -&gt;s_roots in do_one_tree() so
       that umount waits for a racing eviction of an idle one. Since
       v7.3 it didn't, which ended in busy inodes after unmount and an
       iput() on a dead superblock.

     - Make a disconnected dentry a secondary root when the mount on it
       goes away so that umount finds it and waits for its eviction.
       With CAP_DAC_READ_SEARCH such a dentry can be mounted on via
       open_by_handle_at() and move_mount() and umount racing its
       eviction ended the same way.

 - splice:

     - Remove pipe buffer stealing as you and David suggested.

       fuse and virtio_console were the only users of -&gt;try_steal() and
       now always copy, as they already did when a steal failed.
       Stealing took page cache folios out of their files and turned
       pages into page cache folios and back. SPLICE_F_GIFT and
       SPLICE_F_MOVE are still accepted and fuse still advertises
       FUSE_SPLICE_MOVE so servers that ask for it mount as before.

     - Clamp a -&gt;write_iter() result that is larger than the iterator in
       iter_file_splice_write() instead of only warning about it.
       Otherwise the pipe releases buffers past its head.

 - ns:

     -Allocate the namespace id before calling the namespace_init LSM
      hook that was added this merge window. Landlock now logs the
      allocated id instead of zero when it denies the creation of a
      namespace.

     -Don't mark the arguments of the namespace_init and namespace_free
      hooks as trusted for bpf LSM programs. Both see namespaces that
      are only partially set up or on their way out.

 - proc: Don't let proc_sys_call_handler() report more bytes written
   than it was passed when a cgroup/sysctl bpf program replaced the
   value with a longer one. A splice() into the sysctl file then walked
   past the pipe head.

 - coda: Pass the append state of each write on to the container file
   with RWF_APPEND or RWF_NOAPPEND. coda_open() sets O_APPEND on the
   container file after its iocb flags were cached, so an O_APPEND write
   overwrote existing data instead of appending.

 - adfs: Reject big directory entries in adfs_fplus_getnext() whose name
   doesn't fit into the name buffer. A crafted image overflowed it on
   the stack.

* tag 'vfs-7.4-rc3.fixes.2' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: (28 commits)
  nstree: drop ns_tree_add_raw()
  ns: allocate the namespace id before the namespace_init hook
  bpf: don't mark namespace_init and namespace_free arguments as trusted
  splice: replace nosteal_pipe_buf_ops with default_pipe_buf_ops
  splice: remove pipe buffer stealing
  fuse: don't move pipe buffers into the page cache
  virtio_console: copy pipe buffers in splice_write()
  fs/adfs: bound directory entry name length in adfs_fplus_getnext()
  dcache: let umount find a disconnected ex-mountpoint
  dcache: wait for a racing eviction of a secondary root
  dcache: let d_invalidate() wait for a d_set_mounted() in flight
  fat: drop mmb_sync() from fat_evict_inode()
  udf: drop mmb_sync() from udf_evict_inode()
  minix: drop mmb_sync() from minix_evict_inode()
  ext4: drop mmb_sync() from ext4_evict_inode()
  ext2: drop mmb_sync() from ext2_evict_inode()
  fs: don't strand I_METADATA_WRITEBACK inodes outside the LRU
  fs: set I_METADATA_WRITEBACK in mmb_mark_buffer_dirty()
  udf: don't allocate the inode block in udf_sync_inode_metadata()
  minix: don't read the inode block in minix_sync_inode_metadata()
  ...
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pull more vfs fixes from Christian Brauner:

 - inode: Let the shrinker reclaim inodes with I_METADATA_WRITEBACK like
   any other clean inode and have evict() write out what the bit tracks
   unless the inode is being deleted.

   Since v7.3 ext2, ext4 without a journal, fat, udf and minix set
   I_METADATA_WRITEBACK when they copy an inode into its buffer and only
   fsync() and friends clear it again. inode_lru_isolate() took such
   inodes off the LRU expecting something to put them back once the bit
   was gone but nothing ever did. So they couldn't be reclaimed until
   something fsynced them or the filesystem was unmounted.

   On ext4 without a journal an atime update was enough to pin an inode,
   and creating 60000 small files in a memory cgroup limited to 96M got
   the task OOM killed after about 43000 of them. Now all 60000 get
   created.

 - dcache:

     - Give d_set_mounted() a seqlock of its own that d_invalidate()
       waits on after unhashing the dentry.

       Since v6.17 d_set_mounted() doesn't bump the seqcount of
       rename_lock anymore, so a mount racing d_invalidate() could end
       up below the unhashed directory. Nobody can reach it there and it
       pins the subtree until the mount namespace goes away. With a FUSE
       directory 3000 levels deep 151 of 200 bind mounts racing
       FUSE_NOTIFY_INVAL_ENTRY ended up there.

     - Only take busy secondary roots off -&gt;s_roots in do_one_tree() so
       that umount waits for a racing eviction of an idle one. Since
       v7.3 it didn't, which ended in busy inodes after unmount and an
       iput() on a dead superblock.

     - Make a disconnected dentry a secondary root when the mount on it
       goes away so that umount finds it and waits for its eviction.
       With CAP_DAC_READ_SEARCH such a dentry can be mounted on via
       open_by_handle_at() and move_mount() and umount racing its
       eviction ended the same way.

 - splice:

     - Remove pipe buffer stealing as you and David suggested.

       fuse and virtio_console were the only users of -&gt;try_steal() and
       now always copy, as they already did when a steal failed.
       Stealing took page cache folios out of their files and turned
       pages into page cache folios and back. SPLICE_F_GIFT and
       SPLICE_F_MOVE are still accepted and fuse still advertises
       FUSE_SPLICE_MOVE so servers that ask for it mount as before.

     - Clamp a -&gt;write_iter() result that is larger than the iterator in
       iter_file_splice_write() instead of only warning about it.
       Otherwise the pipe releases buffers past its head.

 - ns:

     -Allocate the namespace id before calling the namespace_init LSM
      hook that was added this merge window. Landlock now logs the
      allocated id instead of zero when it denies the creation of a
      namespace.

     -Don't mark the arguments of the namespace_init and namespace_free
      hooks as trusted for bpf LSM programs. Both see namespaces that
      are only partially set up or on their way out.

 - proc: Don't let proc_sys_call_handler() report more bytes written
   than it was passed when a cgroup/sysctl bpf program replaced the
   value with a longer one. A splice() into the sysctl file then walked
   past the pipe head.

 - coda: Pass the append state of each write on to the container file
   with RWF_APPEND or RWF_NOAPPEND. coda_open() sets O_APPEND on the
   container file after its iocb flags were cached, so an O_APPEND write
   overwrote existing data instead of appending.

 - adfs: Reject big directory entries in adfs_fplus_getnext() whose name
   doesn't fit into the name buffer. A crafted image overflowed it on
   the stack.

* tag 'vfs-7.4-rc3.fixes.2' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: (28 commits)
  nstree: drop ns_tree_add_raw()
  ns: allocate the namespace id before the namespace_init hook
  bpf: don't mark namespace_init and namespace_free arguments as trusted
  splice: replace nosteal_pipe_buf_ops with default_pipe_buf_ops
  splice: remove pipe buffer stealing
  fuse: don't move pipe buffers into the page cache
  virtio_console: copy pipe buffers in splice_write()
  fs/adfs: bound directory entry name length in adfs_fplus_getnext()
  dcache: let umount find a disconnected ex-mountpoint
  dcache: wait for a racing eviction of a secondary root
  dcache: let d_invalidate() wait for a d_set_mounted() in flight
  fat: drop mmb_sync() from fat_evict_inode()
  udf: drop mmb_sync() from udf_evict_inode()
  minix: drop mmb_sync() from minix_evict_inode()
  ext4: drop mmb_sync() from ext4_evict_inode()
  ext2: drop mmb_sync() from ext2_evict_inode()
  fs: don't strand I_METADATA_WRITEBACK inodes outside the LRU
  fs: set I_METADATA_WRITEBACK in mmb_mark_buffer_dirty()
  udf: don't allocate the inode block in udf_sync_inode_metadata()
  minix: don't read the inode block in minix_sync_inode_metadata()
  ...
</pre>
</div>
</content>
</entry>
<entry>
<title>udf: drop mmb_sync() from udf_evict_inode()</title>
<updated>2026-11-11T10:59:23+00:00</updated>
<author>
<name>Christian Brauner</name>
<email>brauner@kernel.org</email>
</author>
<published>2026-11-09T16:51:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=c8f250419683099a86e314f79c2cb6b62a2a3f5e'/>
<id>c8f250419683099a86e314f79c2cb6b62a2a3f5e</id>
<content type='text'>
evict() writes out what I_METADATA_WRITEBACK tracks before it calls
-&gt;evict_inode() and since mmb_mark_buffer_dirty() sets the bit that
includes the tracked metadata buffers. So there's nothing left for
udf_evict_inode() to sync for an inode that isn't deleted.

Link: https://patch.msgid.link/20261109-work-inode-metadata_writeback-v3-13-91ac6c024018@kernel.org
Reviewed-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Christian Brauner (Amutable) &lt;brauner@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
evict() writes out what I_METADATA_WRITEBACK tracks before it calls
-&gt;evict_inode() and since mmb_mark_buffer_dirty() sets the bit that
includes the tracked metadata buffers. So there's nothing left for
udf_evict_inode() to sync for an inode that isn't deleted.

Link: https://patch.msgid.link/20261109-work-inode-metadata_writeback-v3-13-91ac6c024018@kernel.org
Reviewed-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Christian Brauner (Amutable) &lt;brauner@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>udf: don't allocate the inode block in udf_sync_inode_metadata()</title>
<updated>2026-11-11T10:59:16+00:00</updated>
<author>
<name>Christian Brauner</name>
<email>brauner@kernel.org</email>
</author>
<published>2026-11-09T16:51:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=05ad4c91fe2852a19d04311883420ffefb02300d'/>
<id>05ad4c91fe2852a19d04311883420ffefb02300d</id>
<content type='text'>
udf_sync_inode_metadata() looks the block that holds the inode up with
sb_getblk() which allocates a buffer for it if it isn't cached. But a
block that isn't cached is neither dirty nor under writeback, so there's
nothing to write or to wait for and the buffer just gets thrown away
again.

That allocation is also something we can't afford once inode eviction
calls -&gt;sync_inode_metadata() from reclaim. So look the block up with
sb_find_get_block_nonatomic() instead.

Cc: stable@vger.kernel.org # v7.3
Reviewed-by: Jan Kara &lt;jack@suse.cz&gt;
Link: https://patch.msgid.link/20261109-work-inode-metadata_writeback-v3-7-91ac6c024018@kernel.org
Signed-off-by: Christian Brauner (Amutable) &lt;brauner@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
udf_sync_inode_metadata() looks the block that holds the inode up with
sb_getblk() which allocates a buffer for it if it isn't cached. But a
block that isn't cached is neither dirty nor under writeback, so there's
nothing to write or to wait for and the buffer just gets thrown away
again.

That allocation is also something we can't afford once inode eviction
calls -&gt;sync_inode_metadata() from reclaim. So look the block up with
sb_find_get_block_nonatomic() instead.

Cc: stable@vger.kernel.org # v7.3
Reviewed-by: Jan Kara &lt;jack@suse.cz&gt;
Link: https://patch.msgid.link/20261109-work-inode-metadata_writeback-v3-7-91ac6c024018@kernel.org
Signed-off-by: Christian Brauner (Amutable) &lt;brauner@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>udf: Fix incorrect error code in udf_current_aext()</title>
<updated>2026-11-05T14:11:44+00:00</updated>
<author>
<name>Jan Kara</name>
<email>jack@suse.cz</email>
</author>
<published>2026-11-05T14:11:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e5801273f93eb7513850b1c38ea14d69f2de1592'/>
<id>e5801273f93eb7513850b1c38ea14d69f2de1592</id>
<content type='text'>
There are two places in udf_current_aext() that return -1 instead of
proper error code. Fix them.

Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There are two places in udf_current_aext() that return -1 instead of
proper error code. Fix them.

Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>udf: Simplify udf_table_prealloc_blocks()</title>
<updated>2026-11-05T14:09:19+00:00</updated>
<author>
<name>Jan Kara</name>
<email>jack@suse.cz</email>
</author>
<published>2026-11-05T14:09:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a3b98efdb320e62ec0f89caaa67993a2d1c178be'/>
<id>a3b98efdb320e62ec0f89caaa67993a2d1c178be</id>
<content type='text'>
Simplify handling when the specified extent is not found in the table
of free blocks.

Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Simplify handling when the specified extent is not found in the table
of free blocks.

Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>udf: don't use eloc after the end of the unallocated space table</title>
<updated>2026-11-05T14:07:35+00:00</updated>
<author>
<name>Matthias Goergens</name>
<email>matthias.goergens@gmail.com</email>
</author>
<published>2026-10-30T14:05:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=94401199df90e1c2a50c6e4b73618ac5a4ba83ba'/>
<id>94401199df90e1c2a50c6e4b73618ac5a4ba83ba</id>
<content type='text'>
When udf_next_aext() returns 0, its eloc, elen and etype outputs hold
no defined value.  Two walks of the unallocated space table still use
eloc after the walk has reached the end of the table.

udf_table_prealloc_blocks() looks for a free extent starting at
first_block and decides whether it found one by comparing eloc with
first_block after the walk.  If the table's list ends in a continuation
descriptor that leads to an empty allocation extent, eloc is then the
block of that allocation extent, which is in use, and if that is
first_block, the block is handed out as preallocation.  Once
udf_discard_prealloc() no longer frees the wrong block, this is what
still makes fsx in generic/091 and generic/263 read back bad data on a
table, in about one run in four.  Only take the extent if the walk
stopped at it.

When udf_table_free_blocks() cannot merge the freed blocks into an
existing extent, it appends a new one and sets only its block number,
so the partition reference comes from whatever eloc held after the
walk, and with long allocation descriptors it is written to disk.  For
a table without extents, eloc was never set.  Take the partition
reference from the freed blocks instead.  Short allocation descriptors
do not store the partition reference, which is why this half remains a
latent long-descriptor fix rather than a reproduced failure.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Matthias Goergens &lt;matthias.goergens@gmail.com&gt;
Link: https://patch.msgid.link/fd9ca4c4ba98c00c012ec861f6c0bc08a3b1d07b.1793349907.git.matthias.goergens@gmail.com
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When udf_next_aext() returns 0, its eloc, elen and etype outputs hold
no defined value.  Two walks of the unallocated space table still use
eloc after the walk has reached the end of the table.

udf_table_prealloc_blocks() looks for a free extent starting at
first_block and decides whether it found one by comparing eloc with
first_block after the walk.  If the table's list ends in a continuation
descriptor that leads to an empty allocation extent, eloc is then the
block of that allocation extent, which is in use, and if that is
first_block, the block is handed out as preallocation.  Once
udf_discard_prealloc() no longer frees the wrong block, this is what
still makes fsx in generic/091 and generic/263 read back bad data on a
table, in about one run in four.  Only take the extent if the walk
stopped at it.

When udf_table_free_blocks() cannot merge the freed blocks into an
existing extent, it appends a new one and sets only its block number,
so the partition reference comes from whatever eloc held after the
walk, and with long allocation descriptors it is written to disk.  For
a table without extents, eloc was never set.  Take the partition
reference from the freed blocks instead.  Short allocation descriptors
do not store the partition reference, which is why this half remains a
latent long-descriptor fix rather than a reproduced failure.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Matthias Goergens &lt;matthias.goergens@gmail.com&gt;
Link: https://patch.msgid.link/fd9ca4c4ba98c00c012ec861f6c0bc08a3b1d07b.1793349907.git.matthias.goergens@gmail.com
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>udf: fix preallocation discarding before an empty allocation extent</title>
<updated>2026-11-05T14:07:35+00:00</updated>
<author>
<name>Matthias Goergens</name>
<email>matthias.goergens@gmail.com</email>
</author>
<published>2026-10-30T14:05:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=0c52750caaaccee8b0e929450fe6538ec4985722'/>
<id>0c52750caaaccee8b0e929450fe6538ec4985722</id>
<content type='text'>
udf_discard_prealloc() finds the last extent of a file by peeking at
the next one with udf_next_aext() and stopping when that returns 0.
The peek reads into eloc and elen, and the code then uses them as the
last extent.  But when udf_next_aext() returns 0 they hold no defined
value: if the extent list ends in a continuation descriptor that leads
to an empty allocation extent, they describe that continuation, i.e.
the block of the empty allocation extent, one block long.

The kernel creates such lists itself: when udf_delete_aext() removes
the only descriptor of the last allocation extent in a list, it leaves
that allocation extent empty and the continuation to it in place.

If the last extent is a preallocation, udf_discard_prealloc() deletes
it with udf_delete_aext(), which finds the following allocation extent
empty, so it also removes the continuation and frees that allocation
extent's block.  udf_discard_prealloc() then frees eloc and elen: that
block a second time, instead of the preallocated blocks.  On a space
bitmap the preallocated blocks leak and the free block count drifts.
On an unallocated space table the second free adds a second free
extent for the same block, which is later handed out twice: fsx as run
by generic/091 and generic/263 ends up with two parts of its test file
in one block and reads back bad data.

Peek into separate variables, so that eloc and elen keep the last
extent that udf_next_aext() returned with 1.

Fixes: cfe4c1b25dd6 ("udf: Fix preallocation discarding at indirect extent boundary")
Cc: stable@vger.kernel.org
Suggested-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Matthias Goergens &lt;matthias.goergens@gmail.com&gt;
Link: https://patch.msgid.link/480eccd1264a4cea5226fc36ed108931b2c403fb.1793349907.git.matthias.goergens@gmail.com
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
udf_discard_prealloc() finds the last extent of a file by peeking at
the next one with udf_next_aext() and stopping when that returns 0.
The peek reads into eloc and elen, and the code then uses them as the
last extent.  But when udf_next_aext() returns 0 they hold no defined
value: if the extent list ends in a continuation descriptor that leads
to an empty allocation extent, they describe that continuation, i.e.
the block of the empty allocation extent, one block long.

The kernel creates such lists itself: when udf_delete_aext() removes
the only descriptor of the last allocation extent in a list, it leaves
that allocation extent empty and the continuation to it in place.

If the last extent is a preallocation, udf_discard_prealloc() deletes
it with udf_delete_aext(), which finds the following allocation extent
empty, so it also removes the continuation and frees that allocation
extent's block.  udf_discard_prealloc() then frees eloc and elen: that
block a second time, instead of the preallocated blocks.  On a space
bitmap the preallocated blocks leak and the free block count drifts.
On an unallocated space table the second free adds a second free
extent for the same block, which is later handed out twice: fsx as run
by generic/091 and generic/263 ends up with two parts of its test file
in one block and reads back bad data.

Peek into separate variables, so that eloc and elen keep the last
extent that udf_next_aext() returned with 1.

Fixes: cfe4c1b25dd6 ("udf: Fix preallocation discarding at indirect extent boundary")
Cc: stable@vger.kernel.org
Suggested-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Matthias Goergens &lt;matthias.goergens@gmail.com&gt;
Link: https://patch.msgid.link/480eccd1264a4cea5226fc36ed108931b2c403fb.1793349907.git.matthias.goergens@gmail.com
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>udf: check the unallocated space table when it is loaded</title>
<updated>2026-11-05T14:07:35+00:00</updated>
<author>
<name>Matthias Goergens</name>
<email>matthias.goergens@gmail.com</email>
</author>
<published>2026-10-30T14:05:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e614c3e35a6699ed691b4d17e1ec4230e34aa3eb'/>
<id>e614c3e35a6699ed691b4d17e1ec4230e34aa3eb</id>
<content type='text'>
udf_table_new_block() hands out the first block of the extent closest
to its goal and trusts that the extent covers at least one whole block
inside the partition.  Nothing checks that.  A zero-length extent makes
it return the block the extent points at, which need not be free, and
the subtraction of one block then underflows the length into the type
bits, turning the entry into a bogus continuation.  An extent running
past the end of the partition makes it return blocks behind the
partition.

Such tables are not only found on crafted images: until the previous
commit, udf_table_new_block() itself left zero-length extents behind
in tables written by mkudffs, and then converted them into extents
running past the partition.

Check every extent once when the table is loaded, and refuse
read-write access if one is empty, is not a whole number of blocks, or
does not lie inside the partition, in the same way as for other
allocation information the kernel cannot use.  Check first that the
table is an Unallocated Space Entry at all: the walk starts at the
offset of the allocation descriptors in one, and for a file entry that
offset lies before the inode's in-memory copy of the descriptors.
Treat a chain of allocation extent descriptors that leads back to
itself the same way: the walk would otherwise return the same extents
forever, and the mount would never finish.  Let a fatal signal
interrupt the walk and fail the mount.

Refusing read-write access to an empty extent is deliberate.  It shows
that an old kernel took the last block but left the entry behind.  If
consumed again, the entry returns an in-use block and turns into a huge
bogus extent.  Refusing the table before that
happens avoids this second allocation; the filesystem can still be
mounted read-only.  The check cannot detect every overlap that may
already exist in a damaged table.

This patch should be backported together with the previous one: that
patch stops creating new empty extents, and this one rejects existing
ones before they are consumed again.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Matthias Goergens &lt;matthias.goergens@gmail.com&gt;
Link: https://patch.msgid.link/81233decd91f4a48bf4d74e3d15b547c7711e39f.1793349907.git.matthias.goergens@gmail.com
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
udf_table_new_block() hands out the first block of the extent closest
to its goal and trusts that the extent covers at least one whole block
inside the partition.  Nothing checks that.  A zero-length extent makes
it return the block the extent points at, which need not be free, and
the subtraction of one block then underflows the length into the type
bits, turning the entry into a bogus continuation.  An extent running
past the end of the partition makes it return blocks behind the
partition.

Such tables are not only found on crafted images: until the previous
commit, udf_table_new_block() itself left zero-length extents behind
in tables written by mkudffs, and then converted them into extents
running past the partition.

Check every extent once when the table is loaded, and refuse
read-write access if one is empty, is not a whole number of blocks, or
does not lie inside the partition, in the same way as for other
allocation information the kernel cannot use.  Check first that the
table is an Unallocated Space Entry at all: the walk starts at the
offset of the allocation descriptors in one, and for a file entry that
offset lies before the inode's in-memory copy of the descriptors.
Treat a chain of allocation extent descriptors that leads back to
itself the same way: the walk would otherwise return the same extents
forever, and the mount would never finish.  Let a fatal signal
interrupt the walk and fail the mount.

Refusing read-write access to an empty extent is deliberate.  It shows
that an old kernel took the last block but left the entry behind.  If
consumed again, the entry returns an in-use block and turns into a huge
bogus extent.  Refusing the table before that
happens avoids this second allocation; the filesystem can still be
mounted read-only.  The check cannot detect every overlap that may
already exist in a damaged table.

This patch should be backported together with the previous one: that
patch stops creating new empty extents, and this one rejects existing
ones before they are consumed again.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Matthias Goergens &lt;matthias.goergens@gmail.com&gt;
Link: https://patch.msgid.link/81233decd91f4a48bf4d74e3d15b547c7711e39f.1793349907.git.matthias.goergens@gmail.com
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>udf: don't let the extent type hide an exhausted free-space table extent</title>
<updated>2026-11-05T14:07:35+00:00</updated>
<author>
<name>Matthias Goergens</name>
<email>matthias.goergens@gmail.com</email>
</author>
<published>2026-10-30T14:05:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=da582d84fcf5f2f0c1d7760e1a899ca7cedb80fc'/>
<id>da582d84fcf5f2f0c1d7760e1a899ca7cedb80fc</id>
<content type='text'>
udf_table_new_block() takes the first block of the free-space table
extent closest to the goal.  It keeps that extent's type and length
together in goal_elen, subtracts one block, and deletes the extent only
if goal_elen then reaches zero.  UDF 2.60 section 2.3.7.1 requires the
free-space extents of an Unallocated Space Entry to be of type 1
(allocated but not recorded), and mkudffs writes them that way.  For
such an extent the type bits keep goal_elen non-zero, so taking its last
block leaves a type-1 extent of length zero behind, starting at the
block after the extent, which is in use.

The next allocation that picks this empty extent returns that in-use
block.  Subtracting a block from 0x40000000 then borrows from the type
bits, and the extent becomes type 0 with a length of 2^30 - blocksize:
about a gigabyte of "free" space overlapping live metadata, the other
table extents and whatever lies behind the partition.  From then on
blocks are handed out twice, or past the end of the partition.

Extents that udf_table_free_blocks() adds are type 0, where the check
works, so only tables written by mkudffs or by another implementation
are affected.  Nothing more than filling such a filesystem is needed:
on a fresh 1 MiB "mkudffs --space=unalloctable" image, creating empty
files until the partition is full writes file entries over the reserve
volume descriptor sequence and the backup anchor, and df then reports a
negative amount of used space.

On syzbot's images the same double allocation is what the two reports
below trip over.  In the first, ftruncate() extends a new file with
enough hole extents to need a chain of allocation extent descriptors;
one AED is placed on another inode's file entry, and a later one is
placed on the block of the AED currently being filled, which
udf_setup_indirect_aext() zeroes, so __udf_add_aext() finds
lengthAllocDescs out of step with its cursor.  In the second, an AED
is placed past the end of the device, sb_getblk() fails, and the error
path of udf_do_extend_file() calls udf_truncate_extents() on an extent
list that no longer covers i_size.

Keep the type separately from the length, as udf_table_prealloc_blocks()
already does.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Reported-by: syzbot+799a0e744ac47f928024@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=799a0e744ac47f928024
Reported-by: syzbot+43fc5ba6dcb33e3261ca@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=43fc5ba6dcb33e3261ca
Signed-off-by: Matthias Goergens &lt;matthias.goergens@gmail.com&gt;
Link: https://patch.msgid.link/6b51c38d2d069544053c542470950e2a448b0b8d.1793349907.git.matthias.goergens@gmail.com
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
udf_table_new_block() takes the first block of the free-space table
extent closest to the goal.  It keeps that extent's type and length
together in goal_elen, subtracts one block, and deletes the extent only
if goal_elen then reaches zero.  UDF 2.60 section 2.3.7.1 requires the
free-space extents of an Unallocated Space Entry to be of type 1
(allocated but not recorded), and mkudffs writes them that way.  For
such an extent the type bits keep goal_elen non-zero, so taking its last
block leaves a type-1 extent of length zero behind, starting at the
block after the extent, which is in use.

The next allocation that picks this empty extent returns that in-use
block.  Subtracting a block from 0x40000000 then borrows from the type
bits, and the extent becomes type 0 with a length of 2^30 - blocksize:
about a gigabyte of "free" space overlapping live metadata, the other
table extents and whatever lies behind the partition.  From then on
blocks are handed out twice, or past the end of the partition.

Extents that udf_table_free_blocks() adds are type 0, where the check
works, so only tables written by mkudffs or by another implementation
are affected.  Nothing more than filling such a filesystem is needed:
on a fresh 1 MiB "mkudffs --space=unalloctable" image, creating empty
files until the partition is full writes file entries over the reserve
volume descriptor sequence and the backup anchor, and df then reports a
negative amount of used space.

On syzbot's images the same double allocation is what the two reports
below trip over.  In the first, ftruncate() extends a new file with
enough hole extents to need a chain of allocation extent descriptors;
one AED is placed on another inode's file entry, and a later one is
placed on the block of the AED currently being filled, which
udf_setup_indirect_aext() zeroes, so __udf_add_aext() finds
lengthAllocDescs out of step with its cursor.  In the second, an AED
is placed past the end of the device, sb_getblk() fails, and the error
path of udf_do_extend_file() calls udf_truncate_extents() on an extent
list that no longer covers i_size.

Keep the type separately from the length, as udf_table_prealloc_blocks()
already does.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Reported-by: syzbot+799a0e744ac47f928024@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=799a0e744ac47f928024
Reported-by: syzbot+43fc5ba6dcb33e3261ca@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=43fc5ba6dcb33e3261ca
Signed-off-by: Matthias Goergens &lt;matthias.goergens@gmail.com&gt;
Link: https://patch.msgid.link/6b51c38d2d069544053c542470950e2a448b0b8d.1793349907.git.matthias.goergens@gmail.com
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>udf: Validate extended attribute space is large enough</title>
<updated>2026-10-26T13:19:22+00:00</updated>
<author>
<name>Jan Kara</name>
<email>jack@suse.cz</email>
</author>
<published>2026-10-23T08:41:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=0415c2624f8be6eac60de2b298de195dd18802d8'/>
<id>0415c2624f8be6eac60de2b298de195dd18802d8</id>
<content type='text'>
When there is extended attributes space in ICB, there must be at least
enough space for the header of this space. Otherwise the fs is corrupted
and other offset validity checks could underflow.

Reported-by: Lennart Finke &lt;lfinke@student.ethz.ch&gt;
Fixes: 127b0d87649f ("udf: Avoid confusion of missing and corrupted extended attributes")
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When there is extended attributes space in ICB, there must be at least
enough space for the header of this space. Otherwise the fs is corrupted
and other offset validity checks could underflow.

Reported-by: Lennart Finke &lt;lfinke@student.ethz.ch&gt;
Fixes: 127b0d87649f ("udf: Avoid confusion of missing and corrupted extended attributes")
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</pre>
</div>
</content>
</entry>
</feed>
