From patchwork Mon Sep 25 12:03:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13397698 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 AEEADCE7A94 for ; Mon, 25 Sep 2023 12:04:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CAE326B015E; Mon, 25 Sep 2023 08:03:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C38ED6B015F; Mon, 25 Sep 2023 08:03:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3C186B0162; Mon, 25 Sep 2023 08:03:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8C6556B015E for ; Mon, 25 Sep 2023 08:03:55 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 69A541C9B3B for ; Mon, 25 Sep 2023 12:03:55 +0000 (UTC) X-FDA: 81274986030.04.F08C31A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id AD3404002A for ; Mon, 25 Sep 2023 12:03:53 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DOLzLQUv; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695643433; a=rsa-sha256; cv=none; b=17ccCQOZQ6l0JKYJJOCbVhSGaLEwpear91QsXfaVtmV1qSQoNq+sAiOeHTnVWUbNVujHZ/ JQI57e+g6kZLRC4JtFHP+aNRKBkr1TLD3w4lQ8kYhnHcgDAiamA7+Juq+R4hfGeY/HnN3c sp5KGFWEHuFBZMpz2zvhrFu/KL/L/9Y= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DOLzLQUv; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695643433; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IFANTKBqjctjMhYlR9DlpaXTtUIzXQ6esPI4cVawB1c=; b=Ep1OAj4cmN1JfH0sUUCpdx30wgRRrJYvdfk0MlhXoINW7E0UBm0pa1uHNrcJlxxklBI0Z6 2MSn+cTs0RUFKGnUpkPGrieLqmLH5O1rwzEvruUHcGB03BekJQ18t0ZYldCuiOw5THtB66 QMd238xSheTGkPaQakKVkot01AW+/18= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695643433; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IFANTKBqjctjMhYlR9DlpaXTtUIzXQ6esPI4cVawB1c=; b=DOLzLQUvM/R3EmmnQc1S1DlyIw3SUOfUAWK/cZ9ORmatX/v0o4cUlvfG13iAK0m/t3Qsg4 4pCAeyYV6kE9O9w1/yiNjHD5JXxocxEfjjiN/7Yp7W000O0iR55D0vQ50OnxqNV/95+P8i XlwW3GC6vdJGs4m6K7JZSGguhyA5eK0= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-381-Yv4-_50VO1WoEpBUsV8YeQ-1; Mon, 25 Sep 2023 08:03:49 -0400 X-MC-Unique: Yv4-_50VO1WoEpBUsV8YeQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D8A8829AB3FD; Mon, 25 Sep 2023 12:03:48 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE54A40C2064; Mon, 25 Sep 2023 12:03:46 +0000 (UTC) From: David Howells To: Jens Axboe Cc: David Howells , Al Viro , Linus Torvalds , Christoph Hellwig , Christian Brauner , David Laight , Matthew Wilcox , Jeff Layton , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v7 12/12] iov_iter, net: Move hash_and_copy_to_iter() to net/ Date: Mon, 25 Sep 2023 13:03:09 +0100 Message-ID: <20230925120309.1731676-13-dhowells@redhat.com> In-Reply-To: <20230925120309.1731676-1-dhowells@redhat.com> References: <20230925120309.1731676-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: AD3404002A X-Stat-Signature: n8dj5ti8xkem1hf5qh6ub6muhj6u894d X-HE-Tag: 1695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JpmyZsHDBVpkCTfYaXKTHbVKjg6CrZqaC/itb0DmFIhC33EDPSElDL+T9Gs3RJY+84HBX89fuNEtwwhrCOrbqEiWTRiyKMYqI1wtnmS5Hn4w+g9CqVZJyAHii5TKVQwFns48x4+K5YSXLdjeoUTa6hm6wiZzNMb6rZ1lK2USHGSYDjaj5yI0czrX8wJe8kohj1qBdjAimMJVZhHvTszwK4byPpRS+1jbQgsgmT1Vt5S6JhhA5jOFm7tWVQ7vhX16DRow8B2vXkMpiAkU+ZC6mkyJadlcpDDWG99aq4jUR4dATvmnSEtPq+rTfjpn9XNuR5EJT6BdqUckXtYVUurS84sYwZnfFea3p5gu6BfieWPUdE0mr86HZ7wGK/hcXVFjBaubfFgm5U9po47eZpB8vUAhq20O6CKcQBullG3ZPo4LJvYHkvWPM8bFk3QGYvv/6DnUy779/VZlk+PZLQyeJ6nxiulcQu6we0zH6o2JLX72PCTtbIhqquL8hyS/wzVr6qoQ1rZapxKlAj6R8fVob0LC38dyj3fk6jVS42K0wYKWUBEDOi12oDJw6JNzWeyInrw+iAKUvPnbvE6FE15ZoamFOXU2DmgkR2OoCVJh5Gq7L 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: Move hash_and_copy_to_iter() to be with its only caller in networking code. Signed-off-by: David Howells cc: Alexander Viro cc: Jens Axboe cc: Christoph Hellwig cc: Christian Brauner cc: Matthew Wilcox cc: Linus Torvalds cc: David Laight cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org cc: netdev@vger.kernel.org --- include/linux/uio.h | 3 --- lib/iov_iter.c | 20 -------------------- net/core/datagram.c | 19 +++++++++++++++++++ 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/include/linux/uio.h b/include/linux/uio.h index 0a5426c97e02..b6214cbf2a43 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h @@ -338,9 +338,6 @@ iov_iter_npages_cap(struct iov_iter *i, int maxpages, size_t max_bytes) return npages; } -size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp, - struct iov_iter *i); - struct iovec *iovec_from_user(const struct iovec __user *uvector, unsigned long nr_segs, unsigned long fast_segs, struct iovec *fast_iov, bool compat); diff --git a/lib/iov_iter.c b/lib/iov_iter.c index fef934a8745d..2547c96d56c7 100644 --- a/lib/iov_iter.c +++ b/lib/iov_iter.c @@ -1,5 +1,4 @@ // SPDX-License-Identifier: GPL-2.0-only -#include #include #include #include @@ -1093,25 +1092,6 @@ ssize_t iov_iter_get_pages_alloc2(struct iov_iter *i, } EXPORT_SYMBOL(iov_iter_get_pages_alloc2); -size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp, - struct iov_iter *i) -{ -#ifdef CONFIG_CRYPTO_HASH - struct ahash_request *hash = hashp; - struct scatterlist sg; - size_t copied; - - copied = copy_to_iter(addr, bytes, i); - sg_init_one(&sg, addr, copied); - ahash_request_set_crypt(hash, &sg, NULL, copied); - crypto_ahash_update(hash); - return copied; -#else - return 0; -#endif -} -EXPORT_SYMBOL(hash_and_copy_to_iter); - static int iov_npages(const struct iov_iter *i, int maxpages) { size_t skip = i->iov_offset, size = i->count; diff --git a/net/core/datagram.c b/net/core/datagram.c index 722311eeee18..103d46fa0eeb 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c @@ -61,6 +61,7 @@ #include #include #include +#include /* * Is a socket 'connection oriented' ? @@ -489,6 +490,24 @@ static int __skb_datagram_iter(const struct sk_buff *skb, int offset, return 0; } +static size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp, + struct iov_iter *i) +{ +#ifdef CONFIG_CRYPTO_HASH + struct ahash_request *hash = hashp; + struct scatterlist sg; + size_t copied; + + copied = copy_to_iter(addr, bytes, i); + sg_init_one(&sg, addr, copied); + ahash_request_set_crypt(hash, &sg, NULL, copied); + crypto_ahash_update(hash); + return copied; +#else + return 0; +#endif +} + /** * skb_copy_and_hash_datagram_iter - Copy datagram to an iovec iterator * and update a hash.