linux-yocto/fs
Qu Wenruo 3ea252a5c4 btrfs: fix symbolic link reading when bs > ps
[ Upstream commit 67378b7546 ]

[BUG DURING BS > PS TEST]
When running the following script on a btrfs whose block size is larger
than page size, e.g. 8K block size and 4K page size, it will trigger a
kernel BUG:

  # mkfs.btrfs -s 8k $dev
  # mount $dev $mnt
  # mkdir $mnt/dir
  # ln -s dir $mnt/link
  # ls $mnt/link

The call trace looks like this:

  BTRFS warning (device dm-2): support for block size 8192 with page size 4096 is experimental, some features may be missing
  BTRFS info (device dm-2): checking UUID tree
  BTRFS info (device dm-2): enabling ssd optimizations
  BTRFS info (device dm-2): enabling free space tree
  ------------[ cut here ]------------
  kernel BUG at /home/adam/linux/include/linux/highmem.h:275!
  Oops: invalid opcode: 0000 [#1] SMP
  CPU: 8 UID: 0 PID: 667 Comm: ls Tainted: G           OE       6.17.0-rc4-custom+ #283 PREEMPT(full)
  Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS unknown 02/02/2022
  RIP: 0010:zero_user_segments.constprop.0+0xdc/0xe0 [btrfs]
  Call Trace:
   <TASK>
   btrfs_get_extent.cold+0x85/0x101 [btrfs 7453c70c03e631c8d8bfdd4264fa62d3e238da6f]
   btrfs_do_readpage+0x244/0x750 [btrfs 7453c70c03e631c8d8bfdd4264fa62d3e238da6f]
   btrfs_read_folio+0x9c/0x100 [btrfs 7453c70c03e631c8d8bfdd4264fa62d3e238da6f]
   filemap_read_folio+0x37/0xe0
   do_read_cache_folio+0x94/0x3e0
   __page_get_link.isra.0+0x20/0x90
   page_get_link+0x16/0x40
   step_into+0x69b/0x830
   path_lookupat+0xa7/0x170
   filename_lookup+0xf7/0x200
   ? set_ptes.isra.0+0x36/0x70
   vfs_statx+0x7a/0x160
   do_statx+0x63/0xa0
   __x64_sys_statx+0x90/0xe0
   do_syscall_64+0x82/0xae0
   entry_SYSCALL_64_after_hwframe+0x4b/0x53
   </TASK>

Please note bs > ps support is still under development and the
enablement patch is not even in btrfs development branch.

[CAUSE]
Btrfs reuses its data folio read path to handle symbolic links, as the
symbolic link target is stored as an inline data extent.

But for newly created inodes, btrfs only set the minimal order if the
target inode is a regular file.

Thus for above newly created symbolic link, it doesn't properly respect
the minimal folio order, and triggered the above crash.

[FIX]
Call btrfs_set_inode_mapping_order() unconditionally inside
btrfs_create_new_inode().

For symbolic links this will fix the crash as now the folio will meet
the minimal order.

For regular files this brings no change.

For directory/bdev/char and all the other types of inodes, they won't
go through the data read path, thus no effect either.

Fixes: cc38d178ff ("btrfs: enable large data folio support under CONFIG_BTRFS_EXPERIMENTAL")
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-10-15 12:03:18 +02:00
..
9p vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
adfs vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
affs vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
afs afs: Fix potential null pointer dereference in afs_put_server 2025-09-25 09:18:17 +02:00
autofs new helper: set_default_d_op() 2025-06-10 22:21:16 -04:00
bcachefs vfs-6.17-rc1.fileattr 2025-07-28 15:24:14 -07:00
befs
bfs vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
btrfs btrfs: fix symbolic link reading when bs > ps 2025-10-15 12:03:18 +02:00
cachefiles vfs-6.17-rc1.misc 2025-07-28 11:22:56 -07:00
ceph ceph: fix crash after fscrypt_encrypt_pagecache_blocks() error 2025-09-09 12:57:03 +02:00
coda vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
configfs configfs: use DCACHE_DONTCACHE 2025-06-11 13:41:05 -04:00
cramfs mm: remove callers of pfn_t functionality 2025-07-09 22:42:19 -07:00
crypto fscrypt: Remove gfp_t argument from fscrypt_encrypt_block_inplace() 2025-07-10 12:33:13 -07:00
debugfs debugfs: fix mount options not being applied 2025-08-17 12:22:25 +02:00
devpts devpts, sunrpc, hostfs: don't bother with ->d_op 2025-06-11 13:40:04 -04:00
dlm treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
ecryptfs vfs-6.17-rc1.fileattr 2025-07-28 15:24:14 -07:00
efivarfs efivarfs: Fix slab-out-of-bounds in efivarfs_d_compare 2025-08-28 08:39:49 +02:00
efs
erofs erofs: avoid reading more for fragment maps 2025-10-15 12:03:16 +02:00
exfat exfat: add cluster chain loop check for dir 2025-08-01 08:34:23 +09:00
exportfs exportfs: use lookup_one_unlocked() 2025-06-11 13:44:15 +02:00
ext2 \n 2025-07-28 16:16:09 -07:00
ext4 Ext4 bug fixes and cleanups for 6.17-rc3, including most notably: 2025-08-18 09:01:00 -07:00
f2fs f2fs: fix to do sanity check on node footer for non inode dnode 2025-10-12 13:01:57 +02:00
fat Significant patch series in this pull request: 2025-08-03 16:23:09 -07:00
freevxfs
fuse fuse: virtio_fs: fix page fault for DAX page address 2025-09-05 15:56:30 +02:00
gfs2 gfs2: Add proper lockspace locking 2025-10-15 12:03:15 +02:00
hfs hfs/hfsplus updates for v6.17 2025-07-28 16:17:44 -07:00
hfsplus hfsplus: fix slab-out-of-bounds read in hfsplus_uni2asc() 2025-10-15 12:03:14 +02:00
hostfs vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
hpfs vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
hugetlbfs mm/hugetlb: fix folio is still mapped when deleted 2025-09-25 16:10:34 -07:00
iomap iomap: Fix broken data integrity guarantees for O_SYNC writes 2025-08-11 14:51:49 +02:00
isofs Current exclusion rules for ->d_flags stores are rather unpleasant. 2025-07-28 09:17:57 -07:00
jbd2 jbd2: prevent softlockup in jbd2_log_do_checkpoint() 2025-08-13 14:24:14 -04:00
jffs2 vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
jfs Fixes and cleanups for JFS filesystem 2025-07-31 10:27:11 -07:00
kernfs kernfs: Fix UAF in polling when open file is released 2025-09-06 20:11:27 +02:00
lockd
minix vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
netfs netfs: fix reference leak 2025-09-26 10:14:19 +02:00
nfs NFSv4/flexfiles: Fix layout merge mirror check. 2025-09-08 14:37:55 -04:00
nfs_common NFS/localio: nfs_uuid_put() fix the wake up after unlinking the file 2025-08-05 16:45:40 -07:00
nfsd nfsd-6.17 fixes: 2025-08-11 07:38:55 -07:00
nilfs2 nilfs2: fix CFI failure when accessing /sys/fs/nilfs2/features/* 2025-09-13 13:05:38 -07:00
nls
notify \n 2025-07-31 10:31:00 -07:00
ntfs3 vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
ocfs2 ocfs2: fix recursive semaphore deadlock in fiemap call 2025-09-08 23:45:11 -07:00
omfs vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
openpromfs
orangefs orangefs: fixes for string handling in debugfs and sysfs 2025-07-31 10:22:48 -07:00
overlayfs ovl: fix possible double unlink 2025-08-18 13:16:49 +02:00
proc fs/proc/task_mmu: check p->vec_buf for NULL 2025-09-25 16:10:34 -07:00
pstore pstore: switch to locked_recursive_removal() 2025-07-02 22:36:51 -04:00
qnx4
qnx6
quota VFS: rename lookup_one_len family to lookup_noperm and remove permission check 2025-04-08 11:24:36 +02:00
ramfs vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
resctrl fs/resctrl: Eliminate false positive lockdep warning when reading SNC counters 2025-09-09 12:43:36 +02:00
romfs fs: replace mmap hook with .mmap_prepare for simple mappings 2025-06-19 13:56:59 +02:00
smb smb: server: fix IRD/ORD negotiation with the client 2025-10-15 12:03:16 +02:00
squashfs squashfs: fix memory leak in squashfs_fill_super 2025-08-19 16:35:53 -07:00
sysfs sysfs: constify internal references to 'struct bin_attribute' 2025-06-17 10:44:09 +02:00
tests
tracefs Massage rpc_pipefs to use saner primitives and clean up the 2025-07-28 09:56:09 -07:00
ubifs This pull request contains the following changes for UBI and UBIFS: 2025-07-31 10:08:44 -07:00
udf \n 2025-07-28 16:16:09 -07:00
ufs vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
unicode
vboxsf vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
verity fsverity: Switch from crypto_shash to SHA-2 library 2025-07-14 11:29:32 -07:00
xfs xfs: do not propagate ENODATA disk errors into xattr code 2025-08-26 11:00:33 +02:00
zonefs zonefs changes for 6.17-rc1 2025-07-28 17:06:51 -07:00
aio.c fs: replace mmap hook with .mmap_prepare for simple mappings 2025-06-19 13:56:59 +02:00
anon_inodes.c module: Rename EXPORT_SYMBOL_GPL_FOR_MODULES to EXPORT_SYMBOL_FOR_MODULES 2025-08-11 16:16:36 +02:00
attr.c docs/vfs: update references to i_mutex to i_rwsem 2025-06-23 12:17:33 +02:00
backing-file.c vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
bad_inode.c
binfmt_elf_fdpic.c execve updates for v6.17 2025-07-28 17:11:40 -07:00
binfmt_elf.c execve updates for v6.17 2025-07-28 17:11:40 -07:00
binfmt_flat.c
binfmt_misc.c binfmt_misc: switch to locked_recursive_removal() 2025-07-02 22:36:51 -04:00
binfmt_script.c
bpf_fs_kfuncs.c bpf: Introduce bpf_cgroup_read_xattr to read xattr of cgroup's node 2025-07-02 14:18:20 +02:00
buffer.c fs/buffer: fix use-after-free when call bh_read() helper 2025-08-19 13:51:28 +02:00
char_dev.c
compat_binfmt_elf.c
coredump.c coredump: don't pointlessly check and spew warnings 2025-08-21 13:54:40 +02:00
d_path.c fold fs_struct->{lock,seq} into a seqlock 2025-07-08 10:25:19 +02:00
dax.c fs/dax: Reject IOCB_ATOMIC in dax_iomap_rw() 2025-08-11 14:03:38 +02:00
dcache.c vfs-6.17-rc1.misc 2025-07-28 11:22:56 -07:00
direct-io.c Summary of significant series in this pull request: 2025-07-31 14:57:54 -07:00
drop_caches.c
eventfd.c
eventpoll.c vfs-6.17-rc1.misc 2025-07-28 11:22:56 -07:00
exec.c coredump: don't pointlessly check and spew warnings 2025-08-21 13:54:40 +02:00
fcntl.c
fhandle.c fhandle: use more consistent rules for decoding file handle from userns 2025-08-29 09:48:31 +02:00
file_attr.c fs: tighten a sanity check in file_attr_to_fileattr() 2025-07-16 10:22:01 +02:00
file_table.c \n 2025-07-31 10:31:00 -07:00
file.c vfs-6.17-rc1.misc 2025-07-28 11:22:56 -07:00
filesystems.c fs/filesystems: Fix potential unsigned integer underflow in fs_name() 2025-04-14 13:05:59 +02:00
fs_context.c fs/fs_context: Mark an unlikely if condition with unlikely() in vfs_parse_monolithic_sep() 2025-04-14 13:05:59 +02:00
fs_parser.c fs/fs_parse: Remove unused and problematic validate_constant_table() 2025-04-21 10:27:59 +02:00
fs_pin.c
fs_struct.c fold fs_struct->{lock,seq} into a seqlock 2025-07-08 10:25:19 +02:00
fs_types.c
fs-writeback.c fs: writeback: fix use-after-free in __mark_inode_dirty() 2025-08-11 14:51:45 +02:00
fsopen.c
init.c
inode.c vfs: Remove unnecessary list_for_each_entry_safe() from evict_inodes() 2025-07-10 09:37:32 +02:00
internal.h vfs-6.17-rc1.pidfs 2025-07-28 14:10:15 -07:00
ioctl.c fs: split fileattr related helpers into separate file 2025-07-01 22:44:22 +02:00
Kconfig fs/Kconfig: enable HUGETLBFS only if ARCH_SUPPORTS_HUGETLBFS 2025-07-24 19:12:38 -07:00
Kconfig.binfmt
kernel_read_file.c
libfs.c vfs-6.17-rc1.pidfs 2025-07-28 14:10:15 -07:00
locks.c docs/vfs: update references to i_mutex to i_rwsem 2025-06-23 12:17:33 +02:00
Makefile fs: split fileattr related helpers into separate file 2025-07-01 22:44:22 +02:00
mbcache.c
mnt_idmapping.c
mount.h copy_tree(): don't link the mounts via mnt_list 2025-06-29 19:03:37 -04:00
mpage.c fs: use writeback_iter directly in mpage_writepages 2025-05-09 12:37:48 +02:00
namei.c vfs-6.17-rc1.pidfs 2025-07-28 14:10:15 -07:00
namespace.c fs: fix indentation style 2025-08-21 10:27:05 +02:00
nsfs.c vfs-6.15-rc1.nsfs 2025-03-24 11:38:12 -07:00
open.c \n 2025-07-31 10:31:00 -07:00
pidfs.c pidfs: Fix memory leak in pidfd_info() 2025-08-15 16:10:46 +02:00
pipe.c fs/pipe: set FMODE_NOWAIT in create_pipe_files() 2025-06-10 13:16:19 +02:00
pnode.c change_mnt_propagation(): calculate propagation source only if we'll need it 2025-08-19 12:05:59 -04:00
pnode.h get rid of CL_SHARE_TO_SLAVE 2025-06-29 19:03:46 -04:00
posix_acl.c
proc_namespace.c ->mnt_devname is never NULL 2025-05-23 14:20:44 +02:00
read_write.c vfs-6.17-rc1.mmap_prepare 2025-07-28 13:43:25 -07:00
readdir.c readdir: supply dir_context.count as readdir buffer size hint 2025-05-29 12:31:23 +02:00
remap_range.c
select.c fs: annotate suspected data race between poll_schedule_timeout() and pollwake() 2025-06-23 12:36:51 +02:00
seq_file.c
signalfd.c
splice.c netfs: Fix unbuffered write error handling 2025-08-15 15:56:49 +02:00
stack.c docs/vfs: update references to i_mutex to i_rwsem 2025-06-23 12:17:33 +02:00
stat.c xfs: New code for 6.16 2025-05-26 12:56:01 -07:00
statfs.c
super.c vfs-6.17-rc1.super 2025-07-28 15:50:15 -07:00
sync.c
sysctls.c
timerfd.c A treewide hrtimer timer cleanup 2025-03-25 10:54:15 -07:00
userfaultfd.c mm/mremap: use an explicit uffd failure path for mremap 2025-07-24 19:12:29 -07:00
utimes.c
xattr.c vfs-6.17-rc1.misc 2025-07-28 11:22:56 -07:00