Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp897356ybn; Wed, 2 Oct 2019 07:54:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqybJH27XvHOHX1TR9UvIX46c5rdVo13d+VxtetdV89a10yuSOYvMm0P8pE0w+LmJFULXrsv X-Received: by 2002:a50:9512:: with SMTP id u18mr4190938eda.182.1570028071926; Wed, 02 Oct 2019 07:54:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570028071; cv=none; d=google.com; s=arc-20160816; b=KguMEk5sYaTx2PW/Ae3rcGRzPh/cmk7jvuaOxc4sF7LW9dgo5udu9+J+4h55e830wB S3MZOPN9Rb4T8Mnam+apNDUSkot3VqIeuJRtjxOCq3dYjFja2PteXydOjf7zdwvcZNUy 0mQFdw1blT2ZIsYTd2MUr5Mdvfhg501w7L+U2/xHzsizZ04ZLlvg7EgKoUIcvfXoQSig JO3nLgs+sj1UrAra/qLAc7iVz58vNLwrIM8kKGCgvTyWQwu6xCCiSnxKwrNH7fLOLK+P WZAFbpkiR1R7frV27OuNzFsKu1liWzzKJaZH/T+tsKUetB72+tDbDsJof6OD4voNgtKX KLqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=XgrvHctv/ZqdaG9+8Dlvx02gr12w6VZP2x20/JwhWYM=; b=itacoInwmJk1+xe5jvajIcTMLJdXcMZwHx+yaWC9+c+n7q+f8+DaQWpVliMHUZ3zjO eNaXKvbTScp/euLuHOQu/UfIdF87eROXugecq/DxNsPM2t1S+awnjDCrlhOFHYAOBXNL JFy2xd/1XS/boNs0fiePVB551oPLjz5KFie+SWJeduoFv6i7nCdRAvoi/aeVd0foQQxS /b82yWJnhyn9pTr+Bogw4xUJxdIqQ1LVL8PykHVsxASVxHaREABQfi+oh2BwaVPlRSqi c0HLzwmySo7OPaY5aSNOyAIqNdnygWD5G79m8kRnuR/WzYFsitEtQg8xetK1q3KS/Qob bZdA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hpe.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d4si10616099ejy.154.2019.10.02.07.54.07; Wed, 02 Oct 2019 07:54:31 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hpe.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728248AbfJBOhL (ORCPT + 99 others); Wed, 2 Oct 2019 10:37:11 -0400 Received: from mx0b-002e3701.pphosted.com ([148.163.143.35]:33430 "EHLO mx0b-002e3701.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726951AbfJBOhK (ORCPT ); Wed, 2 Oct 2019 10:37:10 -0400 Received: from pps.filterd (m0134424.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x92EQN8M016140; Wed, 2 Oct 2019 14:36:14 GMT Received: from g4t3427.houston.hpe.com (g4t3427.houston.hpe.com [15.241.140.73]) by mx0b-002e3701.pphosted.com with ESMTP id 2vck9maha3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Oct 2019 14:36:14 +0000 Received: from g4t3433.houston.hpecorp.net (g4t3433.houston.hpecorp.net [16.208.49.245]) by g4t3427.houston.hpe.com (Postfix) with ESMTP id AC04A57; Wed, 2 Oct 2019 14:35:53 +0000 (UTC) Received: from [16.116.130.10] (unknown [16.116.130.10]) by g4t3433.houston.hpecorp.net (Postfix) with ESMTP id E92F445; Wed, 2 Oct 2019 14:35:49 +0000 (UTC) Subject: Re: [PATCH AUTOSEL 5.3 169/203] x86/platform/uv: Fix kmalloc() NULL check routine To: David Laight , 'Sasha Levin' , Greg KH Cc: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" , Austin Kim , Dimitri Sivanich , Hedi Berriche , Linus Torvalds , Peter Zijlstra , Russ Anderson , Steve Wahl , Thomas Gleixner , "allison@lohutok.net" , "andy@infradead.org" , "armijn@tjaldur.nl" , "bp@alien8.de" , "dvhart@infradead.org" , "hpa@zytor.com" , "kjlu@umn.edu" , "platform-driver-x86@vger.kernel.org" , Ingo Molnar References: <20190922184350.30563-1-sashal@kernel.org> <20190922184350.30563-169-sashal@kernel.org> <20190922202544.GA2719513@kroah.com> <20191001160601.GX8171@sasha-vm> From: Mike Travis Message-ID: Date: Wed, 2 Oct 2019 07:35:59 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-02_06:2019-10-01,2019-10-02 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 malwarescore=0 bulkscore=0 spamscore=0 impostorscore=0 mlxscore=0 lowpriorityscore=0 clxscore=1031 priorityscore=1501 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910020137 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/2/2019 1:34 AM, David Laight wrote: > From: Sasha Levin >> Sent: 01 October 2019 17:06 >> Subject: Re: [PATCH AUTOSEL 5.3 169/203] x86/platform/uv: Fix kmalloc() NULL check routine >> >> On Sun, Sep 22, 2019 at 10:25:44PM +0200, Greg KH wrote: >>> On Sun, Sep 22, 2019 at 02:43:15PM -0400, Sasha Levin wrote: >>>> From: Austin Kim >>>> >>>> [ Upstream commit 864b23f0169d5bff677e8443a7a90dfd6b090afc ] >>>> >>>> The result of kmalloc() should have been checked ahead of below statement: >>>> >>>> pqp = (struct bau_pq_entry *)vp; >>>> >>>> Move BUG_ON(!vp) before above statement. >>>> >>>> Signed-off-by: Austin Kim > ... >>>> --- >>>> arch/x86/platform/uv/tlb_uv.c | 4 ++-- >>>> 1 file changed, 2 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c >>>> index 20c389a91b803..5f0a96bf27a1f 100644 >>>> --- a/arch/x86/platform/uv/tlb_uv.c >>>> +++ b/arch/x86/platform/uv/tlb_uv.c >>>> @@ -1804,9 +1804,9 @@ static void pq_init(int node, int pnode) >>>> >>>> plsize = (DEST_Q_SIZE + 1) * sizeof(struct bau_pq_entry); >>>> vp = kmalloc_node(plsize, GFP_KERNEL, node); >>>> - pqp = (struct bau_pq_entry *)vp; >>>> - BUG_ON(!pqp); >>>> + BUG_ON(!vp); >>>> >>>> + pqp = (struct bau_pq_entry *)vp; >>>> cp = (char *)pqp + 31; >>>> pqp = (struct bau_pq_entry *)(((unsigned long)cp >> 5) << 5); >>>> >>> >>> How did this even get merged in the first place? I thought a number of >>> us complained about it. >>> >>> This isn't any change in code, and the original is just fine, the author >>> didn't realize how C works :( > > Mind you, the code itself if pretty horrid. > Looks like it is aligning to 32 bytes, easier done by: > pqp = (void *)((unsigned long)vp + 31 & ~31); > (and there's a roundup macro to obfuscate it somewhere.) > But I'd also expect to see a matching '+ 31' in the size passed to kmalloc(). > Not to mention a comment! > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales) > Thanks, I will put all of these comments in my notes. This whole function is slated to move to a specialized UV APIC driver since it uses a unique scaling feature available in the UV hardware. (The original author has long retired.) -Mike