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)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 25 Aug 2017 02:29:09 +0000 (22:29 -0400)
commit6a8dadcca81fceff9976e8828cceb072873b7bd5
tree6a9cb8566b1554f8aaafd81fabce9cfc20122490
parent8d26f491116feaa0b16de370b6a7ba40a40fa0b4
scsi: sg: protect against races between mmap() and SG_SET_RESERVED_SIZE

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>
drivers/scsi/sg.c