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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0DC8C433EF for ; Wed, 20 Oct 2021 23:29:12 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A9A5C611CE for ; Wed, 20 Oct 2021 23:29:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A9A5C611CE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=h/3Lo1cG9qEh5/xJ6WahhST6Grpn0eNY/sRa8RMCwlk=; b=MGR/tYuFaPWF5Q NGqGB1EAIS0jNbUsOeiL4nvyOU5jOAeAqD4ocqBI2rAIHqFnmQD80fRmyypk2xRLOtyIyEpD4rkNT l1En78iT1awfhw3uaP7cs88xdDx/9BbJVipWkGntyMBWE72xvjc0NmLQO1qlw6WjppM3vEGuzyazP GzTC8BFWvh3bXtmCh/eYMLtbVbK78RiVNe9m5gNWJ6SYc9Pn9eolXKcG00elEejL/PB4AOwkaOkXj jZbcs/rSa/0XZy+GiE8SDc0xjxRAiqJHJtjhSRbF6uhG2YI+VjsTtsGm9zm4h/r1l5jNhXvV0dUE8 cYqRz3Ldb+ZU8ul/Z4gg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdL02-005zJC-CO; Wed, 20 Oct 2021 23:27:58 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdKzy-005zIp-Jm for linux-arm-kernel@lists.infradead.org; Wed, 20 Oct 2021 23:27:56 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4FBB660F57; Wed, 20 Oct 2021 23:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634772474; bh=vvRfwlxU8SZoTOlb+tOlX8/u84LD6FdEwl6WBQOZ+Tc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Dxe/2mw2u998213c2OEBsM+rmgFmeySkb1AN7HPknwuv/VV80nKAP2ufhmV6lBq+M 3PIQO/YXQrRM45BFEfCKzFpHlYamtnEuKk/kn/4TdrFapzUtiX/XN8Krt+4XQ9aDjf 3KxkOC3Q6cIUp3JQdWnZt228t5jHvMto3m3x94gRP8pedSm7l72CVAImRnmPIJ+xCQ uGPbHGZHvDwbp8IOcHhElGCcgAjXayJ80KWLJ/o1tX3gYjT906BiODqr89ZOsKdPSl /o9MLlNfGH0OaORrwMs6/2672EDzHDX+yTZ3Buant1Ts8fdmfJNzEropurEqGx2swU +rkGKPKYTAqzQ== Date: Wed, 20 Oct 2021 18:32:33 -0500 From: "Gustavo A. R. Silva" To: "Gustavo A. R. Silva" Cc: Len Baker , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Vinod Koul , Kees Cook , linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] dmaengine: pxa_dma: Prefer struct_size over open coded arithmetic Message-ID: <20211020233233.GA1320242@embeddedor> References: <20210918104055.8444-1-len.baker@gmx.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211020_162754_696640_3166E0D5 X-CRM114-Status: GOOD ( 13.01 ) 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Sep 20, 2021 at 07:00:58PM -0500, Gustavo A. R. Silva wrote: > > > On 9/18/21 05:40, Len Baker 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 struct_size() helper to do the arithmetic instead of the > > argument "size + count * size" in the kzalloc() function. > > > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments > > > > Signed-off-by: Len Baker > > Reviewed-by: Gustavo A. R. Silva I'm taking this in my -next tree. Thanks -- Gustavo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel