Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2349489imm; Thu, 7 Jun 2018 09:10:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLdshCft2KKzTx9jEuKBUcyUOT98nfVrFsD2R6DNZJSNKi3CM/4l4I/SdO33zcq1tkABiH+ X-Received: by 2002:a62:221a:: with SMTP id i26-v6mr2368612pfi.240.1528387820337; Thu, 07 Jun 2018 09:10:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528387820; cv=none; d=google.com; s=arc-20160816; b=wzLKZTUoYr9jwMQy8jDl3J08cRe63hbT9vvd08TaSydmemOi80JCP67TOmnOObJckT 3+N7c2gMhFuXv4TdeK8bSC5oowUD5UYTacrfVB1SBEE2GeoO2RiWZLSnnAIr3hkvGx94 L7MN9wVeKL8uxOMPMQtLlwlvtn+fOgK64Av37gBW5xEBqiaIrdOs4GY6oxrMt/H8+SvN BcpYr7OHQ8BYZawQyRncQUd0z3H5tDh+AdCFUJNVavoeA4tX39tDxL9au4aTfjBSSs70 vOZsCqakfrocVdyum8ZbiL/pQpxQ61Zj7bGqlqwrUSSF0dP8Kb9jnolwFfmOZP9c3Zk8 nTeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=Xuq8JTXrOAyf11GMos1ZPos7c+ArGXLU8St/42DRhCE=; b=cU9ZgJdkbY9acZuzP8zf5+txGiZjSdlrKxtpWcWXeTPKkTyWQgCyYHg6USJZMZ3cM+ JJe7r/OMubxGtEoPU0gTJm5usTpWMXgMa4foMpvgCb+eJYzUmN9bWvnXruKYQbR0OkqP IijjHBrMGxyHlCJVW0M6EKXH0NzZGz6vwZFtBU9h/BBH0vmRnIUqejPpIKkp2zJx9YaU U6VuQqdl/YE9VV+a5du7nYoSyyV2wLBJTLxt2O4dC50AeHIBkEYolF5N84dJB4m4JWvr 8CCpCBeOWRAriZaHRHEh8Q7DEqQpfOeFeX7nz/s94WC+C0CaPYMl0jjDrSif68VL/aH/ 6oEw== 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 a5-v6si5502245pgu.119.2018.06.07.09.10.05; Thu, 07 Jun 2018 09:10:20 -0700 (PDT) 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 S934394AbeFGQFD (ORCPT + 99 others); Thu, 7 Jun 2018 12:05:03 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39257 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933019AbeFGOJE (ORCPT ); Thu, 7 Jun 2018 10:09:04 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvb4-0005Zn-90; Thu, 07 Jun 2018 15:09:02 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb1-0002on-4k; Thu, 07 Jun 2018 15:08:59 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Martin K. Petersen" , "Raghava Aditya Renukunta" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 094/410] scsi: aacraid: Fix udev inquiry race condition In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 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 [bwh: Backported to 3.16: - s/sup_adap_info->adapter_type_text/dev->supplement_adapter_info.AdapterTypeText/ - Adjust context] Signed-off-by: Ben Hutchings --- --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -770,8 +770,16 @@ static void setinqstr(struct aac_dev *de memset(str, ' ', sizeof(*str)); if (dev->supplement_adapter_info.AdapterTypeText[0]) { - char * cp = dev->supplement_adapter_info.AdapterTypeText; int c; + char *cp; + char *cname = kmemdup(dev->supplement_adapter_info.AdapterTypeText, + sizeof(dev->supplement_adapter_info.AdapterTypeText), + GFP_ATOMIC); + + if (!cname) + return; + + cp = cname; if ((cp[0] == 'A') && (cp[1] == 'O') && (cp[2] == 'C')) inqstrcpy("SMC", str->vid); else { @@ -780,8 +788,7 @@ static void setinqstr(struct aac_dev *de ++cp; c = *cp; *cp = '\0'; - inqstrcpy (dev->supplement_adapter_info.AdapterTypeText, - str->vid); + inqstrcpy(cname, str->vid); *cp = c; while (*cp && *cp != ' ') ++cp; @@ -795,8 +802,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);