Received: by 2002:a05:6512:2355:0:0:0:0 with SMTP id p21csp78412lfu; Thu, 7 Apr 2022 21:00:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvauLN0CbhciihqhWp6GQAadCK03US9i1SiDmX+cM6+Eq5M/7UGzbFiola0+UXno9bY5Us X-Received: by 2002:a17:90a:ba15:b0:1c6:7873:b192 with SMTP id s21-20020a17090aba1500b001c67873b192mr19726284pjr.76.1649390451948; Thu, 07 Apr 2022 21:00:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649390451; cv=none; d=google.com; s=arc-20160816; b=J/hau40N2zLfKD4ftDRQCq9IaY9QiNB1HXqc/lw92lTpKLlw0Wbn1LhFsuahr2C7r0 8cORoSSaPj1EMkKdQAsI4Eb3OJvkdxbmgtPxkJVLkjw/+aY0aqOShP+J47y8lxQqOCEB /775QSGvzDLIdxCXpY6Lj1agb0P8zlhB+D8GL1WpycXBWTqWZPZY6g4Cqg/lWRoEzSQX VE6QCtfCeafjxrE7HkaeQz8/+0rVbr52JbxLjsiN+YeQBRQUdS+cW0O9wheTiscBjKp+ 1VME2+oyQ8sResxmWLrh4KB7G6aXQAxxETkveYktrEm1oU0MnVbA/zaJHOSGF+RSRwUm oFcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=JyQKxMp/EXB3QuONWryRuqNwNzwYQr67KvoGBWRBZWA=; b=p5jRLolyEBXthm2NpHnWnXaI9V/T1clwpLo+xI0uh36p8mIu3rAfkVipPhF5JEwDmq zTJgTu0fNKyr3gn1bj8t5pCGcJuM3Z1bHeu27wkmVaE4YriflPiICBsUb90wJNM+Szbh yvPnosYThqilS7Ujj+eqmZ+a+6Zr3PMKlVoO/5p+irwBQhc+sPWRmMS7Wi/4RM4cBA3O qQvK3nogg8kM3q9zO5TzohH1+ChgMQkjjMJ/GEjzq6UJsv7pGUMCAp+SC5M5gjgi1NoK h+K9614dCjOK62qQ/LyOX1ws4mP3gGgp2paUQ4GuQYpFKVK0k2ogiS0WrQyD86ymXfAD HshA== 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:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z4-20020a63b044000000b00398d8b16b80si151016pgo.820.2022.04.07.21.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 21:00:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 04DD71945FB; Thu, 7 Apr 2022 20:26:00 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231594AbiDHD15 (ORCPT + 99 others); Thu, 7 Apr 2022 23:27:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231533AbiDHD14 (ORCPT ); Thu, 7 Apr 2022 23:27:56 -0400 Received: from fornost.hmeau.com (helcar.hmeau.com [216.24.177.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94FB1193150 for ; Thu, 7 Apr 2022 20:25:53 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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 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