All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: "Kees Cook" <keescook@chromium.org>,
	"Christoph Hellwig" <hch@infradead.org>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	"James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
	"Tejun Heo" <tj@kernel.org>, "Borislav Petkov" <bp@alien8.de>,
	"David S. Miller" <davem@davemloft.net>,
	"Manoj N. Kumar" <manoj@linux.vnet.ibm.com>,
	"Matthew R. Ochs" <mrochs@linux.vnet.ibm.com>,
	"Uma Krishnan" <ukrishn@linux.vnet.ibm.com>,
	"Nicholas A. Bellinger" <nab@linux-iscsi.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Philippe Ombredanne" <pombredanne@nexb.com>,
	"Stephen Boyd" <sboyd@codeaurora.org>,
	"Cyrille Pitchen" <cyrille.pitchen@free-electrons.com>,
	"Juergen Gross" <jgross@suse.com>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Sagar Dharia" <sdharia@codeaurora.org>,
	"Randy Dunlap" <rdunlap@infradead.org>,
	"Vinod Koul" <vinod.koul@intel.com>,
	"David Kershner" <david.kershner@unisys.com>,
	linux-block@vger.kernel.org, linux-ide@vger.kernel.org,
	linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 7/9] cdrom: Use struct scsi_sense_hdr internally
Date: Tue, 31 Jul 2018 12:51:52 -0700	[thread overview]
Message-ID: <20180731195155.46664-8-keescook@chromium.org> (raw)
In-Reply-To: <20180731195155.46664-1-keescook@chromium.org>

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.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/block/Kconfig | 2 +-
 drivers/cdrom/cdrom.c | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index ad9b687a236a..d4913516823f 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -74,12 +74,12 @@ config AMIGA_Z2RAM
 
 config CDROM
 	tristate
+	select BLK_SCSI_REQUEST
 
 config GDROM
 	tristate "SEGA Dreamcast GD-ROM drive"
 	depends on SH_DREAMCAST
 	select CDROM
-	select BLK_SCSI_REQUEST # only for the generic cdrom code
 	help
 	  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
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index 3522d2cae1b6..e547213239dc 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -282,6 +282,7 @@
 #include <linux/blkdev.h>
 #include <linux/times.h>
 #include <linux/uaccess.h>
+#include <scsi/scsi_common.h>
 #include <scsi/scsi_request.h>
 
 /* 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);
 		if (scsi_req(rq)->result) {
-			struct request_sense *s = req->sense;
+			struct scsi_sense_hdr sshdr;
+
 			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))
-- 
2.17.1

WARNING: multiple messages have this Message-ID (diff)
From: Kees Cook <keescook@chromium.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: "Kees Cook" <keescook@chromium.org>,
	"Christoph Hellwig" <hch@infradead.org>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	"James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
	"Tejun Heo" <tj@kernel.org>, "Borislav Petkov" <bp@alien8.de>,
	"David S. Miller" <davem@davemloft.net>,
	"Manoj N. Kumar" <manoj@linux.vnet.ibm.com>,
	"Matthew R. Ochs" <mrochs@linux.vnet.ibm.com>,
	"Uma Krishnan" <ukrishn@linux.vnet.ibm.com>,
	"Nicholas A. Bellinger" <nab@linux-iscsi.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Philippe Ombredanne" <pombredanne@nexb.com>,
	"Stephen Boyd" <sboyd@codeaurora.org>,
	"Cyrille Pitchen" <cyrille.pitchen@free-electrons.com>,
	"Juergen Gross" <jgross@suse.com>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	"Uwe Kleine-König" <u.kleine-koenig@pen>
Subject: [PATCH v2 7/9] cdrom: Use struct scsi_sense_hdr internally
Date: Tue, 31 Jul 2018 12:51:52 -0700	[thread overview]
Message-ID: <20180731195155.46664-8-keescook@chromium.org> (raw)
In-Reply-To: <20180731195155.46664-1-keescook@chromium.org>

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.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/block/Kconfig | 2 +-
 drivers/cdrom/cdrom.c | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index ad9b687a236a..d4913516823f 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -74,12 +74,12 @@ config AMIGA_Z2RAM
 
 config CDROM
 	tristate
+	select BLK_SCSI_REQUEST
 
 config GDROM
 	tristate "SEGA Dreamcast GD-ROM drive"
 	depends on SH_DREAMCAST
 	select CDROM
-	select BLK_SCSI_REQUEST # only for the generic cdrom code
 	help
 	  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
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index 3522d2cae1b6..e547213239dc 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -282,6 +282,7 @@
 #include <linux/blkdev.h>
 #include <linux/times.h>
 #include <linux/uaccess.h>
+#include <scsi/scsi_common.h>
 #include <scsi/scsi_request.h>
 
 /* 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);
 		if (scsi_req(rq)->result) {
-			struct request_sense *s = req->sense;
+			struct scsi_sense_hdr sshdr;
+
 			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))
-- 
2.17.1

WARNING: multiple messages have this Message-ID (diff)
From: Kees Cook <keescook@chromium.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: "Kees Cook" <keescook@chromium.org>,
	"Christoph Hellwig" <hch@infradead.org>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	"James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
	"Tejun Heo" <tj@kernel.org>, "Borislav Petkov" <bp@alien8.de>,
	"David S. Miller" <davem@davemloft.net>,
	"Manoj N. Kumar" <manoj@linux.vnet.ibm.com>,
	"Matthew R. Ochs" <mrochs@linux.vnet.ibm.com>,
	"Uma Krishnan" <ukrishn@linux.vnet.ibm.com>,
	"Nicholas A. Bellinger" <nab@linux-iscsi.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Philippe Ombredanne" <pombredanne@nexb.com>,
	"Stephen Boyd" <sboyd@codeaurora.org>,
	"Cyrille Pitchen" <cyrille.pitchen@free-electrons.com>,
	"Juergen Gross" <jgross@suse.com>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Sagar Dharia" <sdharia@codeaurora.org>,
	"Randy Dunlap" <rdunlap@infradead.org>,
	"Vinod Koul" <vinod.koul@intel.com>,
	"David Kershner" <david.kershner@unisys.com>,
	linux-block@vger.kernel.org, linux-ide@vger.kernel.org,
	linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 7/9] cdrom: Use struct scsi_sense_hdr internally
Date: Tue, 31 Jul 2018 19:51:52 +0000	[thread overview]
Message-ID: <20180731195155.46664-8-keescook@chromium.org> (raw)
In-Reply-To: <20180731195155.46664-1-keescook@chromium.org>

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.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/block/Kconfig | 2 +-
 drivers/cdrom/cdrom.c | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index ad9b687a236a..d4913516823f 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -74,12 +74,12 @@ config AMIGA_Z2RAM
 
 config CDROM
 	tristate
+	select BLK_SCSI_REQUEST
 
 config GDROM
 	tristate "SEGA Dreamcast GD-ROM drive"
 	depends on SH_DREAMCAST
 	select CDROM
-	select BLK_SCSI_REQUEST # only for the generic cdrom code
 	help
 	  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
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index 3522d2cae1b6..e547213239dc 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -282,6 +282,7 @@
 #include <linux/blkdev.h>
 #include <linux/times.h>
 #include <linux/uaccess.h>
+#include <scsi/scsi_common.h>
 #include <scsi/scsi_request.h>
 
 /* 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);
 		if (scsi_req(rq)->result) {
-			struct request_sense *s = req->sense;
+			struct scsi_sense_hdr sshdr;
+
 			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))
-- 
2.17.1


  parent reply	other threads:[~2018-07-31 19:51 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-31 19:51 [PATCH v2 0/9] block: Consolidate scsi sense buffer usage Kees Cook
2018-07-31 19:51 ` Kees Cook
2018-07-31 19:51 ` Kees Cook
2018-07-31 19:51 ` [PATCH v2 1/9] ide-cd: Drop unused sense buffers Kees Cook
2018-07-31 19:51   ` Kees Cook
2018-07-31 19:51   ` Kees Cook
2018-07-31 21:29   ` David Miller
2018-07-31 21:29     ` David Miller
2018-07-31 19:51 ` [PATCH v2 2/9] scsi: cxlflash: " Kees Cook
2018-07-31 19:51   ` Kees Cook
2018-07-31 19:51   ` Kees Cook
2018-07-31 19:51 ` [PATCH v2 3/9] scsi: build scsi_common.o for all scsi passthrough request users Kees Cook
2018-07-31 19:51   ` Kees Cook
2018-07-31 19:51   ` Kees Cook
2018-07-31 20:01   ` Bart Van Assche
2018-07-31 20:01     ` Bart Van Assche
2018-07-31 20:01     ` Bart Van Assche
2018-07-31 20:01     ` Bart Van Assche
2018-07-31 20:12     ` hch
2018-07-31 20:12       ` hch
2018-07-31 20:12       ` hch
2018-07-31 20:12       ` hch
2018-07-31 20:18       ` Bart Van Assche
2018-07-31 20:18         ` Bart Van Assche
2018-07-31 20:18         ` Bart Van Assche
2018-07-31 20:18         ` Bart Van Assche
2018-08-01 19:50         ` Kees Cook
2018-08-01 19:50           ` Kees Cook
2018-08-01 19:50           ` Kees Cook
2018-08-01 19:50           ` Kees Cook
2018-07-31 19:51 ` [PATCH v2 4/9] target: don't depend on SCSI Kees Cook
2018-07-31 19:51   ` Kees Cook
2018-07-31 19:51   ` Kees Cook
2018-08-06 23:38   ` Randy Dunlap
2018-08-06 23:38     ` Randy Dunlap
2018-08-06 23:38     ` Randy Dunlap
2018-08-06 23:59     ` Kees Cook
2018-08-06 23:59       ` Kees Cook
2018-08-06 23:59       ` Kees Cook
2018-08-07  0:52       ` Randy Dunlap
2018-08-07  0:52         ` Randy Dunlap
2018-08-07  0:52         ` Randy Dunlap
2018-08-07  5:44       ` Christoph Hellwig
2018-08-07  5:44         ` Christoph Hellwig
2018-08-07  5:44         ` Christoph Hellwig
2018-07-31 19:51 ` [PATCH v2 5/9] block: Switch struct packet_command to use struct scsi_sense_hdr Kees Cook
2018-07-31 19:51   ` Kees Cook
2018-07-31 19:51   ` Kees Cook
2018-08-01  8:22   ` Christoph Hellwig
2018-08-01  8:22     ` Christoph Hellwig
2018-08-01  8:22     ` Christoph Hellwig
2018-07-31 19:51 ` [PATCH v2 6/9] ide-cd: Remove redundant sense buffer Kees Cook
2018-07-31 19:51   ` Kees Cook
2018-07-31 19:51   ` Kees Cook
2018-07-31 21:30   ` David Miller
2018-07-31 21:30     ` David Miller
2018-08-01  8:23   ` Christoph Hellwig
2018-08-01  8:23     ` Christoph Hellwig
2018-08-01  8:23     ` Christoph Hellwig
2018-07-31 19:51 ` Kees Cook [this message]
2018-07-31 19:51   ` [PATCH v2 7/9] cdrom: Use struct scsi_sense_hdr internally Kees Cook
2018-07-31 19:51   ` Kees Cook
2018-08-01  8:24   ` Christoph Hellwig
2018-08-01  8:24     ` Christoph Hellwig
2018-08-01  8:24     ` Christoph Hellwig
2018-07-31 19:51 ` [PATCH v2 8/9] libata-scsi: Move sense buffers onto stack Kees Cook
2018-07-31 19:51   ` Kees Cook
2018-07-31 19:51   ` Kees Cook
2018-08-01  8:24   ` Christoph Hellwig
2018-08-01  8:24     ` Christoph Hellwig
2018-08-01  8:24     ` Christoph Hellwig
2018-08-01 15:45   ` Tejun Heo
2018-08-01 15:45     ` Tejun Heo
2018-08-01 15:45     ` Tejun Heo
2018-07-31 19:51 ` [PATCH v2 9/9] scsi: Check sense buffer size at build time Kees Cook
2018-07-31 19:51   ` Kees Cook
2018-07-31 19:51   ` Kees Cook
2018-08-01  8:25   ` Christoph Hellwig
2018-08-01  8:25     ` Christoph Hellwig
2018-08-01  8:25     ` Christoph Hellwig
2018-08-02 20:21 ` [PATCH v2 0/9] block: Consolidate scsi sense buffer usage Martin K. Petersen
2018-08-02 20:21   ` Martin K. Petersen
2018-08-02 20:21   ` Martin K. Petersen
2018-08-02 21:24 ` Jens Axboe
2018-08-02 21:24   ` Jens Axboe
2018-08-02 21:24   ` Jens Axboe
2018-08-02 21:56   ` Kees Cook
2018-08-02 21:56     ` Kees Cook
2018-08-02 21:56     ` Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180731195155.46664-8-keescook@chromium.org \
    --to=keescook@chromium.org \
    --cc=axboe@kernel.dk \
    --cc=bp@alien8.de \
    --cc=cyrille.pitchen@free-electrons.com \
    --cc=davem@davemloft.net \
    --cc=david.kershner@unisys.com \
    --cc=hch@infradead.org \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=jgross@suse.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=manoj@linux.vnet.ibm.com \
    --cc=martin.petersen@oracle.com \
    --cc=mrochs@linux.vnet.ibm.com \
    --cc=nab@linux-iscsi.org \
    --cc=pombredanne@nexb.com \
    --cc=rdunlap@infradead.org \
    --cc=sboyd@codeaurora.org \
    --cc=sdharia@codeaurora.org \
    --cc=target-devel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=ukrishn@linux.vnet.ibm.com \
    --cc=vinod.koul@intel.com \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.