From patchwork Fri Jun 2 21:21:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9763479 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 02A4360360 for ; Fri, 2 Jun 2017 21:22:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9E9A28590 for ; Fri, 2 Jun 2017 21:22:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DECDF285D5; Fri, 2 Jun 2017 21:22:28 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 124A028590 for ; Fri, 2 Jun 2017 21:22:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751267AbdFBVW0 (ORCPT ); Fri, 2 Jun 2017 17:22:26 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:4908 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751170AbdFBVWT (ORCPT ); Fri, 2 Jun 2017 17:22:19 -0400 X-IronPort-AV: E=Sophos;i="5.39,286,1493654400"; d="scan'208";a="22381025" Received: from mail-co1nam03lp0019.outbound.protection.outlook.com (HELO NAM03-CO1-obe.outbound.protection.outlook.com) ([216.32.181.19]) by ob1.hgst.iphmx.com with ESMTP; 03 Jun 2017 05:22:17 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ZKHdLQ6wrqMU0aiepDy97FsgRxu1gkljWmE/oIyyhro=; b=M685rGYM4kGj81SR7tfwiFUyw4L2Z3JUatuuwoGBXkL2dzkuv3U7nhznENGOX0coH3Ki3F+7BvrNP23Ul7FH/uJeekZRzxBilAglcyD0PC2j6QRw4ULJAyOxZtzZdEZeTJmbSoN3QooCy6dWCVumqYh+/dgSrmQMRtMcHodGrSU= Received: from CO2PR04CA0124.namprd04.prod.outlook.com (10.165.95.26) by BY1PR0401MB1462.namprd04.prod.outlook.com (10.161.206.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9; Fri, 2 Jun 2017 21:22:15 +0000 Received: from SN1NAM04FT048.eop-NAM04.prod.protection.outlook.com (2a01:111:f400:7e4c::209) by CO2PR04CA0124.outlook.office365.com (2603:10b6:104:7::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1143.10 via Frontend Transport; Fri, 2 Jun 2017 21:22:15 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.225) smtp.mailfrom=sandisk.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=sandisk.com; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.225 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.225; helo=milsmgep14.sandisk.com; Received: from milsmgep14.sandisk.com (63.163.107.225) by SN1NAM04FT048.mail.protection.outlook.com (10.152.89.195) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1101.12 via Frontend Transport; Fri, 2 Jun 2017 21:22:13 +0000 Received: from MILHUBIP03.sdcorp.global.sandisk.com (Unknown_Domain [10.201.67.162]) (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by (Symantec Messaging Gateway) with SMTP id F5.7A.38445.007D1395; Fri, 2 Jun 2017 14:22:09 -0700 (PDT) Received: from milsmgip12.sandisk.com (10.177.9.6) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.319.2; Fri, 2 Jun 2017 14:22:05 -0700 X-AuditID: 0ac94371-422569800000962d-93-5931d7006b45 Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id 0D.A4.18148.DF6D1395; Fri, 2 Jun 2017 14:22:05 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , James Bottomley CC: , Christoph Hellwig , "Bart Van Assche" , Hannes Reinecke , "Scott Bauer" , Jan Kara , Subject: [PATCH v3 01/12] Avoid that scsi_exit_rq() triggers a use-after-free Date: Fri, 2 Jun 2017 14:21:52 -0700 Message-ID: <20170602212203.30401-2-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170602212203.30401-1-bart.vanassche@sandisk.com> References: <20170602212203.30401-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRmVeSWpSXmKPExsXCddJ5kS7jdcNIg9c3eC0WvNnLZrFy9VEm i9nTm5ksNvZzWHRf38Fmsfz4PyaLl/OusFss2PiI0YHDY9qkU2wei/e8ZPLYfbOBzePj01ss Huu3XGXxOLPgCLvH501yAexRXDYpqTmZZalF+nYJXBkvjvxkLrhsWvG3i6eBcZJuFyMnh4SA icT3+5cZuxi5OIQEljJJfL++EMrZyijRM38NG0zVm1n/WCESmxkl+m82M4Mk2ASMJL69n8kC YosIFEpc2tYB1s0s8JZR4t7WP2DdwgK+EuefPwCzWQRUJBYc3scEYvMK2EtcffIWaoO8xNkt O8GGcgo4SHzr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cMXc1PZQYinOSDTUYi4qTgQAjNCJ+NkB AAA= MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:63.163.107.225; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(39410400002)(39400400002)(39850400002)(39860400002)(39450400003)(39840400002)(2980300002)(438002)(189002)(199003)(9170700003)(50466002)(356003)(33646002)(4326008)(53936002)(106466001)(305945005)(478600001)(47776003)(575784001)(5003940100001)(38730400002)(77096006)(86362001)(230783001)(50986999)(76176999)(54906002)(72206003)(36756003)(1076002)(189998001)(48376002)(8676002)(2950100002)(6666003)(8936002)(5660300001)(50226002)(81166006)(2906002); DIR:OUT; SFP:1102; SCL:1; SRVR:BY1PR0401MB1462; H:milsmgep14.sandisk.com; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; SN1NAM04FT048; 1:fEucVFRg/ssOJasVUCsXMKw66/uscurRfDjeplFT534hfBaWzMPQogiIb7ewum+jMXbW8qfMT3UjS/b49Jpk+w/iHumfhNj1x5/r59FLUeVMY10yUd5xj6MnqRHJ4Yw5IgRHSv//6mpkhUiXL4g46rdaOVvaT/bmAIYDYeiTqksIOA8uVaACwNwuQWZrjsyphWIVONLpKHyPuB72Y7bTSn/U65Xsy8wB7n4fpR9gOv6nv7JDI1Pc5Xvy312bDr6k/1kDZVDd+11TnfYN/qkDRe6uauLa9c8UO/uOeYHsWqLi8xWj72OPkkh7Im74Y47EvfOXQnV0sHTTtN0WtAD/IoYC9PPkV0u7hW99i4/JYU08MH1YhCDnGatyGLvI+MzCP0lxTaRivG63B/wo7vAOSIzMklRXBTAslHuPUuB+m/wFfx7TQrmgrNgyZ5rDr9tBTwCyptFhNQ6ALU7rEa5OX7bdFiowBK6n4sGUbAaKex3zAqeuT5UlQmSVSE/IphOGPbEC612XyjObwH1xzIJwh/oJGarCeGoA3GaHqvGN+lqTqmErWPYGsafghen0+aKRlzLapvyp6Xy9wnpOJwqQGTMJebNY4M1n4fjl1Z9ZIc4= X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PR0401MB1462: X-MS-Office365-Filtering-Correlation-Id: f9132980-ae1f-4ddc-237a-08d4a9fd7094 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081)(201702281549075); SRVR:BY1PR0401MB1462; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0401MB1462; 3:leS5NAATl1ApqcSTj7zAn6z7jNSApxn8hI846JWT2g7YaUSEkOmYc6jYjHrbaXY9kOSP2ovwfIzMYtkwgRwMIr/VRyR0QdKwzb1ZdzIVe5xBvY6Lz+dc1sNcfwuFYrJdNj/p+9FlcXIx/qkjUFg7G0wdN4Z1IB2lu197AdIRYaHfxzk91cZP6jY8nfs8pfjTnomVNYULPrqloEtcfN8plFTM5fNeR5Fe3lwXMnHl97Yr38Nnrk/CpWcAO2uLceHB3dcu+32wDYDfswl2Y2QskdSxg8PNgRR7DYv3k6IsSjLca32T/ViqonKBBzg6g0coNdjksJhQanb7e7MlTf4Il+WReMlIpJvBEFdlzvWaOa6CAQnBFiJknEDUOZ4x8yuRA+ZMCSKpw6kXjSiaCEr9Sh6TFcK4STyCtFKs1gc5qCD1rjkjah2ujIzZKoXKQ+CvgYQJWHl+NyHJpjBJrtXfBk8PYSE5TFjH3A6kY70tOMeJwyBcTdo6gvWNAy3XeOb1zRUKH4Fg/CvgqWl3K4eIuA== X-Microsoft-Exchange-Diagnostics: 1; BY1PR0401MB1462; 25:1ssJ1Lt2aYNLCmYjN347tLVMBmAZQbdtdQg1yUVuHJDvuGhNtSCFrUp7kh3rkEFdLSlhntmz/onTXoDMYgnendVN2DyNxS51t/fG8hQn/cbiLSGPWzp4wYnmclmj6NAKK1mYxVVz5mwbXnNqq67tHR0CcCGuwGUOFB5PfTOYTYYQ1Qx1pA17+P4B7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zzmQKrkwExRbM9fQeQnS9iLBG4n1d1Q4g2crsFapilqvIl7K7Y+pVVejA9dIBrgNSvC/Qjkra5DvzKtnFl99ygOSegm12BG7vQynajFlT8fdC16zA X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(42932892334569)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(13018025)(5005006)(8121501046)(13016025)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(93004095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123564025)(20161123560025)(20161123562025)(20161123558100)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BY1PR0401MB1462; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BY1PR0401MB1462; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR0401MB1462; 4:bL8HS229oa2xInLV74wMJV63BZ818Di4YtRDIVz/?= =?us-ascii?Q?PHYV0N1dtNH2O+vgLTyfNDk70PGag9oZVwnjDGlUq6b0/IiduEzcBWxP65mo?= =?us-ascii?Q?qLYVMQMsx/bI1asKV87IqTmyZBSrycMsndnt7jAEduugGnYesRGM/BE4ZVet?= =?us-ascii?Q?3Doy9nYthiJDu/iDQAmybF1Ls1adFjGsybuX2qH7HgaD4SXcAvLbs7ydhFax?= =?us-ascii?Q?mxezAzJE/kD5yES3P2KQ9Sfd3cCZqAdeWivemeXcvi4j4anZGX8Tms+bvae0?= =?us-ascii?Q?w8sbG7y0/PQ/lxHR+soEiA0UPtHbG8/2XVocrfZcRIxlEh1E8qG3VtYCqZ8+?= =?us-ascii?Q?vAWczKsx+xkUHwlDLCI2umqzpLzgcXfYQDdKQzZfIQ4Qa1n+g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pvn7P9OUuNnAFKeA9OxpidPfaFwyCRpI?= =?us-ascii?Q?QFcRR4WtY9YYh2t9B41o3eE=3D?= X-Forefront-PRVS: 03264AEA72 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR0401MB1462; 23:KfFjS62mn5HDrd4TiZ+JR/+o+wm/KNn5d09nd//?= =?us-ascii?Q?79jlIFTEK90QmP9A5ehmNeuZJkMagL6RKS5dZI9OP4bq28GZ+4rydxagTD8K?= =?us-ascii?Q?maPNVQ0m4kDtk/ppzuc2RM3mHSxKv1ODq4uUe7UUYIGcqfhLbch8ZuKb9p93?= =?us-ascii?Q?LTLWK7beuD6uq+Ws6BfozyWD0Ltk+B8C24qKoogmJs0g1Ru7njpmYe32OFe9?= =?us-ascii?Q?Hk7bbaXy1288+xf+XnWrCvnXJ04e8l/n11zZTkMPJpFqfaSEIKqbGKguYQyv?= =?us-ascii?Q?mGSyJbzp5RpH9Nn4t82Eh03y9YzCNSVn0DgpyZyNo7/wf8PBEiSivkkbUOsB?= =?us-ascii?Q?l4c8xAUlXboBcxaAi0xkgfqFRdjlkEC89GtRw5nQsBcQTm4uZ0/0abwN1Ak9?= =?us-ascii?Q?OR8SsMkCmwClze9yIJoKdvHI31aWPZmL1OBsffLCzawbbxs/snH12a+ckIIb?= =?us-ascii?Q?sIFhfEtENToCpvE66v0KhReCJj4CHRlTtiEvv8gfNSGHfg0MOU0rlPtlfJd/?= =?us-ascii?Q?gMPfGR/8ZOqFRO7C9Cl0BcoVeFzm8XtvyGxyzjQlGUphLA336W8OlkEmCXCh?= =?us-ascii?Q?qidecvhIORCh1cjHBRfa+oH7egdvg55xjjQNm1sjc9W88YGjAWuLZUwU/yTk?= =?us-ascii?Q?5mfVQzjUCe6ht5E9PFbh23VKPDFbHo0Th3eZjnPeqIavE2NBoHS75Vj27XyI?= =?us-ascii?Q?iZHLIpSvriIlCR6qdnTae+gH+R+FvO4ZM3MHS2RqHwxGnJDdzSo4FNxTXwo+?= =?us-ascii?Q?hAh1zYLN5o3TYR9LoSNon6dqvFMtp04DeeLU4hLg1LjycdSRH6fc0lid/DiF?= =?us-ascii?Q?CHZPBj+7KuiCYK00w58SNwMuvm38DPjx90nY8F7HtJMl/5caKWUAidqppmvZ?= =?us-ascii?Q?sH6O6wi+VUG0Ko2LXIUoVFqpUho4YDPQvS/MrUZ6b87xmf8EuQ79oO/LMn0I?= =?us-ascii?Q?8XHtPjADR7uaBir1Oh1hFJb73bICmBzsVAMtMG33InmiX+8w/ijKvkkrvEje?= =?us-ascii?Q?Bg7+swJld+Bzuoq9Djge42kbw1w3CwfsAo7quGbU+nqQZb0kVgfXQ+ScjDqv?= =?us-ascii?Q?gqNkfS6JUei5r/iyNSYnC049bus8kWa3wbczRTL03TMzQhOKoXA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY1PR0401MB1462; 6:uHjVQB4nTTPIcC4Sb3IP+t9oW6VZvHE/XmYl4schHD51J90AvXcOjrorD8ECCR8jKJPYprnZlhYYs1WlBWcgmIoMrK9Q5u5qMFanIsjZ/YGabR3oYkIO+oR7NsZ9NLYY1pCnhyiIZ3BCBfMM32RxlKllPw8py83Ai40MKXGxT51DZgXeVXzsTT1u4fmP4oXTl39JM+FPIBFcviLRWklAipQCjg+EOAKywhP5yGPFrcE0Aj9qGLdP0g9DSePLJtzy8HViYtEAor9WijabIWQgIVEyfotsDhmpX6eXssJnMrnyGisJ6opKjFA0SdqtTt/B1F+VlI4FjCkRgKb/ci6azR3wvHCPrJdS0no0+L8YbholSFzsZAO6AncpJgJKh0wYc26td2pnmMooyGH1QgTbJxvT01fpMVhFq45u437VQZNm8vnlZcIuQLxNxSLkhFSaso8q/g+HK4hDujVgvsos/AiH3hOOex22yVrE6HYkFb0uenyJw9JlefxHp6ggKQra7GG4p1YFQqKll8kMegVJ+JFdEmx933JgL+RVIEDyQwA= X-Microsoft-Exchange-Diagnostics: 1; BY1PR0401MB1462; 5:X0BkWo+H2eidL6qvDdKFrBKQ0QKkdz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f3JFoKdU0vwS3hC9EmDz7ZfZXwz6Tjjrygz8LvmwvQon74jqaDDcloV1DEBkNU1XknUgp7v2BNtNk/AsThdHWrFuFuvmZPJzlEn7z8PEm+1l9qLWi/ceAE4PXAwY= X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2017 21:22:13.2596 (UTC) X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=b61c8803-16f3-4c35-9b17-6f65f441df86; Ip=[63.163.107.225]; Helo=[milsmgep14.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0401MB1462 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 Dereferencing shost from scsi_exit_rq() is not safe because the SCSI host may already have been freed when scsi_exit_rq() is called. Increasing the shost reference count in scsi_init_rq() and dropping that reference in scsi_exit_rq() is nontrivial since scsi_host_dev_release() may sleep and since scsi_exit_rq() may be called from interrupt context. Since scsi_exit_rq() only needs a single bit from shost, copy that bit into struct scsi_cmnd. Reported-by: Scott Bauer Fixes: e9c787e65c0c ("scsi: allocate scsi_cmnd structures as part of struct request") Signed-off-by: Bart Van Assche Reviewed-by: Christoph Hellwig Cc: Hannes Reinecke Cc: Scott Bauer Cc: Jan Kara Cc: --- drivers/scsi/scsi_lib.c | 47 +++++++++++++++++++++++++++++------------------ include/scsi/scsi_cmnd.h | 1 + 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 814a4bd8405d..cc9f792cd12b 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -44,23 +44,23 @@ static struct kmem_cache *scsi_sense_isadma_cache; static DEFINE_MUTEX(scsi_sense_cache_mutex); static inline struct kmem_cache * -scsi_select_sense_cache(struct Scsi_Host *shost) +scsi_select_sense_cache(bool unchecked_isa_dma) { - return shost->unchecked_isa_dma ? - scsi_sense_isadma_cache : scsi_sense_cache; + return unchecked_isa_dma ? scsi_sense_isadma_cache : scsi_sense_cache; } -static void scsi_free_sense_buffer(struct Scsi_Host *shost, - unsigned char *sense_buffer) +static void scsi_free_sense_buffer(bool unchecked_isa_dma, + unsigned char *sense_buffer) { - kmem_cache_free(scsi_select_sense_cache(shost), sense_buffer); + kmem_cache_free(scsi_select_sense_cache(unchecked_isa_dma), + sense_buffer); } -static unsigned char *scsi_alloc_sense_buffer(struct Scsi_Host *shost, +static unsigned char *scsi_alloc_sense_buffer(bool unchecked_isa_dma, gfp_t gfp_mask, int numa_node) { - return kmem_cache_alloc_node(scsi_select_sense_cache(shost), gfp_mask, - numa_node); + return kmem_cache_alloc_node(scsi_select_sense_cache(unchecked_isa_dma), + gfp_mask, numa_node); } int scsi_init_sense_cache(struct Scsi_Host *shost) @@ -68,7 +68,7 @@ int scsi_init_sense_cache(struct Scsi_Host *shost) struct kmem_cache *cache; int ret = 0; - cache = scsi_select_sense_cache(shost); + cache = scsi_select_sense_cache(shost->unchecked_isa_dma); if (cache) return 0; @@ -1137,6 +1137,7 @@ void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd) { void *buf = cmd->sense_buffer; void *prot = cmd->prot_sdb; + unsigned int unchecked_isa_dma = cmd->flags & SCMD_UNCHECKED_ISA_DMA; unsigned long flags; /* zero out the cmd, except for the embedded scsi_request */ @@ -1146,6 +1147,7 @@ void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd) cmd->device = dev; cmd->sense_buffer = buf; cmd->prot_sdb = prot; + cmd->flags = unchecked_isa_dma; INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler); cmd->jiffies_at_alloc = jiffies; @@ -1846,6 +1848,7 @@ static int scsi_mq_prep_fn(struct request *req) struct scsi_device *sdev = req->q->queuedata; struct Scsi_Host *shost = sdev->host; unsigned char *sense_buf = cmd->sense_buffer; + unsigned int unchecked_isa_dma = cmd->flags & SCMD_UNCHECKED_ISA_DMA; struct scatterlist *sg; /* zero out the cmd, except for the embedded scsi_request */ @@ -1857,6 +1860,7 @@ static int scsi_mq_prep_fn(struct request *req) cmd->request = req; cmd->device = sdev; cmd->sense_buffer = sense_buf; + cmd->flags = unchecked_isa_dma; cmd->tag = req->tag; @@ -2003,10 +2007,13 @@ static int scsi_init_request(struct blk_mq_tag_set *set, struct request *rq, unsigned int hctx_idx, unsigned int numa_node) { struct Scsi_Host *shost = set->driver_data; + const bool unchecked_isa_dma = shost->unchecked_isa_dma; struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); - cmd->sense_buffer = - scsi_alloc_sense_buffer(shost, GFP_KERNEL, numa_node); + if (unchecked_isa_dma) + cmd->flags |= SCMD_UNCHECKED_ISA_DMA; + cmd->sense_buffer = scsi_alloc_sense_buffer(unchecked_isa_dma, + GFP_KERNEL, numa_node); if (!cmd->sense_buffer) return -ENOMEM; cmd->req.sense = cmd->sense_buffer; @@ -2016,10 +2023,10 @@ static int scsi_init_request(struct blk_mq_tag_set *set, struct request *rq, static void scsi_exit_request(struct blk_mq_tag_set *set, struct request *rq, unsigned int hctx_idx) { - struct Scsi_Host *shost = set->driver_data; struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); - scsi_free_sense_buffer(shost, cmd->sense_buffer); + scsi_free_sense_buffer(cmd->flags & SCMD_UNCHECKED_ISA_DMA, + cmd->sense_buffer); } static int scsi_map_queues(struct blk_mq_tag_set *set) @@ -2092,11 +2099,15 @@ EXPORT_SYMBOL_GPL(__scsi_init_queue); static int scsi_init_rq(struct request_queue *q, struct request *rq, gfp_t gfp) { struct Scsi_Host *shost = q->rq_alloc_data; + const bool unchecked_isa_dma = shost->unchecked_isa_dma; struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); memset(cmd, 0, sizeof(*cmd)); - cmd->sense_buffer = scsi_alloc_sense_buffer(shost, gfp, NUMA_NO_NODE); + if (unchecked_isa_dma) + cmd->flags |= SCMD_UNCHECKED_ISA_DMA; + cmd->sense_buffer = scsi_alloc_sense_buffer(unchecked_isa_dma, gfp, + NUMA_NO_NODE); if (!cmd->sense_buffer) goto fail; cmd->req.sense = cmd->sense_buffer; @@ -2110,19 +2121,19 @@ static int scsi_init_rq(struct request_queue *q, struct request *rq, gfp_t gfp) return 0; fail_free_sense: - scsi_free_sense_buffer(shost, cmd->sense_buffer); + scsi_free_sense_buffer(unchecked_isa_dma, cmd->sense_buffer); fail: return -ENOMEM; } static void scsi_exit_rq(struct request_queue *q, struct request *rq) { - struct Scsi_Host *shost = q->rq_alloc_data; struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); if (cmd->prot_sdb) kmem_cache_free(scsi_sdb_cache, cmd->prot_sdb); - scsi_free_sense_buffer(shost, cmd->sense_buffer); + scsi_free_sense_buffer(cmd->flags & SCMD_UNCHECKED_ISA_DMA, + cmd->sense_buffer); } struct request_queue *scsi_alloc_queue(struct scsi_device *sdev) diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index b379f93a2c48..16351de31243 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -56,6 +56,7 @@ struct scsi_pointer { /* for scmd->flags */ #define SCMD_TAGGED (1 << 0) +#define SCMD_UNCHECKED_ISA_DMA (1 << 1) struct scsi_cmnd { struct scsi_request req;