Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp599156rda; Sun, 22 Oct 2023 01:19:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwz1xIQvyLXEEfLlp9+9cMM3kc3nsShpQtbnjHEYobVu46+WMrBSwr2ZBp0mUvfKos2Si2 X-Received: by 2002:a05:6e02:5c5:b0:350:f956:91c4 with SMTP id l5-20020a056e0205c500b00350f95691c4mr5850910ils.4.1697962753812; Sun, 22 Oct 2023 01:19:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697962753; cv=none; d=google.com; s=arc-20160816; b=e3eqv7bF1L2k0A3F85T0aDklwhyQHAxzzQ9HXm223wGCaVMuUisyLiX2GJHcYNQfN6 MOJ4B5sTN/irwgmMZLAvsVWxM4kBqW/aUZJbx+u/JnpVa2E6EQHF3Uf9JsP3XKaHLg6w fRnnZpREYX40c2ygLXpLVDfsE2oIUPOqEy/M4DYIZSTDx3hSsZN8+AaWoXEDd+GGe4Tl HGz8UqLIgEGgVajVXStUJXLDOA95TkKF7TwWyJhTlAIYJtjHzkkfddaMgm3QAZyQtE5R AvgzuWHNhDpOWsunamFB1W1tmGoACXugsCh0uimO40Ka8QMiFuq1tylhrKMzkf+qyLee 7BRA== 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=t2tFCvESAbl79ZlB6MlcIP2nmLoS298M3o6zGhi37P0=; fh=uKl1CTlin8qnxt56ErGp3UOINPCBskOXHDuKvJLDQbo=; b=Dr6FH3qGq+sZ+yTVtNStPcsIE7n/0xyjF1vw9uFF5kVkdKL24LFPI+ilcTqVosq5v2 uu8KHSsrDdptX58zYyfC85AJVR6rg8PJk3dSGmtvq9lt2qb0OkgY7tNl2nhjkgxRQYiY BFLAxk8qIS3z9YJO90W5uzS7iQ/GLvl+fNvz6uOVox/Yo3fDACi2RUzCDEsLlH5K8nUa uUMyRn1zidnylw2Rk31nUe3H3XX6GdC/5xrjXMOlD2jmo0noXjssuze3G3U4xpbKbiJy Kwwiu4AzASi4cGhSEjFmTbJu3JFsBJwpEnclhjM39TLt9wnMi3SmWrZY1JBJHpblP7ID rJOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PBV1rRpG; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id ls11-20020a17090b350b00b0027d09bab505si7594976pjb.66.2023.10.22.01.19.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 01:19:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PBV1rRpG; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id BE81A808A37B; Sun, 22 Oct 2023 01:19:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231785AbjJVITI (ORCPT + 99 others); Sun, 22 Oct 2023 04:19:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231649AbjJVISw (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 D9720119 for ; Sun, 22 Oct 2023 01:18:47 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9F0AC43397 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=zfSB2jxlCfaaPSwCofpCsy6YtucmgVuL9a+n18n5RTE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PBV1rRpG0UIUCqZ2R/Rp5Q25boqNg37IrijTsyUbbDPQIct1wAoZA9Ud6YM7zYcyj YGi/7Woe3l5K9paFSi60xuLijLAjHIoF3zoTlZYbJWmfZHcbjGH/MxdcgwXULkTyG2 umPqFDDu1hK0yKtkp9dLVgVbFwImofCafY0hittihPV5wB7kMlYbtNzPebMi2IQ806 fMxmNM+I619XUnAtJ21du8kUBw77eP7vqn9AXV1BjvHYHMse28I8YgOoxLnla5ex5n tScj1xfur8DV/24+hJqYF8kKnviFu79JIOILGM+VsT7fTDcxTAnDH8UzDTAaIXJtVP H7OqKxkHOocqA== From: Eric Biggers To: linux-crypto@vger.kernel.org Subject: [PATCH 19/30] net: ipv6: stop checking crypto_ahash_alignmask Date: Sun, 22 Oct 2023 01:10:49 -0700 Message-ID: <20231022081100.123613-20-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 fry.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 (fry.vger.email [0.0.0.0]); Sun, 22 Oct 2023 01:19:11 -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 ah6.c. Signed-off-by: Eric Biggers --- net/ipv6/ah6.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c index 56f9282ec5df4..2016e90e6e1d2 100644 --- a/net/ipv6/ah6.c +++ b/net/ipv6/ah6.c @@ -44,23 +44,21 @@ 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); } @@ -68,24 +66,23 @@ static void *ah_alloc_tmp(struct crypto_ahash *ahash, int nfrags, static inline struct tmp_ext *ah_tmp_ext(void *base) { return base + IPV6HDR_BASELEN; } static inline u8 *ah_tmp_auth(u8 *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()); @@ -292,21 +289,21 @@ static void ah6_output_done(void *data, int err) struct ipv6hdr *top_iph = ipv6_hdr(skb); struct ip_auth_hdr *ah = ip_auth_hdr(skb); struct tmp_ext *iph_ext; extlen = skb_network_header_len(skb) - sizeof(struct ipv6hdr); if (extlen) extlen += sizeof(*iph_ext); iph_base = AH_SKB_CB(skb)->tmp; iph_ext = ah_tmp_ext(iph_base); - icv = ah_tmp_icv(ahp->ahash, iph_ext, extlen); + icv = ah_tmp_icv(iph_ext, extlen); memcpy(ah->auth_data, icv, ahp->icv_trunc_len); memcpy(top_iph, iph_base, IPV6HDR_BASELEN); if (extlen) { #if IS_ENABLED(CONFIG_IPV6_MIP6) memcpy(&top_iph->saddr, iph_ext, extlen); #else memcpy(&top_iph->daddr, iph_ext, extlen); #endif @@ -355,21 +352,21 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb) seqhi_len = sizeof(*seqhi); } err = -ENOMEM; iph_base = ah_alloc_tmp(ahash, nfrags + sglists, IPV6HDR_BASELEN + extlen + seqhi_len); if (!iph_base) goto out; iph_ext = ah_tmp_ext(iph_base); seqhi = (__be32 *)((char *)iph_ext + extlen); - 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; ah = ip_auth_hdr(skb); memset(ah->auth_data, 0, ahp->icv_trunc_len); top_iph = ipv6_hdr(skb); top_iph->payload_len = htons(skb->len - sizeof(*top_iph)); @@ -461,21 +458,21 @@ static void ah6_input_done(void *data, int err) struct ah_data *ahp = x->data; struct ip_auth_hdr *ah = ip_auth_hdr(skb); int hdr_len = skb_network_header_len(skb); int ah_hlen = ipv6_authlen(ah); if (err) goto out; work_iph = AH_SKB_CB(skb)->tmp; auth_data = ah_tmp_auth(work_iph, hdr_len); - 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, hdr_len); __skb_pull(skb, ah_hlen + hdr_len); @@ -569,21 +566,21 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb) work_iph = ah_alloc_tmp(ahash, nfrags + sglists, hdr_len + ahp->icv_trunc_len + seqhi_len); if (!work_iph) { err = -ENOMEM; goto out; } auth_data = ah_tmp_auth((u8 *)work_iph, hdr_len); seqhi = (__be32 *)(auth_data + ahp->icv_trunc_len); - 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; memcpy(work_iph, ip6h, hdr_len); memcpy(auth_data, ah->auth_data, ahp->icv_trunc_len); memset(ah->auth_data, 0, ahp->icv_trunc_len); err = ipv6_clear_mutable_options(ip6h, hdr_len, XFRM_POLICY_IN); if (err) -- 2.42.0