linux-stable/fs
ZhangPeng 7af9cb8cbb hfs: Fix OOB Write in hfs_asc2mac
[ Upstream commit c53ed55cb2 ]

Syzbot reported a OOB Write bug:

loop0: detected capacity change from 0 to 64
==================================================================
BUG: KASAN: slab-out-of-bounds in hfs_asc2mac+0x467/0x9a0
fs/hfs/trans.c:133
Write of size 1 at addr ffff88801848314e by task syz-executor391/3632

Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106
 print_address_description+0x74/0x340 mm/kasan/report.c:284
 print_report+0x107/0x1f0 mm/kasan/report.c:395
 kasan_report+0xcd/0x100 mm/kasan/report.c:495
 hfs_asc2mac+0x467/0x9a0 fs/hfs/trans.c:133
 hfs_cat_build_key+0x92/0x170 fs/hfs/catalog.c:28
 hfs_lookup+0x1ab/0x2c0 fs/hfs/dir.c:31
 lookup_open fs/namei.c:3391 [inline]
 open_last_lookups fs/namei.c:3481 [inline]
 path_openat+0x10e6/0x2df0 fs/namei.c:3710
 do_filp_open+0x264/0x4f0 fs/namei.c:3740

If in->len is much larger than HFS_NAMELEN(31) which is the maximum
length of an HFS filename, a OOB write could occur in hfs_asc2mac(). In
that case, when the dst reaches the boundary, the srclen is still
greater than 0, which causes a OOB write.
Fix this by adding a check on dstlen in while() before writing to dst
address.

Link: https://lkml.kernel.org/r/20221202030038.1391945-1-zhangpeng362@huawei.com
Fixes: 328b922786 ("[PATCH] hfs: NLS support")
Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
Reviewed-by: Viacheslav Dubeyko <slava@dubeyko.com>
Reported-by: <syzbot+dc3b1cf9111ab5fe98e7@syzkaller.appspotmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-12-31 13:14:05 +01:00
..
9p 9p: fix a bunch of checkpatch warnings 2022-08-17 14:24:07 +02:00
adfs
affs
afs afs: Fix fileserver probe RTT handling 2022-12-08 11:28:41 +01:00
autofs
befs
bfs
btrfs btrfs: send: avoid unaligned encoded writes when attempting to clone range 2022-12-14 11:37:16 +01:00
cachefiles fs: add is_idmapped_mnt() helper 2022-07-02 16:41:14 +02:00
ceph ceph: fix NULL pointer dereference for req->r_session 2022-12-02 17:41:01 +01:00
cifs cifs: fix use-after-free caused by invalid pointer hostname 2022-12-14 11:37:18 +01:00
coda
configfs
cramfs
crypto fscrypt: fix keyring memory leak on mount failure 2022-11-10 18:15:37 +01:00
debugfs debugfs: fix error when writing negative value to atomic_t debugfs file 2022-12-31 13:14:03 +01:00
devpts
dlm fs: dlm: fix invalid derefence of sb_lvbptr 2022-10-29 10:12:57 +02:00
ecryptfs fs: add is_idmapped_mnt() helper 2022-07-02 16:41:14 +02:00
efivarfs
efs
erofs erofs: fix order >= MAX_ORDER warning due to crafted negative i_size 2022-12-08 11:28:37 +01:00
exfat exfat: use updated exfat_chain directly during renaming 2022-07-29 17:25:30 +02:00
exportfs exportfs: support idmapped mounts 2022-06-09 10:23:32 +02:00
ext2 ext2: Use kvmalloc() for group descriptor array 2022-10-26 12:35:51 +02:00
ext4 ext4: fix use-after-free in ext4_ext_shift_extents 2022-12-02 17:41:08 +01:00
f2fs ext4,f2fs: fix readahead of verity data 2022-11-10 18:15:42 +01:00
fat fat: add ratelimit to fat*_ent_bread() 2022-06-09 10:22:42 +02:00
freevxfs
fscache
fuse fuse: lock inode unconditionally in fuse_fallocate() 2022-12-02 17:41:11 +01:00
gfs2 gfs2: Switch from strlcpy to strscpy 2022-11-26 09:24:51 +01:00
hfs hfs: Fix OOB Write in hfs_asc2mac 2022-12-31 13:14:05 +01:00
hfsplus
hostfs
hpfs
hugetlbfs hugetlbfs: don't delete error page from pagecache 2022-11-26 09:24:33 +01:00
iomap iomap: iomap_write_failed fix 2022-06-09 10:22:55 +02:00
isofs
jbd2 jbd2: add miss release buffer head in fc_do_one_pass() 2022-10-26 12:34:28 +02:00
jffs2 jffs2: fix memory leak in jffs2_do_fill_super 2022-06-14 18:36:10 +02:00
jfs fs: jfs: fix possible NULL pointer dereference in dbFree() 2022-06-09 10:22:41 +02:00
kernfs kernfs: fix use-after-free in __kernfs_remove 2022-11-03 23:59:13 +09:00
ksmbd vfs: fix copy_file_range() averts filesystem freeze protection 2022-12-19 12:36:39 +01:00
lockd lockd: set other missing fields when unlocking files 2022-12-31 13:14:05 +01:00
minix
netfs
nfs NFSv4: Retry LOCK on OLD_STATEID during delegation return 2022-11-26 09:24:31 +01:00
nfs_common
nfsd nfsd: don't call nfsd_file_put from client states seqfile display 2022-12-31 13:14:03 +01:00
nilfs2 nilfs2: fix NULL pointer dereference in nilfs_palloc_commit_free_entry() 2022-12-08 11:28:42 +01:00
nls
notify fsnotify: fix wrong lockdep annotations 2022-06-09 10:22:50 +02:00
ntfs ntfs: check overflow when iterating ATTR_RECORDs 2022-11-26 09:24:52 +01:00
ntfs3 ntfs3: rework xattr handlers and switch to POSIX ACL VFS helpers 2022-10-26 12:34:36 +02:00
ocfs2 ocfs2: fix memory leak in ocfs2_stack_glue_init() 2022-12-31 13:14:02 +01:00
omfs
openpromfs
orangefs
overlayfs ovl: remove privs in ovl_fallocate() 2022-12-31 13:14:00 +01:00
proc mm: /proc/pid/smaps_rollup: fix no vma's null-deref 2022-10-29 10:12:58 +02:00
pstore pstore: Avoid kcore oops by vmap()ing with VM_IOREMAP 2022-12-31 13:14:00 +01:00
qnx4
qnx6
quota quota: Check next/prev free block number after reading from quota file 2022-10-26 12:34:21 +02:00
ramfs
reiserfs
romfs
smbfs_common
squashfs
sysfs
sysv fs: sysv: Fix sysv_nblocks() returns wrong value 2022-12-31 13:14:05 +01:00
tracefs tracefs: Only clobber mode/uid/gid on remount if asked 2022-09-20 12:39:43 +02:00
ubifs
udf udf: Fix extending file within last block 2022-12-21 17:36:36 +01:00
ufs
unicode
vboxsf
verity
xfs fs: record I_DIRTY_TIME even if inode already has I_DIRTY_INODE 2022-10-26 12:34:27 +02:00
zonefs zonefs: fix zone report size in __zonefs_io_error() 2022-12-02 17:41:10 +01:00
aio.c
anon_inodes.c
attr.c vfs: Check the truncate maximum size in inode_newsize_ok() 2022-08-17 14:22:50 +02:00
bad_inode.c
binfmt_aout.c
binfmt_elf.c fs/binfmt_elf: Fix memory leak in load_elf_binary() 2022-11-03 23:59:12 +09:00
binfmt_elf_fdpic.c
binfmt_flat.c binfmt_flat: do not stop relocating GOT entries prematurely on riscv 2022-06-09 10:22:26 +02:00
binfmt_misc.c
binfmt_script.c
buffer.c mm: fs: initialize fsdata passed to write_begin/write_end interface 2022-11-26 09:24:51 +01:00
char_dev.c
compat_binfmt_elf.c
coredump.c
d_path.c
dax.c fsdax: Fix infinite loop in dax_iomap_rw() 2022-09-28 11:11:56 +02:00
dcache.c
direct-io.c
drop_caches.c
eventfd.c eventfd: guard wake_up in eventfd fs calls as well 2022-10-26 12:35:49 +02:00
eventpoll.c epoll: autoremove wakers even more aggressively 2022-08-17 14:22:59 +02:00
exec.c exec: Copy oldsighand->action under spin-lock 2022-11-03 23:59:12 +09:00
fcntl.c
fhandle.c
file.c fs: use acquire ordering in __fget_light() 2022-12-14 11:37:15 +01:00
file_table.c locks: fix TOCTOU race when granting write lease 2022-10-26 12:34:58 +02:00
filesystems.c
fs-writeback.c fs: do not update freeing inode i_io_list 2022-12-02 17:41:07 +01:00
fs_context.c
fs_parser.c
fs_pin.c
fs_struct.c
fs_types.c
fsopen.c
init.c
inode.c fs: fix UAF/GPF bug in nilfs_mdt_destroy 2022-10-12 09:53:26 +02:00
internal.h locks: fix TOCTOU race when granting write lease 2022-10-26 12:34:58 +02:00
ioctl.c
Kconfig
Kconfig.binfmt
kernel_read_file.c
libfs.c libfs: add DEFINE_SIMPLE_ATTRIBUTE_SIGNED for signed value 2022-12-31 13:14:03 +01:00
locks.c
Makefile io_uring: move to separate directory 2022-12-14 11:37:31 +01:00
mbcache.c mbcache: add functions to delete entry if unused 2022-08-17 14:22:57 +02:00
mount.h
mpage.c
namei.c mm: fs: initialize fsdata passed to write_begin/write_end interface 2022-11-26 09:24:51 +01:00
namespace.c fs: require CAP_SYS_ADMIN in target namespace for idmapped mounts 2022-08-31 17:16:37 +02:00
no-block.c
nsfs.c
open.c locks: fix TOCTOU race when granting write lease 2022-10-26 12:34:58 +02:00
pipe.c
pnode.c
pnode.h
posix_acl.c fs: fix acl translation 2022-07-02 16:41:17 +02:00
proc_namespace.c fs: add is_idmapped_mnt() helper 2022-07-02 16:41:14 +02:00
read_write.c vfs: fix copy_file_range() averts filesystem freeze protection 2022-12-19 12:36:39 +01:00
readdir.c
remap_range.c fs/remap: constrain dedupe of EOF blocks 2022-07-21 21:24:14 +02:00
select.c
seq_file.c rxrpc: Fix locking issue 2022-07-12 16:35:08 +02:00
signalfd.c
splice.c Revert "fs: check FMODE_LSEEK to control internal pipe splicing" 2022-10-26 12:34:17 +02:00
stack.c
stat.c
statfs.c
super.c fscrypt: fix keyring memory leak on mount failure 2022-11-10 18:15:37 +01:00
sync.c
timerfd.c
userfaultfd.c userfaultfd: open userfaultfds with O_RDONLY 2022-10-26 12:34:36 +02:00
utimes.c
xattr.c fs: don't audit the capability check in simple_xattr_list() 2022-12-31 13:14:01 +01:00