From patchwork Wed Sep 13 16:56:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13383577 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 8A46DEE01EA for ; Wed, 13 Sep 2023 16:57:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 900676B0208; Wed, 13 Sep 2023 12:57:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8AE046B0209; Wed, 13 Sep 2023 12:57:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7281D6B020A; Wed, 13 Sep 2023 12:57:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 5EAF86B0209 for ; Wed, 13 Sep 2023 12:57:33 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3F0551404B7 for ; Wed, 13 Sep 2023 16:57:33 +0000 (UTC) X-FDA: 81232180386.11.04FDA77 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 93584A0035 for ; Wed, 13 Sep 2023 16:57:31 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RFEDV2uE; spf=pass (imf15.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694624251; 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=c2st9mzpODW5EfnFYy73QjLkmO48eOaJEcOSoL9qczM=; b=jnHKpc/NLcFFOdHTojeM4LtUJRVyekT+YRC3ztCi9ahlaPvHUgmPokOsov2eUPqNk+acLT /J++MSaX5cNr5MStuXZJo2FRM83LTvjC/FAMlh/ClcJdAZlfGYmvyfq3gcmc5Rs9XceE4j lwjxTz82SztuZVefliMOqFrnDZ8VdgM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694624251; a=rsa-sha256; cv=none; b=bz3R9IiQsvxLZrXQ0hDqzzBe3hOKDQbAqYY8DfCS9FRl7jFnQN0dUwgmtbLGtEhCNRuDkN k+HFf75YEZRxZYtlFTEZywedFOkaUazAUQtwR64N+Z12HzTM9kFfWELtqTvrjHwiRREjHm tMoUhN2ucKYkUYKYiqWeBEMJ1+HNbIs= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RFEDV2uE; spf=pass (imf15.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694624251; 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=c2st9mzpODW5EfnFYy73QjLkmO48eOaJEcOSoL9qczM=; b=RFEDV2uE5/kKcKcdHW1SLKkp901HMexROSAMJldGFjba2YTZE6zPcePrnnoiq32PBnEACV c5CGoy67P9aBhWzXgsGDKxbUV5Utn5yV4znDhsrzcH2AJdAa4mx/+omM/cfrGrwLM78b5f LF6/WseT8hFwdcG9bTdIP9w4HyU1ZsU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-628-Z0pMlrrIOVKNFRYw1td4xA-1; Wed, 13 Sep 2023 12:57:23 -0400 X-MC-Unique: Z0pMlrrIOVKNFRYw1td4xA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 D46F2101FAA0; Wed, 13 Sep 2023 16:57:22 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAFFF40C6EA8; Wed, 13 Sep 2023 16:57:20 +0000 (UTC) From: David Howells To: Al Viro , Linus Torvalds Cc: David Howells , Jens Axboe , 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 v4 12/13] iov_iter, net: Move hash_and_copy_to_iter() to net/ Date: Wed, 13 Sep 2023 17:56:47 +0100 Message-ID: <20230913165648.2570623-13-dhowells@redhat.com> In-Reply-To: <20230913165648.2570623-1-dhowells@redhat.com> References: <20230913165648.2570623-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspamd-Queue-Id: 93584A0035 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 6r8zn5ikgi3yhmrap1kkrjn1fgdm9p66 X-HE-Tag: 1694624251-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pA6qQ19LlDAWMhKEV0ui/q7TMkGtM4IfxsJYD0zovrr3lR4bnhi2cNtg707Pp/6klhHROazhVdSmYLnS3xYLW0hmgrXBSipagpKOvUvlplLjfCzg2sOdCHXj4rcu/oYcDQYHD1hIpZkkqRXouElcgDzKVOhnA7qKz0UpSrr59i1UkbdY7Vk98LG+0xYoynBdOu33hL8NIM0pnX7Ej0KRGYGQux1FEJLe/en1YsfIwPJe7UzwPcz3xJeQ84CBDnQ7NrVjbPlqNELRA+dp3qEPm4YWnvKm79nbZ+xQ/6e2E/v6xqLR1txIQ3hXxs5HX4pBzEzzLkH3NhPCdpAgTcOPQjLLDHH9MUq5vb+QpnILPsCNZGn/ZsRU6VNKHKS8TAqFIkHc/1O3YarqSFsGPz+ODrXMOC/J052zipeK21eGTIfMSxsQV8TrlXCiec7G96AHuUMi4iLh2jMyY87MvGDqK788IpjDAYOpr7GYr88YxNNSpGp+Q6hG2ECp8fK2aGe7L4J0hi3a16H4no4P3PzU8IH/hHMRNQf5eYCtTBHcDzzbwjTFSzDhldAT0UVXPADILP8IKLhi+1BpzUFkJWPewuEIJmEx862NDMo 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 c335b95626af..6bb00645fe46 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h @@ -326,9 +326,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 5b2d053f057f..77520834ebe4 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 @@ -1071,25 +1070,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.