From patchwork Wed Dec 27 04:34:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raghava Aditya Renukunta X-Patchwork-Id: 10133381 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 B6ECB605B4 for ; Wed, 27 Dec 2017 04:35:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E3F02DA60 for ; Wed, 27 Dec 2017 04:35:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89FCF2DA67; Wed, 27 Dec 2017 04:35:04 +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 23F002DA5E for ; Wed, 27 Dec 2017 04:35:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751539AbdL0Ee7 (ORCPT ); Tue, 26 Dec 2017 23:34:59 -0500 Received: from mail-by2nam01on0067.outbound.protection.outlook.com ([104.47.34.67]:23244 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751332AbdL0Ee6 (ORCPT ); Tue, 26 Dec 2017 23:34:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mscc365.onmicrosoft.com; s=selector1-microsemi-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=1n9yoClXsJjlJGbVN33U50ATM+ErJCM8zWRqO1E8CyM=; b=C+eV78TlWb83/mlN7S2LKdoADUT/db/abjoN48qRPcqs4Q5aGNTWv3hfzLEd3R1pmDwwXe1YFoqEGw0l3oV8Z9f+nM3C4kF9jOkPBARoy19B/N1tYpBDB2gfWWF/eCJkanquo52PKwBEwGK4aR3/YABZM2Yk3wd4K6ZicEaacvg= Received: from CY4PR02CA0002.namprd02.prod.outlook.com (10.169.188.12) by CY1PR0201MB1836.namprd02.prod.outlook.com (10.163.55.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.366.8; Wed, 27 Dec 2017 04:34:55 +0000 Received: from BL2FFO11FD049.protection.gbl (2a01:111:f400:7c09::182) by CY4PR02CA0002.outlook.office365.com (2603:10b6:903:18::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.366.8 via Frontend Transport; Wed, 27 Dec 2017 04:34:55 +0000 Authentication-Results: spf=pass (sender IP is 208.19.100.21) smtp.mailfrom=microsemi.com; wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=bestguesspass action=none header.from=microsemi.com; Received-SPF: Pass (protection.outlook.com: domain of microsemi.com designates 208.19.100.21 as permitted sender) receiver=protection.outlook.com; client-ip=208.19.100.21; helo=avsrvexchhts1.microsemi.net; Received: from avsrvexchhts1.microsemi.net (208.19.100.21) by BL2FFO11FD049.mail.protection.outlook.com (10.173.161.211) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.345.12 via Frontend Transport; Wed, 27 Dec 2017 04:34:35 +0000 Received: from localhost (10.181.72.13) by avsrvexchhts1.microsemi.net (10.100.34.105) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 26 Dec 2017 20:34:52 -0800 From: Raghava Aditya Renukunta To: , , CC: , , , "Guilherme G . Piccoli" , Bart Van Assche Subject: [PATCH v2 01/30] scsi: aacraid: Fix udev inquiry race condition Date: Tue, 26 Dec 2017 20:34:22 -0800 Message-ID: <20171227043451.27813-2-RaghavaAditya.Renukunta@microsemi.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20171227043451.27813-1-RaghavaAditya.Renukunta@microsemi.com> References: <20171227043451.27813-1-RaghavaAditya.Renukunta@microsemi.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:208.19.100.21; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39380400002)(396003)(346002)(376002)(39860400002)(2980300002)(438002)(189003)(199004)(53936002)(478600001)(54906003)(2906002)(51416003)(72206003)(76176011)(4326008)(8936002)(1076002)(76506005)(57986006)(50226002)(16586007)(36756003)(8676002)(68736007)(316002)(69596002)(110136005)(305945005)(356003)(47776003)(6666003)(48376002)(50466002)(97736004)(106466001)(81156014)(81166006)(2950100002)(106002)(77096006)(2201001)(104016004)(86362001)(5660300001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0201MB1836; H:avsrvexchhts1.microsemi.net; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD049; 1:SkZ/dbO5GrASVM4Mw0bnjqUEzkpJVpk/5ehYTSCpsCa93rLoIl0m0vk5/Ky7W1z8hxmpq/Vg3bBXw9PBJ6jt0/h4ziRi5YAbi8CtwT/foyUC9SChR8X92x4q4Hkik7bo X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7a5dc6a7-95be-4e5a-ae60-08d54ce32273 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(4608076)(2017052603307)(7153060); SRVR:CY1PR0201MB1836; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB1836; 3:iQMucx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z5/By0M+NsTjqBgCD4SNFOvzifKfT5MH6ZzSDPlmxq8LjE8jpmpPUvWOqnHiRAUU5Eh3R3n2oOfTKNL2RBS/rTU0/vTGjaG/jou8xobK2rSQbJI38Lmc1qT+8B/wTFF/YLvd86WhaiocOVqnE3dIW/UCZGLxzcDGUQjN3ZPlJFBzYWyQ0/UWTYR9tDSwVMXx7b5rzYric5avoP1mj20oHbgbF41LLHQxt0UCt07RsYPBLyGK5SRNAE3TiuW8cBigO96c+ubqUY22Rr7hbvg3X7dYicQcX6AVAXhZL8jM9f0L/Hydm7kFhzuHHG32Yr7wdcMcii7g4VJXj7S4xbXN4Vprbk2aos3mbJsx9KK18Cl6KzSD03bFoMcS/BjSV/DjEyp12JcMGCySvpkbQXPF0ymlM6CcGQx9jxsc2rqS+TltPJx1x0Y4FEsPnIbocv8EpyFKizKTW2DwdG96eqpeFCFzyJ7VmVBcLpSM1VI7ifLOIHt1YgJUEOE5QP0BO/Fii38pThgedeMjS8txrIxsyZBMpi0WCuajux90Hdg7w2jDORfgHdcLLaUt5Zz8EYKqbM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(72170198267865); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93004095)(3231023)(944501075)(6055026)(6041268)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(6072148)(201708071742011); SRVR:CY1PR0201MB1836; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CY1PR0201MB1836; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB1836; 4:H+I4BPpyV7mu/FMFl3El3VjRTElOTha4cJ8shGv6RpH8ynK2MvIsxqcCOeENQXOA3drmPh9M+WRIg1rwJqnrDgdA6SEo2KxmCCiIGoKA1XUHg6AnXmVvOKVrnsnm5TRLIPu8ObEliv6qe1w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FMA39nJPg7BEltROZ+H12bswwgl83jYo+0RD+oULYuD3LELd6EJFiSCABwVT3kNH91sVywyTQskkoUkI=; 24:V/t1dHfRJDW+0+n4GkLBO3o8JYWRMfwm6usXX8uDzi64T4IpUQgSeh1gm8zlqWZbo79hH72HnuFZ1K8+zYix6wdCEHvtUl0mTIlHETH7Sn0=; 7:Mxu49BFhCBqXbqZq0Mz7Tub8N/50tq2MvlP2lui27ByN55I7HG5o0fFQ3eKmWqDDBAEXDiZMaP35pkaYiFtiJuFIMq7ySrbb0RrszybmOcjGQOCVRVVzqmtQ6PZ8hLjwBJyOGOZkvlwGS7X2n60vJ0FmvjRKDZRFsE9PXoDtvlWOWuqKvh8WidKWiG9aMlVtYPUPMxvISE6lPVPX0Itf5uqsKtjaGprU+dtSH6ozxvsLFFW8JzLZhU9fSfkWOzVn SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: microsemi.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2017 04:34:35.8811 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7a5dc6a7-95be-4e5a-ae60-08d54ce32273 X-MS-Exchange-CrossTenant-Id: f267a5c8-86d8-4cc9-af71-1fd2c67c8fad X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f267a5c8-86d8-4cc9-af71-1fd2c67c8fad; Ip=[208.19.100.21]; Helo=[avsrvexchhts1.microsemi.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0201MB1836 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 When udev requests for a devices inquiry string, it might create multiple threads causing a race condition on the shared inquiry resource string. Created a buffer with the string for each thread. Cc: Fixes: 3bc8070fb75b3315 ([SCSI] aacraid: SMC vendor identification) Signed-off-by: Raghava Aditya Renukunta --- Changes in V2: Replaced kmalloc and memcpy adapter_type_text with kmemdup drivers/scsi/aacraid/aachba.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index af3e4d3..548a3e7 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -913,8 +913,16 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex) memset(str, ' ', sizeof(*str)); if (sup_adap_info->adapter_type_text[0]) { - char *cp = sup_adap_info->adapter_type_text; int c; + char *cp; + char *cname = kmemdup(sup_adap_info->adapter_type_text, + sizeof(sup_adap_info->adapter_type_text), + GFP_ATOMIC); + + if (!cname) + return; + + cp = cname; if ((cp[0] == 'A') && (cp[1] == 'O') && (cp[2] == 'C')) inqstrcpy("SMC", str->vid); else { @@ -923,7 +931,7 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex) ++cp; c = *cp; *cp = '\0'; - inqstrcpy(sup_adap_info->adapter_type_text, str->vid); + inqstrcpy(cname, str->vid); *cp = c; while (*cp && *cp != ' ') ++cp; @@ -937,8 +945,8 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex) cp[sizeof(str->pid)] = '\0'; } inqstrcpy (cp, str->pid); - if (c) - cp[sizeof(str->pid)] = c; + + kfree(cname); } else { struct aac_driver_ident *mp = aac_get_driver_ident(dev->cardtype);