summaryrefslogtreecommitdiff
path: root/kernel/relay.c
diff options
context:
space:
mode:
authorJann Horn <jannh@google.com>2020-08-21 03:42:11 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2020-08-21 19:52:53 +0300
commitbcf85fcedfdd17911982a3e3564fcfec7b01eebd (patch)
treeb44bac429bb2f43419a827fc5a1e824f4d08f49e /kernel/relay.c
parent86f54bb7e4ff22ad5dd0b1e179610cc8bbb3bd63 (diff)
downloadlinux-bcf85fcedfdd17911982a3e3564fcfec7b01eebd.tar.xz
romfs: fix uninitialized memory leak in romfs_dev_read()
romfs has a superblock field that limits the size of the filesystem; data beyond that limit is never accessed. romfs_dev_read() fetches a caller-supplied number of bytes from the backing device. It returns 0 on success or an error code on failure; therefore, its API can't represent short reads, it's all-or-nothing. However, when romfs_dev_read() detects that the requested operation would cross the filesystem size limit, it currently silently truncates the requested number of bytes. This e.g. means that when the content of a file with size 0x1000 starts one byte before the filesystem size limit, ->readpage() will only fill a single byte of the supplied page while leaving the rest uninitialized, leaking that uninitialized memory to userspace. Fix it by returning an error code instead of truncating the read when the requested read operation would go beyond the end of the filesystem. Fixes: da4458bda237 ("NOMMU: Make it possible for RomFS to use MTD devices directly") Signed-off-by: Jann Horn <jannh@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: David Howells <dhowells@redhat.com> Cc: <stable@vger.kernel.org> Link: http://lkml.kernel.org/r/20200818013202.2246365-1-jannh@google.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/relay.c')
0 files changed, 0 insertions, 0 deletions