From patchwork Thu Dec 21 17:33:52 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: 10128089 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 675446056F for ; Thu, 21 Dec 2017 17:34:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5536229CE3 for ; Thu, 21 Dec 2017 17:34:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 49EDC29D1B; Thu, 21 Dec 2017 17:34:30 +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 A608F29D15 for ; Thu, 21 Dec 2017 17:34:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753199AbdLURe2 (ORCPT ); Thu, 21 Dec 2017 12:34:28 -0500 Received: from mail-by2nam03on0040.outbound.protection.outlook.com ([104.47.42.40]:15680 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752513AbdLURe0 (ORCPT ); Thu, 21 Dec 2017 12:34:26 -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=zv4kepSAi6vsjFWrGUXpZytA059YSHS/TMHzuIbitwY=; b=mQDaXKEa4tWxRnu9ob7fJS3u4UanR4jf7yy+JPhIs37nKKkjDaPCvH+gPBNhQPDXVQHrg63BLmJgaKuyFABuUbBmzE9ndpotei5CyOIY1jDMNHSAiftrPwjB+HEi+O93mUjHtgZEarWlCOCuK+EnsaT83wtD76+1Y7z9dLz9Mss= Received: from MWHPR02CA0036.namprd02.prod.outlook.com (10.164.133.25) 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.345.14; Thu, 21 Dec 2017 17:34:25 +0000 Received: from BN1BFFO11FD036.protection.gbl (2a01:111:f400:7c10::1:126) by MWHPR02CA0036.outlook.office365.com (2603:10b6:301:60::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.345.14 via Frontend Transport; Thu, 21 Dec 2017 17:34:25 +0000 Authentication-Results: spf=pass (sender IP is 208.19.100.21) smtp.mailfrom=microsemi.com; linux.vnet.ibm.com; dkim=none (message not signed) header.d=none; linux.vnet.ibm.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 BN1BFFO11FD036.mail.protection.outlook.com (10.58.144.99) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.302.6 via Frontend Transport; Thu, 21 Dec 2017 17:34:10 +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; Thu, 21 Dec 2017 09:34:20 -0800 From: Raghava Aditya Renukunta To: , , CC: , , , "Guilherme G . Piccoli" Subject: [PATCH 01/29] scsi: aacraid: Fix udev inquiry race condition Date: Thu, 21 Dec 2017 09:33:52 -0800 Message-ID: <20171221173420.8213-2-RaghavaAditya.Renukunta@microsemi.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20171221173420.8213-1-RaghavaAditya.Renukunta@microsemi.com> References: <20171221173420.8213-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)(376002)(346002)(39380400002)(39860400002)(396003)(2980300002)(438002)(199004)(189003)(51416003)(76176011)(50226002)(2201001)(69596002)(36756003)(53936002)(57986006)(76506005)(48376002)(50466002)(1076002)(4326008)(104016004)(356003)(106466001)(81166006)(81156014)(8676002)(8936002)(47776003)(106002)(97736004)(305945005)(68736007)(72206003)(2906002)(316002)(86362001)(6666003)(16586007)(2950100002)(5660300001)(77096006)(110136005)(478600001)(54906003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0201MB1836; H:avsrvexchhts1.microsemi.net; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD036; 1:mNbYpHPTdm21jl4RINOaYioEnThOqhYoIttTMi2WwXJRv3uK+3Kj8tgDlFrLih8k7oFvyULskZin5lHJ/oOW/zl5Cng0EH05ZxbTDJkOVvFNKtPh+60PLtjHOx2Sr4kd X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f61f6032-0f81-4b34-ab81-08d548990bde 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:01/sK1+4+m1vFpRjI62Jxmb6Wzmucj0DuEcRojUY0UOtR/6IlqkprcOsqrBW22Za3UbZylXJCJuMHCJ0Fczf3A8Np1z5G0kW5NrvO8QdEfq3Wajp/u2DT1ftRXbzLo2NblftfgeZTT+RHrOB5gtpM6vSnn0dHnnq4kShajqy6fkn5IoV1M0O6/1dtnxFLCZLlIJJQEkH3Ir6D4jurUaPSgGS9BpTRj2Ct2Mf8E4XwK0bH6QiBR1g51+LJ9LGpxWBVfrM1pUmuUQaJkPZGFS939hW4lLNoyd5PG67U05/IZUfSBOSGjx0vBswVXLJvV8cw93iTU9zoaTbLmxqaszik4GCDRFrDismazofXW0amaY=; 25:EDvsPqKHcP056hTYOzdB7xcLmZShg/ziZTI06uAnimbj9V+bqtgPu7pJkozGouRfkh0So17Teh8BNBaKWalQMYn1g6+R7B5AU5Xpo195uxOhi9k+iiuHfAbonLRKRUOsgrUGTo8vdi6YErooZvKLKgO3eOL53ICdOpgfjCwUkCT/oue8isLYOUgHvU4cuegTZOEmRKrYNHugrCOmafPsmhUA4q86VHp7hFQeHmQG1N1YWl0bFz6fh3Tilsfpkg6HWXETPNM08MuvfGwmhNhBk41F+nDnWjrbzEOVnhLPNESiD5zNR1OH3KRqMF6Vv4LcV8XREqHFa6kgLmbI20TYow== X-MS-TrafficTypeDiagnostic: CY1PR0201MB1836: X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB1836; 31:/jb4mUyFzcSxamLmqHg8oA7pMXX7+GkufvymIc6/0dCrTJ+cmaw99MXm5Y+vE5fKDb1GCBeyB4ddxHk4B+Zs5TbQSLZIcbgIl4YQb1kuN8RKCkanBM8r6OmsiZjMuaM90dyzTvPWyb3vi23d4bERygluRlKwK6bVQY3/IH6E5WKWQT16pblpI27jqR+9PEU6Nms8RyE/qoZGfFrhDSFq8Is8wIVh83clwDbYw/FJyjg=; 20:LNEdQfvODPShebjxz7kJKdq6fN3hMYdgXlATinUj9n+rqh+svERqN5OPrqQkCROezXF4QPrpuoWeKXpcqoUJmN17yuf21gI0+6zaPzrCVCorsitAp5XuiFVw0LkQ4wTEty4B4HwQxR8MGLrKJNiPKIwlV4rkZ82nbGlx/GK9PQPNmG7VplH60kpkGthO9BhTqF8cILhP7MxLAgQFY4TZCzrInxVhNVIvP7Gq0N0/Lb/Krp4JtYTza8a5HmAUxh4U/QqFzfFz99W0NujpCsEdrnNPKkK59Bq6JDDOCvaHfcJWM7BuE+iZc22YD4PZkFNYEuI82M0xv8OdttnhRm/jZk2iric3NWfy0J7GeDiN61tpibZzxQey1K7ZekQSD5tRxvdWZaJ6bItaOb4Z//ku6qIi4RzIrku3mSXCgvs6SI8A0NtWO7J1ln0nqlgLFRuqrxufQo9l2YpMJbTYXU2szZImEcuJCosDtBM+Ep1wlMNlME4JWiRk0toK2Fm65q8eyXTwGIbVTKMnDBEglV0XRPv3z3ig5rJWM4dBaihwXxe+rbkyadMvLgOUEU3iYdL8vEDkWEyPsceFP9t61efvDKV+SdQ75/9R8n/v5nhdi/M= 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)(93006095)(93004095)(3231023)(10201501046)(3002001)(6055026)(6041268)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(6072148)(201708071742011); SRVR:CY1PR0201MB1836; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CY1PR0201MB1836; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB1836; 4:foOq1m8JiUsQl3gpu4L2E2j6Ar/Uby1bkF6RH/JL9Ak3Nj/LcuKw71BGPfxisOlf1m7BbO05T5RMTmERxUCqltWjvjJG5c8n+FQUYZWvc+fcdpBcODPyMW4xlnMzL0wHi8kUwohYW/f5qtfyoz+gtdPB8rHXK34WAZYjwIeQddVgeY7u9dUv1jFySW5XVb1Kl6YBeCVIAePv7AbC6NDvMvWHLJ3Pv0MJrUaMZFeVHUchKzxSF9n8Xb1xXlbZkrxUFmiGEVfoO3iO4BY4t2Ev/2DxK1gRaJ7gXzffU7G9+BX14JGTWOKuzLzVIOKyc7mubKeJdhPfUF0QzGo7g01yT/Lc+/XJe1VoVU/01KLI5HM= X-Forefront-PRVS: 0528942FD8 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0201MB1836; 23:rQube1+zAJUi632SLCJRb+FDr7jBJDsClM4duag?= =?us-ascii?Q?XxEjMFhBJHFRV4CagO1z98bIuVuGYlK0ATIQG2iXPFfwuu4pBua/XJWAiUg8?= =?us-ascii?Q?LhrIvi+OV+5+x9qgiqHYZryKpAkPX5ZaQIYng7ByDBHFL9QQVMFXoCm0+M/B?= =?us-ascii?Q?cqe3tO8ECNwg+JsoRHqk13rps+n2DNuDCCJMWBYYLxRygTq+khGF42vClD3q?= =?us-ascii?Q?5Sav6p85X2N6B5Hn0mZsgKbAYk4PamAPqKpaVtwvx3LhdaEfQyV7SeSBaXr9?= =?us-ascii?Q?l2lI8vOAVlW2b/6CmYNhuiGbhOa5GR5srNOhhpBShUWtGRtdRTqxVX1+t27r?= =?us-ascii?Q?dBKh+dWTvTMz96tCaem3+8oG/tRSggSm8hK7coLdKDO6bm0dgm4KRSIPZGvI?= =?us-ascii?Q?t4kH52T4I57qcwYikEK7enKmHyHSnXFTZk/MHgLaP1EMpzUA4GT3b5GOIl0K?= =?us-ascii?Q?8Ef3yNQhBhMlkD0m9pSe01Xeb/wqQdt9SGfUWUm27iglsLD6Npl2B3APLApV?= =?us-ascii?Q?3vTH0tAmcrF8CU/2VwkGcbKsP5RMycyBEm0Qd8utwrQ40pLZQwRVSJdxXIUs?= =?us-ascii?Q?6v2q03iKHa8nKPClpv4PaXiACRu3VLKtcRn3DdBMuFKRIlLsk9JChBwDxPWS?= =?us-ascii?Q?TPSBL/8Nj46PmTyhz3k2fZy4dmvxN9WDq8YwYQ7R03doAAkaX3Afdqm/Q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24:ZBfBryYY1dWHgz0Qi21cvt46/rGbqpjcANFW7FSSomjsY2Kixc8PD0FA+YfFycGruXvDpCEvqwP6VfgCjhlaCUSDYH1NTQwUU7R3Mzf/iZA=; 7:8r256AFlaRGDqM7AxyKRClCNFavUdt1vtAsZRAy8BJbDLZBMckAYAt/ZUCXLoPeMZwB2NZfyHbEh9Zy4AJH3hhZFgkfhZ2jsqwYECVLXyg+3ij1ckMuL7eLS/OgfyzEfPd588fubLck1nTYf4H9EgBM9sRM27tnfBUrmyaCi9xiKm6bzrJ5k9Kou4/QY3phKF1sZP5DI5KFXp6iecIf47btju9ZzVWu23+H2Uzzi2H+aUFgkIQug18s0sZNzIcmu SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: microsemi.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2017 17:34:10.5699 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f61f6032-0f81-4b34-ab81-08d548990bde 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 --- drivers/scsi/aacraid/aachba.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index af3e4d3..f264515 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -913,8 +913,18 @@ 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 = kmalloc(sizeof(sup_adap_info->adapter_type_text), + GFP_ATOMIC); + + if (!cname) + return; + + cp = cname; + memcpy(cname, sup_adap_info->adapter_type_text, + sizeof(sup_adap_info->adapter_type_text)); + if ((cp[0] == 'A') && (cp[1] == 'O') && (cp[2] == 'C')) inqstrcpy("SMC", str->vid); else { @@ -923,7 +933,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 +947,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);