]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
floppy: fix out-of-bounds read in copy_buffer
authorDenis Efremov <efremov@ispras.ru>
Fri, 12 Jul 2019 18:55:23 +0000 (21:55 +0300)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 13 Aug 2019 11:39:27 +0000 (12:39 +0100)
commit05429983fa0fa3bfa1b8436beb63913d9d4aad1a
treeecaf78b0621fc27d7dfd1eeba98a93a71a1c1209
parentfbf6a95d0a3d410ee2f4530e243b77beee87c76a
floppy: fix out-of-bounds read in copy_buffer

commit da99466ac243f15fbba65bd261bfc75ffa1532b6 upstream.

This fixes a global out-of-bounds read access in the copy_buffer
function of the floppy driver.

The FDDEFPRM ioctl allows one to set the geometry of a disk.  The sect
and head fields (unsigned int) of the floppy_drive structure are used to
compute the max_sector (int) in the make_raw_rw_request function.  It is
possible to overflow the max_sector.  Next, max_sector is passed to the
copy_buffer function and used in one of the memcpy calls.

An unprivileged user could trigger the bug if the device is accessible,
but requires a floppy disk to be inserted.

The patch adds the check for the .sect * .head multiplication for not
overflowing in the set_geometry function.

The bug was found by syzkaller.

Signed-off-by: Denis Efremov <efremov@ispras.ru>
Tested-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/block/floppy.c