Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp599200rda; Sun, 22 Oct 2023 01:19:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG8Q9i+T2YNaUfnBiaR4euWwp4FCwXbi+ZfvLFAvhs/Z3yHYhuVe0/JdNyvA9dhBLtXftEx X-Received: by 2002:a05:6a00:93a2:b0:68c:69c8:e0f0 with SMTP id ka34-20020a056a0093a200b0068c69c8e0f0mr7823904pfb.18.1697962760774; Sun, 22 Oct 2023 01:19:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697962760; cv=none; d=google.com; s=arc-20160816; b=f10NhW7jGUVdHjY8Nxj2RxKZI9mMlOHVX+T57S0HzzObnvCC5ofdNXjlsRXX9e4Er1 d1Tcl5gA0R5nKnnJRWS/4wZggUW30v1+cCUCqnvnIBLEE4QEJ8vudMA+4+EgdToBFI0D QqbRmQQwwhy/ItcX655R27PRnatoF8FSq98kmUSZxUjP+3Lw9NryUUQ+HrK6xWg9LUu8 hLPI7Zyri0r/g3+nc4D5GwHw6D0kX1Kf+dc7aSjx/LiLaCWOtrAO8VOgAO2oG0CvPcWf rRO8n8AWKuYujQBvgDa38IKUkperpKUpelJRQzlHLxneVkEEK7beyUOXTv/lvDsIVBPp UMoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=0lSQVQvSyKlVO5M2KstZ/7oCaHrPhUXJjaznuycCKSY=; fh=uKl1CTlin8qnxt56ErGp3UOINPCBskOXHDuKvJLDQbo=; b=bh9Mw2cnNkbecZjGYIwlsIJDaTzMfU5rQQqtDysFkDEL30QIN3jW/TsqBvpxPkupNe PzaaehJK3ChhaGRrr1k/MhqleNNJ7CM4fq65cZKuzqAuX7MdayywDwJBLIlP/jVpiJw7 sRA235TvXpEuQZjdBLiPKMNPVJJxS70YtTumEO/HxtXDb0z/tIbLtf2MEiOahirfKMMl 52Yr5PxZEmWEL8nHEy4OA+R8QuN6idj1T+wHK8FFHY4XyYj4It6LUlyAqrxiFlUlD6EN LpN4nHQ55tVg3vgf3ZLr3PexXSfT6hHrGUzAiuhsPNd0Bh1fCgieF/PaW5z5+H6jWIsC yNEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hZmDwLHu; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id a71-20020a63904a000000b005b33c54df1esi4709608pge.51.2023.10.22.01.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 01:19:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hZmDwLHu; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 37D488080D59; Sun, 22 Oct 2023 01:19:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231631AbjJVITD (ORCPT + 99 others); Sun, 22 Oct 2023 04:19:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231445AbjJVISw (ORCPT ); Sun, 22 Oct 2023 04:18:52 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0C9F124 for ; Sun, 22 Oct 2023 01:18:47 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76AFEC43395 for ; Sun, 22 Oct 2023 08:18:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697962727; bh=ADeN/ZcvSOtk0xzds/Rjes9cMXM9bWKAFg7ZICtWoM8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hZmDwLHuWTchSz0dU+RKvEja8fZQDN4a+LyPmzn2k3XsRsNqzC5CTgJTknvsuImlw D/hG2I2XOmmbSaxaLQZ6/FrE7ckPtknEG3+u+UrLCknJJA0OPVtKg49Irqh1dHw1Ts YSZ2RhBB6Cqm9suQtKiihL5GkztkD9iztjMkOg7MDHIlpa3pHs8Vc7yTrPv2bJLLfz F0gcitYXOQkcfy244Str7LnQ3sLH5LYOEMwFelPEwZMLp2L+cr5AqmKtoybKuVtRhX intThyYDDXyYoGkd8apaTXgrrC9j9d6tV16tdczDq0vqGGe03IMneTLxl+LxSkJ5Nk M/0d8ejQ4dy2A== From: Eric Biggers To: linux-crypto@vger.kernel.org Subject: [PATCH 18/30] net: ipv4: stop checking crypto_ahash_alignmask Date: Sun, 22 Oct 2023 01:10:48 -0700 Message-ID: <20231022081100.123613-19-ebiggers@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231022081100.123613-1-ebiggers@kernel.org> References: <20231022081100.123613-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sun, 22 Oct 2023 01:19:18 -0700 (PDT) From: Eric Biggers Now that the alignmask for ahash and shash algorithms is always 0, crypto_ahash_alignmask() always returns 0 and will be removed. In preparation for this, stop checking crypto_ahash_alignmask() in ah4.c. Signed-off-by: Eric Biggers --- net/ipv4/ah4.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c index bc0f968c5d5b4..a2e6e1fdf82be 100644 --- a/net/ipv4/ah4.c +++ b/net/ipv4/ah4.c @@ -20,43 +20,40 @@ struct ah_skb_cb { void *tmp; }; #define AH_SKB_CB(__skb) ((struct ah_skb_cb *)&((__skb)->cb[0])) static void *ah_alloc_tmp(struct crypto_ahash *ahash, int nfrags, unsigned int size) { unsigned int len; - len = size + crypto_ahash_digestsize(ahash) + - (crypto_ahash_alignmask(ahash) & - ~(crypto_tfm_ctx_alignment() - 1)); + len = size + crypto_ahash_digestsize(ahash); len = ALIGN(len, crypto_tfm_ctx_alignment()); len += sizeof(struct ahash_request) + crypto_ahash_reqsize(ahash); len = ALIGN(len, __alignof__(struct scatterlist)); len += sizeof(struct scatterlist) * nfrags; return kmalloc(len, GFP_ATOMIC); } static inline u8 *ah_tmp_auth(void *tmp, unsigned int offset) { return tmp + offset; } -static inline u8 *ah_tmp_icv(struct crypto_ahash *ahash, void *tmp, - unsigned int offset) +static inline u8 *ah_tmp_icv(void *tmp, unsigned int offset) { - return PTR_ALIGN((u8 *)tmp + offset, crypto_ahash_alignmask(ahash) + 1); + return tmp + offset; } static inline struct ahash_request *ah_tmp_req(struct crypto_ahash *ahash, u8 *icv) { struct ahash_request *req; req = (void *)PTR_ALIGN(icv + crypto_ahash_digestsize(ahash), crypto_tfm_ctx_alignment()); @@ -122,21 +119,21 @@ static void ah_output_done(void *data, int err) u8 *icv; struct iphdr *iph; struct sk_buff *skb = data; struct xfrm_state *x = skb_dst(skb)->xfrm; struct ah_data *ahp = x->data; struct iphdr *top_iph = ip_hdr(skb); struct ip_auth_hdr *ah = ip_auth_hdr(skb); int ihl = ip_hdrlen(skb); iph = AH_SKB_CB(skb)->tmp; - icv = ah_tmp_icv(ahp->ahash, iph, ihl); + icv = ah_tmp_icv(iph, ihl); memcpy(ah->auth_data, icv, ahp->icv_trunc_len); top_iph->tos = iph->tos; top_iph->ttl = iph->ttl; top_iph->frag_off = iph->frag_off; if (top_iph->ihl != 5) { top_iph->daddr = iph->daddr; memcpy(top_iph+1, iph+1, top_iph->ihl*4 - sizeof(struct iphdr)); } @@ -175,21 +172,21 @@ static int ah_output(struct xfrm_state *x, struct sk_buff *skb) if (x->props.flags & XFRM_STATE_ESN) { sglists = 1; seqhi_len = sizeof(*seqhi); } err = -ENOMEM; iph = ah_alloc_tmp(ahash, nfrags + sglists, ihl + seqhi_len); if (!iph) goto out; seqhi = (__be32 *)((char *)iph + ihl); - icv = ah_tmp_icv(ahash, seqhi, seqhi_len); + icv = ah_tmp_icv(seqhi, seqhi_len); req = ah_tmp_req(ahash, icv); sg = ah_req_sg(ahash, req); seqhisg = sg + nfrags; memset(ah->auth_data, 0, ahp->icv_trunc_len); top_iph = ip_hdr(skb); iph->tos = top_iph->tos; iph->ttl = top_iph->ttl; @@ -272,21 +269,21 @@ static void ah_input_done(void *data, int err) struct ah_data *ahp = x->data; struct ip_auth_hdr *ah = ip_auth_hdr(skb); int ihl = ip_hdrlen(skb); int ah_hlen = (ah->hdrlen + 2) << 2; if (err) goto out; work_iph = AH_SKB_CB(skb)->tmp; auth_data = ah_tmp_auth(work_iph, ihl); - icv = ah_tmp_icv(ahp->ahash, auth_data, ahp->icv_trunc_len); + icv = ah_tmp_icv(auth_data, ahp->icv_trunc_len); err = crypto_memneq(icv, auth_data, ahp->icv_trunc_len) ? -EBADMSG : 0; if (err) goto out; err = ah->nexthdr; skb->network_header += ah_hlen; memcpy(skb_network_header(skb), work_iph, ihl); __skb_pull(skb, ah_hlen + ihl); @@ -367,21 +364,21 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb) work_iph = ah_alloc_tmp(ahash, nfrags + sglists, ihl + ahp->icv_trunc_len + seqhi_len); if (!work_iph) { err = -ENOMEM; goto out; } seqhi = (__be32 *)((char *)work_iph + ihl); auth_data = ah_tmp_auth(seqhi, seqhi_len); - icv = ah_tmp_icv(ahash, auth_data, ahp->icv_trunc_len); + icv = ah_tmp_icv(auth_data, ahp->icv_trunc_len); req = ah_tmp_req(ahash, icv); sg = ah_req_sg(ahash, req); seqhisg = sg + nfrags; memcpy(work_iph, iph, ihl); memcpy(auth_data, ah->auth_data, ahp->icv_trunc_len); memset(ah->auth_data, 0, ahp->icv_trunc_len); iph->ttl = 0; iph->tos = 0; -- 2.42.0