android_kernel_samsung_a7y1.../fs
Eric Biggers b263c13b62 libfs: fix infoleak in simple_attr_read()
commit a65cab7d7f05c2061a3e2490257d3086ff3202c6 upstream.

Reading from a debugfs file at a nonzero position, without first reading
at position 0, leaks uninitialized memory to userspace.

It's a bit tricky to do this, since lseek() and pread() aren't allowed
on these files, and write() doesn't update the position on them.  But
writing to them with splice() *does* update the position:

	#define _GNU_SOURCE 1
	#include <fcntl.h>
	#include <stdio.h>
	#include <unistd.h>
	int main()
	{
		int pipes[2], fd, n, i;
		char buf[32];

		pipe(pipes);
		write(pipes[1], "0", 1);
		fd = open("/sys/kernel/debug/fault_around_bytes", O_RDWR);
		splice(pipes[0], NULL, fd, NULL, 1, 0);
		n = read(fd, buf, sizeof(buf));
		for (i = 0; i < n; i++)
			printf("%02x", buf[i]);
		printf("\n");
	}

Output:
	5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a30

Fix the infoleak by making simple_attr_read() always fill
simple_attr::get_buf if it hasn't been filled yet.

Reported-by: syzbot+fcab69d1ada3e8d6f06b@syzkaller.appspotmail.com
Reported-by: Alexander Potapenko <glider@google.com>
Fixes: acaefc25d21f ("[PATCH] libfs: add simple attribute files")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20200308023849.988264-1-ebiggers@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-07 14:24:56 +02:00
..
9p
adfs
affs
afs
autofs4 autofs: fix a leak in autofs_expire_indirect() 2020-04-07 12:44:02 +02:00
befs
bfs
btrfs Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents 2020-04-07 14:03:50 +02:00
cachefiles
ceph ceph: fix dentry leak in ceph_readdir_prepopulate 2020-04-07 12:35:17 +02:00
cifs cifs: don't leak -EAGAIN for stat() during reconnect 2020-04-07 14:10:10 +02:00
coda
configfs configfs: fix a deadlock in configfs_symlink() 2020-04-07 11:49:08 +02:00
cramfs
crypto
debugfs
devpts
dlm dlm: fix invalid cluster name warning 2020-04-07 12:45:23 +02:00
ecryptfs ecryptfs: Fix up bad backport of fe2e082f5da5b4a0a92ae32978f81507ef37ec66 2020-04-07 14:04:54 +02:00
efivarfs
efs
exofs
exportfs exportfs: fix 'passing zero to ERR_PTR()' warning 2020-04-07 13:39:20 +02:00
ext2 ext2: Adjust indentation in ext2_fill_super 2020-04-07 13:50:47 +02:00
ext4 ext4: potential crash on allocation error in ext4_alloc_flex_bg_array() 2020-04-07 14:04:41 +02:00
f2fs
fat fat: fix uninit-memory access for partial initialized inode 2020-04-07 14:10:21 +02:00
freevxfs
fscache
fuse fs: prevent page refcount overflow in pipe_buf_get 2020-04-07 14:09:48 +02:00
gfs2 gfs2_atomic_open(): fix O_EXCL|O_CREAT handling on cold dcache 2020-04-07 14:11:36 +02:00
hfs fs/hfs/extent.c: fix array out of bounds read of array extent 2020-04-07 12:35:57 +02:00
hfsplus hfsplus: fix return value of hfsplus_get_block() 2020-04-07 12:35:53 +02:00
hostfs
hpfs
hugetlbfs
isofs
jbd2 jbd2: fix data races at struct journal_head 2020-04-07 14:13:37 +02:00
jffs2
jfs jfs: fix bogus variable self-initialization 2020-04-07 13:41:05 +02:00
kernfs kernfs: Fix range checks in kernfs_get_target_path 2020-04-07 12:28:12 +02:00
lockd
logfs
minix
ncpfs
nfs NFS: Remove superfluous kmap in nfs_readdir_xdr_to_array 2020-04-07 14:10:55 +02:00
nfs_common
nfsd nfsd: Return EPERM, not EACCES, in some SETATTR cases 2020-04-07 12:45:30 +02:00
nilfs2
nls
notify
ntfs
ocfs2 ocfs2: fix a NULL pointer dereference when call ocfs2_update_inode_fsync_trans() 2020-04-07 13:57:19 +02:00
omfs
openpromfs
overlayfs Revert "ovl: modify ovl_permission() to do checks on two inodes" 2020-04-07 13:49:58 +02:00
proc mm/page_alloc.c: calculate 'available' memory in a separate function 2020-04-07 13:36:28 +02:00
pstore pstore/ram: Write new dumps to start of recycled zones 2020-04-07 13:25:10 +02:00
qnx4
qnx6
quota fs/quota: handle overflows of sysctl fs.quota.* and report as unsigned long 2020-04-07 13:23:11 +02:00
ramfs
reiserfs reiserfs: prevent NULL pointer dereference in reiserfs_insert_item() 2020-04-07 13:57:23 +02:00
romfs
sdcardfs
sdfat
squashfs
sysfs
sysv
tracefs
ubifs ubifs: Fix deadlock in concurrent bulk-read and writepage 2020-04-07 13:55:10 +02:00
udf
ufs
xfs xfs: Sanity check flags of Q_XQUOTARM call 2020-04-07 13:39:05 +02:00
aio.c
anon_inodes.c
attr.c
bad_inode.c
binfmt_aout.c
binfmt_elf_fdpic.c
binfmt_elf.c
binfmt_em86.c
binfmt_flat.c
binfmt_misc.c
binfmt_script.c exec: load_script: Do not exec truncated interpreter path 2020-04-07 09:27:31 +02:00
block_dev.c
buffer.c
char_dev.c chardev: Avoid potential use-after-free in 'chrdev_open()' 2020-04-07 13:29:29 +02:00
compat_binfmt_elf.c
compat_ioctl.c
compat.c
coredump.c
dax.c
dcache.c fs/dcache: move security_d_instantiate() behind attaching dentry to inode 2020-04-07 09:57:56 +02:00
dcookies.c
direct-io.c
dlog_hook.c
drop_caches.c
eventfd.c
eventpoll.c
exec.c
fcntl.c
fhandle.c
file_table.c
file.c
filesystems.c
fs_pin.c
fs_struct.c
fs-writeback.c cgroup,writeback: don't switch wbs immediately on dead wbs if the memcg is dead 2020-04-07 11:58:54 +02:00
inode.c futex: Fix inode life-time issue 2020-04-07 14:17:43 +02:00
internal.h
ioctl.c
Kconfig
Kconfig.binfmt
libfs.c libfs: fix infoleak in simple_attr_read() 2020-04-07 14:24:56 +02:00
locks.c locks: print unsigned ino in /proc/locks 2020-04-07 13:24:39 +02:00
Makefile
mbcache.c
mount.h
mpage.c
namei.c namei: only return -ECHILD from follow_dotdot_rcu() 2020-04-07 14:05:00 +02:00
namespace.c
no-block.c
nsfs.c
open.c
pipe.c fs: prevent page refcount overflow in pipe_buf_get 2020-04-07 14:09:48 +02:00
pnode.c
pnode.h
posix_acl.c
proc_namespace.c
read_write.c
readdir.c filldir[64]: remove WARN_ON_ONCE() for bad directory entries 2020-04-07 13:23:50 +02:00
select.c
seq_file.c
signalfd.c
splice.c fs: prevent page refcount overflow in pipe_buf_get 2020-04-07 14:09:48 +02:00
stack.c
stat.c
statfs.c
super.c
sync.c
timerfd.c
userfaultfd.c
utimes.c
xattr.c