Received: by 10.223.176.5 with SMTP id f5csp1002417wra; Fri, 2 Feb 2018 09:31:10 -0800 (PST) X-Google-Smtp-Source: AH8x227kMjnvMjBha3zW3kQwDlrZy1Tk3TFXesrAYd367Z01XxDJgWl8YmJQpuhoSVwvOzkaped9 X-Received: by 2002:a17:902:7c86:: with SMTP id y6-v6mr26321857pll.24.1517592670727; Fri, 02 Feb 2018 09:31:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517592670; cv=none; d=google.com; s=arc-20160816; b=SHgEXdgOatKGrN9YDmBkX0p7j9C0jC8Bb9rJiMOaIkz4RJ+QwpElEZ/hHhBKkWMZAp civwwnlFWQp1RMPiY1tv5oyxhimowcLGPU/wvNttwBC5OkD1q1KlwlrbR0gfuS3LMUF3 M2t9xvwGItJAEUiQ1YIry1zcGY6UC/o8KrrK8XwANDpGk/RzqZUjEI8LZvgGSli+DQSC S9YT1FES/jbj3eygyMWPH+3cwCieeB2jyjmnrQY2RtsejbC1MYMQL8f9yQAO8w/2TrY6 WkdC3elbaFckrOuWPMJPtKqcC2s1In/xGFbn/jMoyywN2X+8JKmfeoNDdousKGyyKmgV altQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=FBXi8meEScZlEneKHZGmjuUIN4AgkX1VnYSnFn6+xKE=; b=arAt+kelizkW6JRHRR9N+ZeWwwa8bIi1AtaWUgvTZRt/d2yOKATWFnyeTv0GNysBIo YmPj2a3+XGj6H1Bm7lLqRK6koAnkDrHN/D8uAXZA4HQDWNx6sujXghvSN+HhuRFNPSvR ckSBnOVWbUq1pbDB973M+S+3p2OAiUyS3pwbaaMD1rV9yR9xVrIGgItiGKzsFIcjE8ZT aoqO6vv2w3nPw3bhA8PLEF+x6QwEGTdwglD5wom2nzK1PZRXE5WKrcT57/AuMKpEY60+ pPCg9wl2hm+88LN4aCnclu2C06ELOT040JvDaZ+mgUCmLl26Zep2xzUT31ca01/hefzz 8MGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f30-v6si45646plj.658.2018.02.02.09.30.56; Fri, 02 Feb 2018 09:31:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753597AbeBBR2b (ORCPT + 99 others); Fri, 2 Feb 2018 12:28:31 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:41088 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753307AbeBBRQv (ORCPT ); Fri, 2 Feb 2018 12:16:51 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B41D7AD8; Fri, 2 Feb 2018 17:16:49 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Raghava Aditya Renukunta , "Martin K. Petersen" Subject: [PATCH 4.15 24/55] scsi: aacraid: Fix udev inquiry race condition Date: Fri, 2 Feb 2018 17:58:42 +0100 Message-Id: <20180202140828.711529542@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140826.117602411@linuxfoundation.org> References: <20180202140826.117602411@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Raghava Aditya Renukunta commit f4e8708d3104437fd7716e957f38c265b0c509ef upstream. 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. Fixes: 3bc8070fb75b3315 ([SCSI] aacraid: SMC vendor identification) Signed-off-by: Raghava Aditya Renukunta Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/aacraid/aachba.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -913,8 +913,16 @@ static void setinqstr(struct aac_dev *de 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 *de ++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 *de 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);