From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2A64AC47DAF for ; Mon, 22 Jan 2024 17:54:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=A/XDLdMG5uW+VPVrTnPilq6aOvH6oGuJxYVza7rZCtM=; b=zmLEFAXJXpoeG+ TLPRiQVwUX7rEWn8ysYOfc/p49ug2mfADflgkpHo7ELUXtGjsZi0mjF5wQLlVT1CTGsUFJZFc6/o0 8PHXmfXqXhwkiGfqDuKM9cgFvycZd1+SWpn9PfP5o64/wfLi/mGQG/Vr7LWwvhicaBPEI4fP+Bj3g vtoWjLGPZpj6N2a+w+moCaVOrdrF8i2ZhjOOjItB8Tngn/jlsXdRtZIINlfF6Rl10ZqRmrwPHdbY4 FE9LkAwHrJalhf/NUMx2nFvAVdlS2TCravk24j4T+owtPNe8ufGE9hWtuFnPaqrcvxgtL8AlBGDK6 yjDdL3UuQRpyr+1Y2Ggw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rRyUg-00DMul-26; Mon, 22 Jan 2024 17:53:58 +0000 Received: from omta40.uswest2.a.cloudfilter.net ([35.89.44.39]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rRyUc-00DMtQ-17 for linux-arm-kernel@lists.infradead.org; Mon, 22 Jan 2024 17:53:56 +0000 Received: from eig-obgw-6002a.ext.cloudfilter.net ([10.0.30.222]) by cmsmtp with ESMTPS id RwiZrtyxd80oiRyUYrTzqK; Mon, 22 Jan 2024 17:53:50 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id RyUXr7HzhD6lhRyUXrn7EK; Mon, 22 Jan 2024 17:53:49 +0000 X-Authority-Analysis: v=2.4 cv=LNR1/ba9 c=1 sm=1 tr=0 ts=65aeabad a=1YbLdUo/zbTtOZ3uB5T3HA==:117 a=WzbPXH4gqzPVN0x6HrNMNA==:17 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=wYkD_t78qR0A:10 a=VwQbUJbxAAAA:8 a=NEAV23lmAAAA:8 a=7YfXLusrAAAA:8 a=CsOLvDfn09n0XjjTB6sA:9 a=QEXdDO2ut3YA:10 a=9cHFzqQdt-sA:10 a=PUnBvhIW4WwA:10 a=AjGcO6oz07-iQ99wixmX:22 a=SLz71HocmBbuEhFRYD3r:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=HnBhTN2Qswqklqa5h1VDuRxzPmCKbJjTZLHYO8QIxWw=; b=c6iGIMVa+eG37rAI6qKtUzqRcp xGUl5ldFfByNWlilB8Oci0BltbK/89REty8IxwtOM53jwd8dt7qtz4HUZFwfFZz4TwGM8PRk7Nccr bTB1b1SDEVPpM0jaR70qY1yCd10aQwNwnUKD6krMawX3LRfB1RrnHPaXPOilmXqqsU8anGCKrMSce AEXt+dX2wNOkHRZvvc8NGKtF/gUWNQNWhhp9P5YUWEZyi2WgW3+4U//FTxWDbj+7XHPlBimHWxVPa rM1kmIwpaGgANpVwiNUXvoCNlZuKbL7Czw3PlRgFvums82syh0gKtA8N1oDJuFlCbx8lYzWXDSpfv ANG431Hw==; Received: from 187-162-21-192.static.axtel.net ([187.162.21.192]:37538 helo=[192.168.15.10]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96.2) (envelope-from ) id 1rRyUV-001MU8-17; Mon, 22 Jan 2024 11:53:47 -0600 Message-ID: Date: Mon, 22 Jan 2024 11:53:45 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] crypto: sun8i-ce - Use kcalloc() instead of kzalloc() Content-Language: en-US To: Erick Archer , Corentin Labbe , Herbert Xu , "David S. Miller" , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Corbet , "Gustavo A. R. Silva" Cc: linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <20240121153407.8348-1-erick.archer@gmx.com> From: "Gustavo A. R. Silva" In-Reply-To: <20240121153407.8348-1-erick.archer@gmx.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 187.162.21.192 X-Source-L: No X-Exim-ID: 1rRyUV-001MU8-17 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 187-162-21-192.static.axtel.net ([192.168.15.10]) [187.162.21.192]:37538 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 42 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfOBKxJZ2ilKvmBkExdRjKq1jWTDhZcZMUKNoXQN4Hquwh1EZstINOLtMZVkU2ZDqcPCDWEkOi7IrU32HK6p/kCd8NwxCx9PvHIQXJrDH3OiVveXIs0+n h0okaTgq+pppgkmGjFKmat4B05JgCcvath0EuRjlnfT0TPFr5fXNaX1VhF2oB2McYOXepBuAOkOkE70dDiaxLtPDbb3BhwouS7B3EbEB/m0FrMj7CunqCspK X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240122_095354_420206_7FF3ECEA X-CRM114-Status: GOOD ( 14.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 1/21/24 09:34, Erick Archer wrote: > As noted in the "Deprecated Interfaces, Language Features, Attributes, > and Conventions" documentation [1], size calculations (especially > multiplication) should not be performed in memory allocator (or similar) > function arguments due to the risk of them overflowing. This could lead > to values wrapping around and a smaller allocation being made than the > caller was expecting. Using those allocations could lead to linear > overflows of heap memory and other misbehaviors. > > So, use the purpose specific kcalloc() function instead of the argument > size * count in the kzalloc() function. > > Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1] > Link: https://github.com/KSPP/linux/issues/162 > Signed-off-by: Erick Archer Reviewed-by: Gustavo A. R. Silva Thanks! -- Gustavo > --- > drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c > index d358334e5981..ee2a28c906ed 100644 > --- a/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c > +++ b/drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c > @@ -362,7 +362,7 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) > digestsize = SHA512_DIGEST_SIZE; > > /* the padding could be up to two block. */ > - buf = kzalloc(bs * 2, GFP_KERNEL | GFP_DMA); > + buf = kcalloc(2, bs, GFP_KERNEL | GFP_DMA); > if (!buf) { > err = -ENOMEM; > goto theend; > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel