Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp7581252rwn; Wed, 14 Sep 2022 00:37:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR7f00hsQ991w57bLOIVLd2TdPF4tm87jFZE2CkGHBkCNvgyLZTVEbIEKnS8aIsQdgVtRlbU X-Received: by 2002:a05:6402:1946:b0:44e:a406:5ff5 with SMTP id f6-20020a056402194600b0044ea4065ff5mr29783158edz.14.1663141044424; Wed, 14 Sep 2022 00:37:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663141044; cv=none; d=google.com; s=arc-20160816; b=qaQsaB8hJ4bO3/jlLOHlska+soggy+aUPy5iVkNNmYutnIgLnODaeNgw+z92dRK15D 45RPAriE5+IfNmMmKKGXKhs1Otqhq0VKAsu+rnCvjGSekuYvdhnl6niMQszg3LHadFSq c2cbuYRhV1IWgC9x9/CRNUjmDQvwi2LWUxoUHkJUZS8gpM8qLvxfzosa+2Tssx/gPX0n ay/afv6NqetGStP2ewr232QVzgnuV76yLXVoC3jKBEFXI+OZ89wgFSwIl/Qf0PiMvIvA n193Naz6H19/+01/qOo/pCbSqcwVZDOaIlP3QDoxORxaV+76t1sNci7uaFdBjLN26dXr iRGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=TAWBq4OzD5cPlhTwzFDFAAVtgktr8BRKXhNz5ZrGpyA=; b=xAGyngl4DDIKsl4UAAh5TMF71sf4WNSihk6EZXdF8Se2CSmdmFvKS9TfVhyHB9vtJ/ 4PdtZx77REq3+0YhjmaWDlwoWsLmbvgh8OcnrW17dtRiMVxi8Cc6jgvO8Qsev6Zn5IA4 mPhHb8oP0JSX1b1wyPoZKAZWGD1ELlTi5k8OOynsFBIUjXK1POtm7FWy5FHuC/V/PcVb ct7XI1vi1aUtuXoDX9ysFv3yohOB1GNjk5Rmt3hg1CJ6HPdiKuCNucr6jq20p2i8Epy2 9iHUxDn1wnz/i9mzNbMcni2nqlBa9F5Fq3hEln/FXV4QRc3Jjp3OaRQpWrSkZrVgi2rO LHEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d4-20020a50fb04000000b00450f56cd37bsi7679375edq.175.2022.09.14.00.36.56; Wed, 14 Sep 2022 00:37:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229953AbiINGuN (ORCPT + 99 others); Wed, 14 Sep 2022 02:50:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230114AbiINGuH (ORCPT ); Wed, 14 Sep 2022 02:50:07 -0400 X-Greylist: delayed 401 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 13 Sep 2022 23:50:03 PDT Received: from mail.sf-mail.de (mail.sf-mail.de [IPv6:2a01:4f8:1c17:6fae:616d:6c69:616d:6c69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E358347B93 for ; Tue, 13 Sep 2022 23:50:03 -0700 (PDT) Received: (qmail 13895 invoked from network); 14 Sep 2022 06:43:39 -0000 Received: from p200300cf07104d0076d435fffeb7be92.dip0.t-ipconnect.de ([2003:cf:710:4d00:76d4:35ff:feb7:be92]:42942 HELO eto.sf-tec.de) (auth=eike@sf-mail.de) by mail.sf-mail.de (Qsmtpd 0.38dev) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPSA for ; Wed, 14 Sep 2022 08:43:39 +0200 From: Rolf Eike Beer To: Li zeming , James.Bottomley@hansenpartnership.com, Helge Deller Cc: linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] parisc: Increase the usage check of kmalloc allocated object a Date: Wed, 14 Sep 2022 08:43:13 +0200 Message-ID: <1668528.WaZXzWfjLs@eto.sf-tec.de> In-Reply-To: References: <20220914060428.4039-1-zeming@nfschina.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart4636421.EM0ToxPilq"; micalg="pgp-sha1"; protocol="application/pgp-signature" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --nextPart4636421.EM0ToxPilq Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii"; protected-headers="v1" From: Rolf Eike Beer Cc: linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 14 Sep 2022 08:43:13 +0200 Message-ID: <1668528.WaZXzWfjLs@eto.sf-tec.de> In-Reply-To: MIME-Version: 1.0 Am Mittwoch, 14. September 2022, 08:18:19 CEST schrieb Helge Deller: > On 9/14/22 08:04, Li zeming wrote: > > In the case of memory allocation failure, no alignment operation is > > required. > > > > Signed-off-by: Li zeming > > --- > > > > drivers/parisc/iosapic.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c > > index 3a8c98615634..33de438916d3 100644 > > --- a/drivers/parisc/iosapic.c > > +++ b/drivers/parisc/iosapic.c > > @@ -229,7 +229,9 @@ static struct irt_entry *iosapic_alloc_irt(int > > num_entries)> > > * 4-byte alignment on 32-bit kernels > > */ > > > > a = (unsigned long)kmalloc(sizeof(struct irt_entry) * num_entries + 8, > > GFP_KERNEL);> > > - a = (a + 7UL) & ~7UL; > > + if (a) > > + a = (a + 7UL) & ~7UL; > > + > > As you said, the adjustment isn't required, but it's still ok. > So I think the additional "if" isn't necessary and so I'm not > applying your patch. > > Anyway, thanks for your help to try to improve the code! I was about to say the same, but from looking at the code I don't think what is in there is correct either. The comment seems outdated, because __assume_kmalloc_alignment, which is __alignof__(unsigned long long). This code is untouched for the entire git history, so maybe we can just change the whole thing to return kcalloc(num_entries, sizeof(struct irt_entry)) now? And these functions end up propagating an allocation error in this file and it will never reach kernel/setup.c, which seems bad. But I guess the only point where this really can go wrong if the PDC returns an absurdly large number of entries. Eike --nextPart4636421.EM0ToxPilq Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQSaYVDeqwKa3fTXNeNcpIk+abn8TgUCYyF4AQAKCRBcpIk+abn8 TmMrAJ9tzLMJcya2N1PiOENzBvcMciMbwgCbByM94VXUSX7X4mawEGbzvvELeEg= =Lbg1 -----END PGP SIGNATURE----- --nextPart4636421.EM0ToxPilq--