]> git.baikalelectronics.ru Git - kernel.git/commit
sg: fix dxferp in from_to case
authorDouglas Gilbert <dgilbert@interlog.com>
Thu, 3 Mar 2016 05:31:29 +0000 (00:31 -0500)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 14 Mar 2016 19:50:25 +0000 (15:50 -0400)
commit9a3042c7e493f79f95e4c7b837d091ed88062918
tree1c13b1e219778ab774728aef8b93dcafe18d3e18
parent620bf317592e768f8a09b1da5c1b50d9fd86d282
sg: fix dxferp in from_to case

One of the strange things that the original sg driver did was let the
user provide both a data-out buffer (it followed the sg_header+cdb)
_and_ specify a reply length greater than zero. What happened was that
the user data-out buffer was copied into some kernel buffers and then
the mid level was told a read type operation would take place with the
data from the device overwriting the same kernel buffers. The user would
then read those kernel buffers back into the user space.

From what I can tell, the above action was broken by commit 7581a5dad623
("sg: set dxferp to NULL for READ with the older SG interface") in 2008
and syzkaller found that out recently.

Make sure that a user space pointer is passed through when data follows
the sg_header structure and command.  Fix the abnormal case when a
non-zero reply_len is also given.

Fixes: 7581a5dad62351ba2cce234d02433991d9ef95e0
Cc: <stable@vger.kernel.org> #v2.6.28+
Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
Reviewed-by: Ewan Milne <emilne@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/sg.c