]> git.baikalelectronics.ru Git - kernel.git/commit
compat: scsi: sg: fix v3 compat read/write interface
authorArnd Bergmann <arnd@arndb.de>
Wed, 4 Dec 2019 08:35:00 +0000 (09:35 +0100)
committerArnd Bergmann <arnd@arndb.de>
Fri, 3 Jan 2020 08:32:54 +0000 (09:32 +0100)
commit548fe4628bfa5864d04ff23a5dcea867d5272973
treef2da56782db2b9c43397be98d362dd94db3790ac
parentaf3c34802e4a12f4242401194aa042d82ff49ff6
compat: scsi: sg: fix v3 compat read/write interface

In the v5.4 merge window, a cleanup patch from Al Viro conflicted
with my rework of the compat handling for sg.c read(). Linus Torvalds
did a correct merge but pointed out that the resulting code is still
unsatisfactory.

I later noticed that the sg_new_read() function still gets the compat
mode wrong, when the 'count' argument is large enough to pass a
compat_sg_io_hdr object, but not a nativ sg_io_hdr.

To address both of these, move the definition of compat_sg_io_hdr
into a scsi/sg.h to make it visible to sg.c and rewrite the logic
for reading req_pack_id as well as the size check to a simpler
version that gets the expected results.

Fixes: ee27c9b70af7 ("scsi: sg: sg_read(): simplify reading ->pack_id of userland sg_io_hdr_t")
Fixes: 54f648f99f6f ("compat_ioctl: reimplement SG_IO handling")
Reviewed-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
block/scsi_ioctl.c
drivers/scsi/sg.c
include/scsi/sg.h