linux-stable/fs
Filipe Manana 33690eb1a8 btrfs: use u64 for buffer sizes in the tree search ioctls
[ Upstream commit dec96fc2dc ]

In the tree search v2 ioctl we use the type size_t, which is an unsigned
long, to track the buffer size in the local variable 'buf_size'. An
unsigned long is 32 bits wide on a 32 bits architecture. The buffer size
defined in struct btrfs_ioctl_search_args_v2 is a u64, so when we later
try to copy the local variable 'buf_size' to the argument struct, when
the search returns -EOVERFLOW, we copy only 32 bits which will be a
problem on big endian systems.

Fix this by using a u64 type for the buffer sizes, not only at
btrfs_ioctl_tree_search_v2(), but also everywhere down the call chain
so that we can use the u64 at btrfs_ioctl_tree_search_v2().

Fixes: cc68a8a5a4 ("btrfs: new ioctl TREE_SEARCH_V2")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/linux-btrfs/ce6f4bd6-9453-4ffe-ba00-cee35495e10f@moroto.mountain/
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 10:27:35 +01:00
..
9p 9p: missing chunk of "fs/9p: Don't update file type when updating file attributes" 2022-06-25 11:46:24 +02:00
adfs fs/adfs: super: fix use-after-free bug 2019-08-06 19:05:21 +02:00
affs affs: initialize fsdata in affs_truncate() 2023-02-06 07:46:28 +01:00
afs treewide: Remove uninitialized_var() usage 2023-08-11 11:33:32 +02:00
autofs4 autofs: fix memory leak of waitqueues in autofs_catatonic_mode 2023-09-23 10:47:03 +02:00
befs
bfs
btrfs btrfs: use u64 for buffer sizes in the tree search ioctls 2023-11-20 10:27:35 +01:00
cachefiles cachefiles: Handle readpage error correctly 2020-11-05 11:07:05 +01:00
ceph ceph: fix incorrect revoked caps assert in ceph_fill_file_size() 2023-10-25 11:13:30 +02:00
cifs cifs: add a warning when the in-flight count goes negative 2023-09-23 10:46:54 +02:00
coda coda: add error handling for fget 2019-08-06 19:05:23 +02:00
configfs configfs: fix a race in configfs_{,un}register_subsystem() 2022-03-02 11:33:56 +01:00
cramfs
crypto fscrypt: don't ignore minor_hash when hash is 0 2021-07-20 16:17:45 +02:00
debugfs debugfs: fix use-after-free on symlink traversal 2019-05-08 07:20:49 +02:00
devpts fs/devpts: always delete dcache dentry-s in dput() 2019-03-23 14:35:21 +01:00
dlm fs: dlm: return positive pid value for F_GETLK 2023-08-11 11:33:45 +02:00
ecryptfs Revert "ecryptfs: replace BUG_ON with error handling code" 2021-05-26 11:47:00 +02:00
efivarfs efivarfs: revert "fix memory leak in efivarfs_create()" 2020-12-02 08:34:44 +01:00
efs
exofs exofs_mount(): fix leaks on failure exits 2019-12-05 15:37:28 +01:00
exportfs exportfs: fix 'passing zero to ERR_PTR()' warning 2020-01-27 14:46:06 +01:00
ext2 ext2: fix datatype of block number in ext2_xattr_set2() 2023-09-23 10:47:04 +02:00
ext4 ext4: move 'ix' sanity check to corrent position 2023-11-20 10:27:34 +01:00
f2fs f2fs: fix to do sanity check on inode type during garbage collection 2023-11-08 11:21:07 +01:00
fat treewide: Remove uninitialized_var() usage 2023-08-11 11:33:32 +02:00
freevxfs
fscache fscache: fix race between enablement and dropping of object 2018-12-17 09:28:53 +01:00
fuse fuse: revalidate: don't invalidate if interrupted 2023-08-11 11:33:47 +02:00
gfs2 gfs2: Fix possible data races in gfs2_show_options() 2023-08-30 16:35:11 +02:00
hfs hfs: fix missing hfs_bnode_get() in __hfs_bnode_create 2023-03-11 16:26:44 +01:00
hfsplus treewide: Remove uninitialized_var() usage 2023-08-11 11:33:32 +02:00
hostfs
hpfs
hugetlbfs hugetlbfs: hugetlb_fault_mutex_hash() cleanup 2021-06-03 08:36:25 +02:00
isofs treewide: Remove uninitialized_var() usage 2023-08-11 11:33:32 +02:00
jbd2 jbd2: fix assertion 'jh->b_frozen_data == NULL' failure when journal aborted 2022-08-25 11:11:23 +02:00
jffs2 jffs2: reduce stack usage in jffs2_build_xattr_subsystem() 2023-08-11 11:33:41 +02:00
jfs jfs: fix invalid free of JFS_IP(ipimap)->i_imap in diUnmount 2023-09-23 10:47:04 +02:00
kernfs kernfs: fix use-after-free in __kernfs_remove 2022-11-03 23:50:53 +09:00
lockd fs: lockd: avoid possible wrong NULL parameter 2023-09-23 10:46:57 +02:00
minix fs/minix: reject too-large maximum file size 2020-08-21 09:48:15 +02:00
ncpfs
nfs NFS: Don't call generic_error_remove_page() while holding locks 2023-11-08 11:21:06 +01:00
nfs_common nfs_common: need lock during iterate through the list 2020-12-29 13:47:01 +01:00
nfsd nfsd: lock_rename() needs both directories to live on the same fs 2023-11-08 11:21:07 +01:00
nilfs2 nilfs2: fix potential use after free in nilfs_gccache_submit_read_data() 2023-10-10 21:43:40 +02:00
nls fs/nls: make load_nls() take a const parameter 2023-09-23 10:46:53 +02:00
notify fsnotify: fix wrong lockdep annotations 2022-06-14 16:53:48 +02:00
ntfs ntfs: check overflow when iterating ATTR_RECORDs 2022-11-25 17:36:55 +01:00
ocfs2 fs: ocfs2: namei: check return value of ocfs2_add_entry() 2023-09-23 10:46:55 +02:00
omfs treewide: Remove uninitialized_var() usage 2023-08-11 11:33:32 +02:00
openpromfs
orangefs orangefs: Fix kmemleak in orangefs_prepare_debugfs_help_string() 2023-01-18 09:26:33 +01:00
overlayfs overlayfs: set ctime when setting mtime and atime 2023-10-25 11:13:32 +02:00
proc procfs: block chmod on /proc/thread-self/comm 2023-09-23 10:47:00 +02:00
pstore pstore/ram: Check start of empty przs during init 2023-09-23 10:47:01 +02:00
qnx4 qnx4: work around gcc false positive warning bug 2021-10-06 15:05:08 +02:00
qnx6
quota quota: fix warning in dqgrab() 2023-08-30 16:35:09 +02:00
ramfs ramfs: fix nommu mmap with gaps in the page cache 2020-10-29 09:07:11 +01:00
reiserfs reiserfs: Check the return value from __getblk() 2023-09-23 10:46:54 +02:00
romfs romfs: fix uninitialized memory leak in romfs_dev_read() 2020-08-26 10:29:54 +02:00
squashfs revert "squashfs: harden sanity check in squashfs_read_xattr_id_table" 2023-02-22 12:46:05 +01:00
sysfs fs: sysfs_emit_at: Remove PAGE_SIZE alignment check 2023-03-22 13:26:13 +01:00
sysv fs/sysv: Null check to prevent null-ptr-deref bug 2023-08-11 11:33:56 +02:00
tracefs tracefs: Only clobber mode/uid/gid on remount if asked 2022-09-20 11:51:31 +02:00
ubifs treewide: Remove uninitialized_var() usage 2023-08-11 11:33:32 +02:00
udf udf: Handle error when adding extent to a file 2023-09-23 10:46:54 +02:00
ufs fs/ufs: avoid potential u32 multiplication overflow 2020-08-21 09:48:22 +02:00
xfs treewide: Remove uninitialized_var() usage 2023-08-11 11:33:32 +02:00
aio.c aio: fix mremap after fork null-deref 2023-02-22 12:46:05 +01:00
anon_inodes.c
attr.c attr: block mode changes of symlinks 2023-09-23 10:47:05 +02:00
bad_inode.c
binfmt_aout.c
binfmt_elf.c fs/binfmt_elf.c: allocate initialized memory in fill_thread_core_info() 2020-06-03 08:18:03 +02:00
binfmt_elf_fdpic.c fs: binfmt_elf_efpic: fix personality for ELF-FDPIC 2023-10-10 21:43:40 +02:00
binfmt_em86.c
binfmt_flat.c binfmt_flat: do not stop relocating GOT entries prematurely on riscv 2022-06-14 16:53:43 +02:00
binfmt_misc.c binfmt_misc: fix shift-out-of-bounds in check_special_flags 2023-01-18 09:26:29 +01:00
binfmt_script.c exec: load_script: Do not exec truncated interpreter path 2019-11-06 12:42:59 +01:00
block_dev.c block: reexpand iov_iter after read/write 2021-05-22 10:57:43 +02:00
buffer.c mm: fs: initialize fsdata passed to write_begin/write_end interface 2022-11-25 17:36:55 +01:00
char_dev.c chardev: fix error handling in cdev_device_add() 2023-01-18 09:26:24 +01:00
compat.c
compat_binfmt_elf.c
compat_ioctl.c fix compat handling of FICLONERANGE, FIDEDUPERANGE and FS_IOC_FIEMAP 2020-01-09 10:17:58 +01:00
coredump.c coredump: fix crash when umh is disabled 2020-05-20 08:16:58 +02:00
dax.c dax: pass NOWAIT flag to iomap_apply 2020-03-11 18:02:43 +01:00
dcache.c fs/dcache: Fix incorrect nr_dentry_unused accounting in shrink_dcache_sb() 2019-02-06 17:31:34 +01:00
dcookies.c
direct-io.c fs: direct-io: fix missing sdio->boundary 2021-04-16 11:57:48 +02:00
drop_caches.c fs: avoid softlockups in s_inodes iterators 2020-01-12 12:11:59 +01:00
eventfd.c
eventpoll.c ep_create_wakeup_source(): dentry name can change under you... 2020-10-14 09:51:09 +02:00
exec.c exec: Force single empty string when argv is empty 2022-06-06 08:20:57 +02:00
fcntl.c
fhandle.c
file.c fs: prevent out-of-bounds array speculation when closing a file descriptor 2023-03-17 08:30:36 +01:00
file_table.c fs: add fget_many() and fput_many() 2021-12-08 08:46:55 +01:00
filesystems.c fs/filesystems.c: downgrade user-reachable WARN_ONCE() to pr_warn_once() 2020-04-24 08:00:43 +02:00
fs-writeback.c writeback: fix call of incorrect macro 2023-05-17 11:11:48 +02:00
fs_pin.c
fs_struct.c
inode.c fs: fix UAF/GPF bug in nilfs_mdt_destroy 2022-10-26 13:16:51 +02:00
internal.h
ioctl.c
iomap.c iomap: Fix pipe page leakage during splicing 2019-12-17 20:38:57 +01:00
Kconfig
Kconfig.binfmt
libfs.c libfs: add DEFINE_SIMPLE_ATTRIBUTE_SIGNED for signed value 2023-01-18 09:26:10 +01:00
locks.c locks: print unsigned ino in /proc/locks 2020-01-09 10:17:55 +01:00
Makefile
mbcache.c
mount.h
mpage.c
namei.c fs: Fix error checking for d_hash_and_lookup() 2023-09-23 10:46:54 +02:00
namespace.c VFS: Fix memory leak caused by concurrently mounting fs with subtype 2022-05-15 19:40:27 +02:00
no-block.c
nsfs.c
open.c cifs_atomic_open(): fix double-put on late allocation failure 2020-03-20 10:54:16 +01:00
pipe.c pipe: increase minimum default pipe size to 2 pages 2021-08-15 13:03:31 +02:00
pnode.c pnode: terminate at peers of source 2023-01-18 09:26:35 +01:00
pnode.h
posix_acl.c
proc_namespace.c
read_write.c vfs: avoid problematic remapping requests into partial EOF block 2019-12-01 09:13:51 +01:00
readdir.c readdir: make sure to verify directory entry for legacy interfaces too 2021-04-28 12:08:41 +02:00
select.c kernel, fs: Introduce and use set_restart_fn() and arch_set_restart_data() 2021-03-24 11:05:05 +01:00
seq_file.c seq_file: disallow extremely large seq buffer allocations 2021-07-20 16:17:55 +02:00
signalfd.c signalfd: use wake_up_pollfree() 2021-12-14 10:16:55 +01:00
splice.c Revert "fs: check FMODE_LSEEK to control internal pipe splicing" 2022-10-26 13:16:56 +02:00
stack.c
stat.c stat: fix inconsistency between struct stat and struct compat_stat 2022-04-27 13:15:30 +02:00
statfs.c statfs: enforce statfs[64] structure initialization 2023-05-30 12:38:36 +01:00
super.c vfs: make freeze_super abort when sync_filesystem returns error 2022-02-23 11:57:33 +01:00
sync.c
timerfd.c
userfaultfd.c userfaultfd: require CAP_SYS_PTRACE for UFFD_FEATURE_EVENT_FORK 2020-01-04 13:59:58 +01:00
utimes.c
xattr.c fs: don't audit the capability check in simple_xattr_list() 2023-01-18 09:26:09 +01:00