]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
scsi: sg: protect against races between mmap() and SG_SET_RESERVED_SIZE
authorTodd Poynor <toddpoynor@google.com>
Wed, 16 Aug 2017 05:41:08 +0000 (22:41 -0700)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 11 Jun 2020 18:05:44 +0000 (19:05 +0100)
commitfaf0e0de9c4f9ab9b80e1396128c9c804af09fe2
treebcac57b81812f7c0f4b941c5114fa0efd2396666
parent6c9fe95373f5ac073c657d31beb369df0f14db60
scsi: sg: protect against races between mmap() and SG_SET_RESERVED_SIZE

commit 6a8dadcca81fceff9976e8828cceb072873b7bd5 upstream.

Take f_mutex around mmap() processing to protect against races with the
SG_SET_RESERVED_SIZE ioctl.  Ensure the reserve buffer length remains
consistent during the mapping operation, and set the "mmap called" flag
to prevent further changes to the reserved buffer size as an atomic
operation with the mapping.

[mkp: fixed whitespace]

Signed-off-by: Todd Poynor <toddpoynor@google.com>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/scsi/sg.c