From patchwork Tue Jul 31 19:51:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10551251 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D5BC157D for ; Tue, 31 Jul 2018 19:52:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DF16285FF for ; Tue, 31 Jul 2018 19:52:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01C382B1A2; Tue, 31 Jul 2018 19:52:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55F092B49D for ; Tue, 31 Jul 2018 19:52:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732582AbeGaVeF (ORCPT ); Tue, 31 Jul 2018 17:34:05 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:45488 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732569AbeGaVeE (ORCPT ); Tue, 31 Jul 2018 17:34:04 -0400 Received: by mail-pg1-f196.google.com with SMTP id f1-v6so9583494pgq.12 for ; Tue, 31 Jul 2018 12:52:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nqR6k1MB6wyRMVwrfWMrenBi6eb5HDL3f8RkW4PPP4Q=; b=mboo4uKK8mHUzXWzVnL44wPkHdoUh2DoObef4UPry7nWOk32vTLbVDfdEfPQicXW5H H9noud5bEa9RnJGkCaNJqAo1I/l6jd37xmZ5oG5LrJ0HTHUJSnQnmnSv3BsyFSqmvPaW d3pO7Q2XmNcB+Tiaue5PoVO5HaQGwY72qZ/3Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nqR6k1MB6wyRMVwrfWMrenBi6eb5HDL3f8RkW4PPP4Q=; b=XtuKXqHNmNKI5/5MvP7d2WxBAzd8pvgPp9/UK+m2nhpj0rMLE6PnRuO5WH/koQmtOv C+S24AAXngVFFTKyxDIH1dcYUzc45qyiYPPJ66scC/KVo/rVyy0SJiMG5teAfxySzXUh RffOMuKCWQHnFFqBzRMkTzwU7a24XirFqZku3m3YFPzD4uu5rnaqeHSNLrbSZyDpU3LZ mlOVZFY67NH3ofG9chxZ288+YakcsaYyHJGpp025veCiZN3jaRMn33B3UAPbI/3f3bVT UWGgpG0p8QqrvSPlcDMDxtNNBx4wqMr11Tp/0QNDf9LUFlfRwzJ/arxF4/oX6MxHN/rc Wajg== X-Gm-Message-State: AOUpUlE0XUrgyCw3DZkKKW4Q94DejPmrv1XxkWReM+83StHn9/g+DYEb PIQ3HbPDQ+S0P+Hu5wtV0WwgFw== X-Google-Smtp-Source: AAOMgpe2Hm0zPeg7+mCCEeTxTxEqxKPcnz5q1+aikiX596hAQ1DmHZMGoe6S1eOhs0JXFWeVUKvFgQ== X-Received: by 2002:a65:6343:: with SMTP id p3-v6mr21983982pgv.48.1533066731061; Tue, 31 Jul 2018 12:52:11 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id s3-v6sm43338921pfg.2.2018.07.31.12.52.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Jul 2018 12:52:07 -0700 (PDT) From: Kees Cook To: Jens Axboe Cc: Kees Cook , Christoph Hellwig , "Martin K. Petersen" , "James E.J. Bottomley" , Tejun Heo , Borislav Petkov , "David S. Miller" , "Manoj N. Kumar" , "Matthew R. Ochs" , Uma Krishnan , "Nicholas A. Bellinger" , Thomas Gleixner , Philippe Ombredanne , Stephen Boyd , Cyrille Pitchen , Juergen Gross , Viresh Kumar , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Sagar Dharia , Randy Dunlap , Vinod Koul , David Kershner , 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 Message-Id: <20180731195155.46664-8-keescook@chromium.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180731195155.46664-1-keescook@chromium.org> References: <20180731195155.46664-1-keescook@chromium.org> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Christoph Hellwig --- 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 #include #include +#include #include /* 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))