cdrom: Use struct scsi_sense_hdr internally

This removes more casts of struct request_sense and uses the standard
struct scsi_sense_hdr instead. This also fixes any possible stale values
since the prior code did not check the sense length.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Kees Cook 2018-07-31 12:51:52 -07:00 коммит произвёл Jens Axboe
Родитель 7a6873be1b
Коммит 4e178c17ca
2 изменённых файлов: 7 добавлений и 3 удалений

Просмотреть файл

@ -74,12 +74,12 @@ config AMIGA_Z2RAM
config CDROM config CDROM
tristate tristate
select BLK_SCSI_REQUEST
config GDROM config GDROM
tristate "SEGA Dreamcast GD-ROM drive" tristate "SEGA Dreamcast GD-ROM drive"
depends on SH_DREAMCAST depends on SH_DREAMCAST
select CDROM select CDROM
select BLK_SCSI_REQUEST # only for the generic cdrom code
help help
A standard SEGA Dreamcast comes with a modified CD ROM drive called a A standard SEGA Dreamcast comes with a modified CD ROM drive called a
"GD-ROM" by SEGA to signify it is capable of reading special disks "GD-ROM" by SEGA to signify it is capable of reading special disks

Просмотреть файл

@ -282,6 +282,7 @@
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/times.h> #include <linux/times.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <scsi/scsi_common.h>
#include <scsi/scsi_request.h> #include <scsi/scsi_request.h>
/* used to tell the module to turn on full debugging messages */ /* used to tell the module to turn on full debugging messages */
@ -2222,9 +2223,12 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,
blk_execute_rq(q, cdi->disk, rq, 0); blk_execute_rq(q, cdi->disk, rq, 0);
if (scsi_req(rq)->result) { if (scsi_req(rq)->result) {
struct request_sense *s = req->sense; struct scsi_sense_hdr sshdr;
ret = -EIO; ret = -EIO;
cdi->last_sense = s->sense_key; scsi_normalize_sense(req->sense, req->sense_len,
&sshdr);
cdi->last_sense = sshdr.sense_key;
} }
if (blk_rq_unmap_user(bio)) if (blk_rq_unmap_user(bio))