Received: by 10.223.176.5 with SMTP id f5csp1039416wra; Fri, 2 Feb 2018 10:07:24 -0800 (PST) X-Google-Smtp-Source: AH8x225AYkfPyWGXOTqZMDLFzrC+uQnH/gtajffCytP+gRcMmS7i/vZ/k55OBchbJ3eqANrd5bJ6 X-Received: by 2002:a17:902:3363:: with SMTP id a90-v6mr34805387plc.159.1517594844206; Fri, 02 Feb 2018 10:07:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517594844; cv=none; d=google.com; s=arc-20160816; b=SF8pQ3pEcvxq051BUrmIxzYN0hxpCLx3k9jnxuVgJb0Zdd01fy+7TlNJlg7bvpzuT3 K4uEzMMB+aPzZOKJb5nTcHw4XW/QJyO3fZo72832miMLD7Y5hnEk3uhPJBwkZ06o41e7 I5z6jlMN3YdrLS8/lShPskFYjRxyY5rkSpocohzbKwX+5/+gxTeT4xSbgpr6i3vvE48f lhaAXNmeVguQWQeyq3VER7S1yZYTfr5AILJIN8+6LV5HRsgISOrcZJeIiZKTgIJquqpl HJeW4iQgJS3idtp+Blt7cmZfR50QBOXhWbxgOMS60FqX+SoGwanXJz4eQSm2VbQz0qdh NPvA== 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=8ZyaLLjrTK7rYbgEKjRNOG7bwhZji4imSkWtPXZKc50=; b=WMTJ8bxgfvaiXR/bkYx33gRWYW7jYW+ug0PZ62IKavPAVOWH+jMHzElX1YTJZgLOQc hjB5CdYSBNO9AyKHp15neYlwRiKzjdaDprBqdtRiaB9SwxhhRvQmPAmRi8VBgyxCbIPZ 9At7OdqN4uHlB24g9vT2MyYBmk6JCI+w2swfETRwiU1RrajAk6rTyzkOZTPstQ2OxMvC h7afvg4riF4IxkCj6TgyeicXO8odloHy4K9cTuHMSEWZfXF7FsKCcoOXcPPgkSnY83aU 5RMQT82ivCzrZVxJJob1AZwtGjYzwcVptzwx1r89iuwG2/5PIO1/4FYOnUQUdeJWhYM0 1V3Q== 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 v81si638529pgb.570.2018.02.02.10.07.09; Fri, 02 Feb 2018 10:07:24 -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 S1753949AbeBBSFw (ORCPT + 99 others); Fri, 2 Feb 2018 13:05:52 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:37230 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753200AbeBBRIK (ORCPT ); Fri, 2 Feb 2018 12:08:10 -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 781BDEFF; Fri, 2 Feb 2018 17:08:09 +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.14 028/156] scsi: aacraid: Fix udev inquiry race condition Date: Fri, 2 Feb 2018 17:56:49 +0100 Message-Id: <20180202140841.576350772@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@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.14-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);