Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp7676779rwn; Wed, 14 Sep 2022 02:41:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6KUdIf91RdOEbdC0gn/xRD1o253hn8jR4MQGWhdJII4vP8bhBJrK8ppHZ7cpg6pZ92YDrk X-Received: by 2002:a17:90a:1b65:b0:1f7:4725:aa6e with SMTP id q92-20020a17090a1b6500b001f74725aa6emr3746612pjq.179.1663148490957; Wed, 14 Sep 2022 02:41:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663148490; cv=none; d=google.com; s=arc-20160816; b=fVYiN4/mfdIwcRdspx56PSElF+SGqzBDTvvPKrxjZhku9u4LHr8j4b9AT/hfXzTavb iNVH+XjqmRh0HUDuWJIZK0B6B9o3RGXsmwvHHS2HlMWqHJ6H8+I10ijAsYIhDv/xpXl3 dsp1OvoQ1QQLl5gGF/PhOD1mM8BNfgmi5uwzb+b5/PA/P1Jv6TbIGEaVwFnfqa6DXMc2 FKtdDD0qJzrt5C0/2acSwt6UTFjH/apPCTBXO+5HurQT4LQqXRto/FJPiMF2bcc++cNA zNdJ15hp9elUjZfHypV+qQIkhKTtoPDFfjNIqQwbZitYLU2Tgtcp39qLsmJ8xBY37shb +r+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=u9+atBuzfZIlS5dTkC9hPP+7+iJnUSoetVPdljZM3ng=; b=MO3Y/oGyihd/Pz0x72Kp6ZS5fIsMOlHQTu2ZbqJJipiVQEOMQ6+Pk3K1jlxTipmVmB TZznCms8/Xb0X04evmbW/U1GW1HAP6xqAHwPDVpg41nlFFWAXet2RLnuzn3rBR3faQR0 fh6315fK7TwB6M4CWQASjozVfEv4gfD+6UculWlBi8tJWwq5JPJ0lACM/GGaQpcYAaQo UrHYu/r40zVvR39IRLd3nAZX4/vELN8bL73CYQ4lfTT/lTt+9D7y3pwy1pKdCNlOYoqM gQGKh6gpTLJCEAYYvHoXG9w24IRh3UlNuM1tkYCuk8WRM4rku1gdYQb77fUf5R0IlhFz sz7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=fYN080ep; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c13-20020a056a000acd00b0053adb3105b7si2065416pfl.67.2022.09.14.02.41.15; Wed, 14 Sep 2022 02:41:30 -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; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=fYN080ep; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231521AbiINJPh (ORCPT + 99 others); Wed, 14 Sep 2022 05:15:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231524AbiINJNh (ORCPT ); Wed, 14 Sep 2022 05:13:37 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B9C47C1C1; Wed, 14 Sep 2022 02:05:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1663146277; bh=LxrrAAF02KCR76/F/annEJIQS3JrN8qn8iNj3YoH9CU=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=fYN080epVgDKh9qonjYciKmUKszfVilZ9Y1YLcwqUaXjMOVZRwQzrPkvA6Ivk4Nte qNkybJOmuOQP52Auz0UjGj4CFCk5gE04oZIuPxdf2+62FEyLL3gn3G0oVh8CrO2lz7 qqw+oK7RsWo+7l67TMpGcXJtPd7TuvRH8wifRYYY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.20.60] ([92.116.164.250]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MatVh-1p9v4A1m3P-00cRMe; Wed, 14 Sep 2022 11:04:37 +0200 Message-ID: <3a72852c-2f28-2916-f02c-b52cb06efd7d@gmx.de> Date: Wed, 14 Sep 2022 11:04:33 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: [PATCH] parisc: Increase the usage check of kmalloc allocated object a Content-Language: en-US To: Rolf Eike Beer , Li zeming , James.Bottomley@hansenpartnership.com Cc: linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220914060428.4039-1-zeming@nfschina.com> <1668528.WaZXzWfjLs@eto.sf-tec.de> From: Helge Deller In-Reply-To: <1668528.WaZXzWfjLs@eto.sf-tec.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:LbXXBWq4HMo2OOfU43zK7i8Q+y96oVWwAVNPRwbPlXF5nSKicZi Ccz3hsMjSI13cGNcj86S9p9mcFBvbRLY+iGPvmOOm5q6n6y8lcrby53XrHTauGMlhX07U6Y YiW0Tcra07wMnNGgsnFjIDxxtPUGNwvPpz1UzAvwFLVYDUZXkwlbBfrQu7gAASvZ1Xj8r7G WQdk9MPfBjxf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A9mR1egK9VAxPmtKXWJmOhCXwfFQU2v6rR 6oqzCMj4fJZbWGO8JvmqTPPCkkhtW3/Xdx7MdT25Lx+bXeQ+TQRYPSjdZFK6aP4MTga1AWnPB EfyNp8tNQJkH/5zqxw6fILT2VbGmlz6I5T//TC22YtFPXKgovPLNp7bwwviPhmRRu3rgF32CM 0NKvbDT6ZPb/+mYyFd/v/AbPR2 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On 9/14/22 08:43, Rolf Eike Beer wrote: > 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 =3D (unsigned long)kmalloc(sizeof(struct irt_entry) * num_entrie= s > + 8, >>> GFP_KERNEL);> >>> - a =3D (a + 7UL) & ~7UL; >>> + if (a) >>> + a =3D (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). Th= is > code is untouched for the entire git history, so maybe we can just chang= e the > whole thing to > > return kcalloc(num_entries, sizeof(struct irt_entry)) > > now? Yes, your proposal is good. Anyone want to send a patch (with a small comment that kcalloc() will retu= rn at least the required 8-byte alignment)? > And these functions end up propagating an allocation error in this file = and it > will never reach kernel/setup.c, which seems bad. That part I don't understand. The return value of iosapic_alloc_irt() is checked afterwards, but you pro= bably meant something else? > But I guess the only point where this really can go wrong if the PDC > returns an absurdly large number of entries. Helge