libata: have ata_scsi_rw_xlat() fail invalid passthrough requests
authorJens Axboe <axboe@kernel.dk>
Wed, 7 Aug 2019 18:20:52 +0000 (12:20 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 25 Nov 2019 08:53:15 +0000 (09:53 +0100)
commit31941e54e35295e66fa1a6e749f5faf0332bc7f5
treed125f3ed0ab8de5a547835e739d603305860dcc1
parentf3216243df6758ee8c80f63b95b9be424abb0ce2
libata: have ata_scsi_rw_xlat() fail invalid passthrough requests

commit 2d7271501720038381d45fb3dcbe4831228fc8cc upstream.

For passthrough requests, libata-scsi takes what the user passes in
as gospel. This can be problematic if the user fills in the CDB
incorrectly. One example of that is in request sizes. For read/write
commands, the CDB contains fields describing the transfer length of
the request. These should match with the SG_IO header fields, but
libata-scsi currently does no validation of that.

Check that the number of blocks in the CDB for passthrough requests
matches what was mapped into the request. If the CDB asks for more
data then the validated SG_IO header fields, error it.

Reported-by: Krishna Ram Prakash R <krp@gtux.in>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/ata/libata-scsi.c