From patchwork Thu Jun 1 23:27:00 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: 9761355 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 D648D602BC for ; Thu, 1 Jun 2017 23:27:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7F5228524 for ; Thu, 1 Jun 2017 23:27:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCEAF28544; Thu, 1 Jun 2017 23:27:40 +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 0A09728524 for ; Thu, 1 Jun 2017 23:27:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751193AbdFAX1i (ORCPT ); Thu, 1 Jun 2017 19:27:38 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:5112 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751148AbdFAX11 (ORCPT ); Thu, 1 Jun 2017 19:27:27 -0400 X-IronPort-AV: E=Sophos;i="5.39,281,1493654400"; d="scan'208";a="124764479" Received: from mail-cys01nam02lp0048.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([207.46.163.48]) by ob1.hgst.iphmx.com with ESMTP; 02 Jun 2017 07:27:25 +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=dTg5BNbBQQWvigw08Ph/GdfagALFQptuuUSLqurPE/A=; b=erDUQ+za4EQ+cDXjiYh3d0ud5SVwIdQJ4q8emvrxaMcL/s3aVbBFaHj7aKkFhdxajdH6FUTgk7LThmIaTLRlKK/Da4JlvZmKUyidvIYprHhMSll7V34T6Df65Bml2iF3qA+kyGSCFbK3yybuWfZiyV9FbBCzhNQB9xjNab+AgAs= Received: from DM2PR04CA029.namprd04.prod.outlook.com (10.141.154.147) by BLUPR0401MB1682.namprd04.prod.outlook.com (10.162.214.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1143.10; Thu, 1 Jun 2017 23:27:22 +0000 Received: from CO1NAM04FT050.eop-NAM04.prod.protection.outlook.com (2a01:111:f400:7e4d::209) by DM2PR04CA029.outlook.office365.com (2a01:111:e400:243c::19) 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; Thu, 1 Jun 2017 23:27:21 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.21) smtp.mailfrom=sandisk.com; suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=bestguesspass action=none header.from=sandisk.com; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.21 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.21; helo=milsmgep15.sandisk.com; Received: from milsmgep15.sandisk.com (63.163.107.21) by CO1NAM04FT050.mail.protection.outlook.com (10.152.91.145) 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; Thu, 1 Jun 2017 23:27:17 +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 93.A8.51736.3D2A0395; Thu, 1 Jun 2017 16:27:16 -0700 (PDT) Received: from milsmgip11.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; Thu, 1 Jun 2017 16:27:14 -0700 X-AuditID: 0ac94369-6dc8f9800000ca18-98-5930a2d37fb6 Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id BC.83.11415.2D2A0395; Thu, 1 Jun 2017 16:27:14 -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 v2 01/12] Avoid that scsi_exit_rq() triggers a use-after-free Date: Thu, 1 Jun 2017 16:27:00 -0700 Message-ID: <20170601232711.29062-2-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170601232711.29062-1-bart.vanassche@sandisk.com> References: <20170601232711.29062-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCLMWRmVeSWpSXmKPExsXCddJ5ke6VRQaRBs/nMFoseLOXzWLl6qNM FrOnNzNZbOznsOi+voPNYvnxf0wWL+ddYbdYsPERowOHx7RJp9g8Fu95yeSx+2YDm8fHp7dY PNZvucricWbBEXaPz5vkAtijuGxSUnMyy1KL9O0SuDIuT8srOGVaMeOrbgNjp24XIweHhICJ xNFrQV2MXBxCAkuZJOb+msIG4WxllFg36ShTFyMnWNG8eVPYIRIbGSVWz/zEDpJgEzCS+PZ+ JguILSJQKHFpWwcjSBGzwFtGiXtb/7CBrBAW8JVoWOgMYrIIqEi8+O0HYvIK2Ev0Hy2HGC8v cXbLTmYQm1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2eRc7zSv8Ut4kZavEUpyRaKjFXFScCABvRaOE2QEA AA== MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:63.163.107.21; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(39400400002)(39860400002)(39410400002)(39850400002)(39840400002)(39450400003)(2980300002)(438002)(199003)(189002)(9170700003)(5003940100001)(2950100002)(47776003)(6666003)(50986999)(76176999)(77096006)(305945005)(189998001)(54906002)(106466001)(33646002)(5660300001)(53936002)(38730400002)(4326008)(230783001)(478600001)(1076002)(50226002)(72206003)(50466002)(48376002)(36756003)(2906002)(81166006)(356003)(8936002)(86362001)(8676002)(575784001); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR0401MB1682; H:milsmgep15.sandisk.com; FPR:; SPF:Pass; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM04FT050; 1:zqEDbi0YNMem5u2Z3SmcYNzrln24miP2rImzxx7VCupEcAO69f+6tqD6wGRJo916xKtG24x2yV45s8618pYzT8aG9fLjuCnCO9UAaINLqNzCtCL1xQst6fvXvo4fhDfW3GHZ46QG22xAOhi2XHyBG6aDRQzL1rOhs/YUkLR/t4fOCpUAocokSh7ZCIUg8RiuSJHQr2po9XOpBRLus9f7Nou0dWAHhgZkNUf71r3XrPrmif9FCZu2r/VB78GnmYxXCD4uaa+V2fydLncdKxTRgTREYrymv/HTPuU8292f5xek2oUjkf54gLqRf0ucVxFgEWFg8tRcXG619uYsiaJjaTx4OpWBWdkgXSiSF5HNjrc8w/TeW2gp6aMUV6CKZnAn5c+VWm7abeOrLRT+udvTjAVE1KLHEWiCizf+3KZ7v1Pi2rJQWUOcXxF96IRLtLpJmKV71FL0k0vYGLR9M2WCaovmfTx6bm4rNh+xfdB2Fzw+Jwb5OTyJ4+ftXrE2sxakFO9EfdzQn+amyzegCxLl9I5K6Ms2NqqrOSMWKdoK4YpPmGd7BChULx9m0pWmU2IClAeg3XJGRQUTvsuX62ssglRwyEso5EmxF8/WJnVAp8k= X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BLUPR0401MB1682: X-MS-Office365-Filtering-Correlation-Id: 3b352fa9-83c6-4329-d3be-08d4a945c036 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081)(201702281549075); SRVR:BLUPR0401MB1682; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0401MB1682; 3:TcEXRr7JnZQ7/BoiOzpcSODwl883e3bAOyiCutdKzHJBT/VGCDJzLbEYsQAyRTsLWGiAfbXFBC6UzbKfgSVIRROV9qnrSbu7IMeDfA8KJvI2Z2xdoWpJ812sypg7V11XJPnREj+Gs2dRn1Ve1zGTPdA4XAYrvN5QXmGBGYXULssVDruH+e7iLV4BlvVYe57pdgyJQc6/so5vSeKDNfyHewTo4tGGZvc/YeAIeFs+p5QZNy2rkf+7aIAKhGWciBeNznQRyC8vK/0kr3pdTaUz1Y1g9NVn0i0Yq2lKwbkUfvNRcUsDHbq2vFFEijAQND14lYRKExZVgqeC4PWf9+0mESUymrDAC+BffTXtv6aj7hrKIdl3dAhWqifRG1o4X4zxBvUEEGibnNxFrpVDaDr93w6HA1W3pzL2ETjjsq214Wa0SkdQzC+VVOwKdDGpR4zw6T3nXUv8TXIPhp4Rotxfre/VRnN/s2jJPXhyOyyw9wG88dHDdo67y503hsbWU0hhmDY2uUg85wUU/LzdbLCQPw== X-Microsoft-Exchange-Diagnostics: 1; BLUPR0401MB1682; 25:2OLUieBIPjoPH7N3J52sOFdiQDHKztziO0GX2tclTuL7K+/ztzEpiC+d2xXms6Y4AM9vMXmH00iI2Aa38PXdzDfNJ9Dl7OqsRiQl+4eDLZyBstftFEwjlciDlHePgfQFDQFq3neGoGpmo33Bxn6wog4NNeMGLl4M3rQFgvq9WVWw9Isi4Z03hp5CjJMr+E452/mogQM61v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EXb3kzT8UZN2REOqQeNkE1sfHJm0UoAdw/quAqAPAZnyDSJ82xSX832g6EkakhA3Ix93M 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)(8121501046)(13016025)(5005006)(10201501046)(93006095)(93004095)(3002001)(100000703101)(100105400095)(6055026)(6041248)(20161123562025)(20161123558100)(20161123560025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BLUPR0401MB1682; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BLUPR0401MB1682; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0401MB1682; 4:9x6WCbKjshvWb9lO6QfbWr2MFGaC9LICq4NAWW25?= =?us-ascii?Q?qGpAyxv3VSQOreAW+x0W5tQYSv2GPEs6DaswrgwshJfgG/hCEBwfl2s4T1Eq?= =?us-ascii?Q?Pdh+06ajXuMgjRSkNBYYXzA6BmW+oUPnRsWHb9/Hsp23QtReLCtpg7sFIqyj?= =?us-ascii?Q?pW/ltk5ULeV8WGo/0Iqy9ALuOvABGEYsedF/sAyjglm4n0X/bv9CVDD8iidc?= =?us-ascii?Q?CXD6W0XdBKEOvMgm5DssGU8yEUtD9s8+1pWBvrrTB2wP55hfopQOukn/UKNG?= =?us-ascii?Q?NDOaQjVqCVo2w0L2C9+0bpi31tQS3rJIbETneAJH0Ve07pPr4xhT5Z4flPmD?= =?us-ascii?Q?v5ZSqk8FHlbOaXiSt7oXU1sjkbje3RLeQs2J6NrZe8NY0OzuMF/dWsGJTg5B?= =?us-ascii?Q?hbeT8N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cLXNDACt/XS0T?= =?us-ascii?Q?q5NxqHix+RIAe/gbNUFpNGw=3D?= X-Forefront-PRVS: 0325F6C77B X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0401MB1682; 23:W8ne8/krBjz/M+VeuVX7oXVmQSy677AJLLebR86?= =?us-ascii?Q?bhazWIDTesLPiT6If1sBGtgtmM3CnF+VdVf3xzmDdTtnJDElWTqpDbVDEEC4?= =?us-ascii?Q?qn3PtZXNyfq1+9GPyjZFIty/+WssSVAPUShcIoJqaKhi26/oO3FpN1ITORnO?= =?us-ascii?Q?JTgelc46iviIBG+hp8j6j2xU39aeSWnk2rpDblb2mIOAUJ8MYdvgUMNHdT3Q?= =?us-ascii?Q?mwFXnphLn5jUgzIFUR3G3MjqQAyXIpWWYOsDphbERIyQ2QCG3Y8T9WBJ6S+g?= =?us-ascii?Q?MK6fIxJmSG/fZY0/TQD6eMdPXN+9vEpnmdJJLzAJgxoYtdn46h6wddyAZyaU?= =?us-ascii?Q?0fW4XniA+1QUtlrIW/DhN7vsMgNBOwHAVeACP65ab5HJxASHOkjhKq9PdXo7?= =?us-ascii?Q?dE2rDjs/OC3ySyQGMplhqgBuHVGinG/yTn5a+x0e0jWyaZ88VozpdAta7wr1?= =?us-ascii?Q?4wGdAphCQosZIuMi7KYRP04MFe/wUwaf7CzNk7PjfX8Fb4EhJGs3KCtkdeNt?= =?us-ascii?Q?li06vKqeGpo/tDr3V2FXGQY5SvvX4ev9+BJOKVy1IJ/w03zH9EQW22rmaCT+?= =?us-ascii?Q?bgej1mLBb9xdhJvsMgSUdaL5v9K1jGHOLHOgJQt5G7u2EiDI7VYbVJHIGjK3?= =?us-ascii?Q?S83RbXzhwU7E9h3dD4ulbvplyO30ZlYvLI3qK5lY7+hz86vERaifSOGdaEiC?= =?us-ascii?Q?Q/Kfjt7dC1utIW5xhE0t2I77hv7snhBsfyeYPL+dZrxoSuuct4uy2KPCCboE?= =?us-ascii?Q?XES/7q6Tz0OOXdf9f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/6I+zwQDmAKGHjTrJQn+pHpREY9dYL2e0bm9eQOrK17V+vKvGWX9pNN4NloKLeNjZg6a7xE1oDgEtDpiYGj7dXMoA70KPTSkRUQ0lbgK8jLw2iY8JBhhRSmZZ1Q= X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2017 23:27:17.7949 (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.21]; Helo=[milsmgep15.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0401MB1682 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 Cc: Hannes Reinecke Cc: Scott Bauer Cc: Christoph Hellwig Cc: Jan Kara Cc: Reviewed-by: Christoph Hellwig --- 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;