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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89F61C433F5 for ; Fri, 8 Apr 2022 03:25:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BA096B0071; Thu, 7 Apr 2022 23:25:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 069F66B0072; Thu, 7 Apr 2022 23:25:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E72F66B0074; Thu, 7 Apr 2022 23:25:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id D03A56B0071 for ; Thu, 7 Apr 2022 23:25:51 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 98D77254D0 for ; Fri, 8 Apr 2022 03:25:51 +0000 (UTC) X-FDA: 79332272502.13.2E8A198 Received: from fornost.hmeau.com (helcar.hmeau.com [216.24.177.18]) by imf22.hostedemail.com (Postfix) with ESMTP id 58DF5C0003 for ; Fri, 8 Apr 2022 03:25:50 +0000 (UTC) Received: from gwarestrin.arnor.me.apana.org.au ([192.168.103.7]) by fornost.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1ncfFZ-000Nbr-3W; Fri, 08 Apr 2022 13:25:30 +1000 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Fri, 08 Apr 2022 11:25:29 +0800 Date: Fri, 8 Apr 2022 11:25:29 +0800 From: Herbert Xu To: Catalin Marinas Cc: Ard Biesheuvel , Will Deacon , Marc Zyngier , Arnd Bergmann , Greg Kroah-Hartman , Andrew Morton , Linus Torvalds , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, "David S. Miller" Subject: Re: [PATCH 07/10] crypto: Use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN Message-ID: References: <20220405135758.774016-1-catalin.marinas@arm.com> <20220405135758.774016-8-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 58DF5C0003 X-Rspam-User: Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf22.hostedemail.com: domain of herbert@gondor.apana.org.au designates 216.24.177.18 as permitted sender) smtp.mailfrom=herbert@gondor.apana.org.au X-Stat-Signature: s46h7ikrhgdxwcae7d1h5daa8956cwqr X-HE-Tag: 1649388350-458760 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Apr 07, 2022 at 05:28:10PM +0100, Catalin Marinas wrote: > > I can see in many cases that the kmalloc() caller aligns the requested > size to something like crypto_tfm_ctx_alignment(). So this would > guarantee a kmalloc() object aligned to CRYPTO_MINALIGN. crypto_tfm_ctx_alignment is basically the same as CRYPTO_MINALIGN. We assume any kmalloced pointers to be aligned to that. Specific algorithms may ask for an alignment greater than that and we will use the knowledge that kmalloc is aligned to CRYPTO_MINALIGN to derive the extra memory we need to get. So if kmalloc no longer returns memory aligned to MINALIGN then we'll get memory overruns. > I saw Ard already started to refactor some of these. But in the meantime > are there cases where the crypto code does a kmalloc() of less than > CRYPTO_MINALIGN and expects it to be CRYPTO_MINALIGN aligned? It's a fundamental assumption of the API. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt