From patchwork Wed Sep 20 22:22:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13393505 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 E1571CD13D3 for ; Wed, 20 Sep 2023 22:23:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E7E56B01F2; Wed, 20 Sep 2023 18:23:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 798876B01F3; Wed, 20 Sep 2023 18:23:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 613276B01F4; Wed, 20 Sep 2023 18:23:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4BD436B01F2 for ; Wed, 20 Sep 2023 18:23:14 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 295CC140CE3 for ; Wed, 20 Sep 2023 22:23:14 +0000 (UTC) X-FDA: 81258402708.12.9B782CB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 4E62840029 for ; Wed, 20 Sep 2023 22:23:12 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="WWOW/mwY"; spf=pass (imf27.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1695248592; 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=qT59ImjpXymvQ6tFUMHWEUo8+jWIxsSglDsUCxtrSao=; b=YypUS4AKZJ50if+Sd+5Kgb8hsnx8WrFc319nVcuJcZ9/5xiOz2uxCxAruphEY7AIoD/VJJ B5FLLpDgd5j8WR22sFM5k7LOW6a6GIyrkgcYfmJ2tpcwdfTVc0+41HIPz/woH0AaRmU3Bi t3qUlJQMX8rVPlEDNN4iDuXXvavVOsM= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="WWOW/mwY"; spf=pass (imf27.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695248592; a=rsa-sha256; cv=none; b=ae+3AjruftSFsM8kvMhzcMYCh4swe8QRJqwfiDihsUIZOcmupVzovxBMA3At7o8v36REQa /ma5gUEzXwdMG5qkhn5TJeHrZ3uQwg87hfNvVIRuO1yHArY0IFURfzj1nmyDVV4cAb9xqh ZBGnzxI6Nb4YH4nVvJMJ32hm8pgyyzQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695248591; 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=qT59ImjpXymvQ6tFUMHWEUo8+jWIxsSglDsUCxtrSao=; b=WWOW/mwYQR/DCRrRodyOThwIcyAm7lLVxChswFtQlRCdXwsQo0os8InlsUatnXvVoPwPTu in8FcRNwvSMx/SlgMeOvyI8cfS3O41RtWXbovEvmGKrCezK5hq72HM4DRJ1MVVHvVi53i+ oZDyfoJ/FOeesJ779F+zAY+C2Hj0rTE= 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-647-5dIXQ-LFOyWTHqsMcxPB4w-1; Wed, 20 Sep 2023 18:23:07 -0400 X-MC-Unique: 5dIXQ-LFOyWTHqsMcxPB4w-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 4AC303C0D183; Wed, 20 Sep 2023 22:23:06 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4231E40C6EBF; Wed, 20 Sep 2023 22:23:04 +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 v5 11/11] iov_iter, net: Move hash_and_copy_to_iter() to net/ Date: Wed, 20 Sep 2023 23:22:31 +0100 Message-ID: <20230920222231.686275-12-dhowells@redhat.com> In-Reply-To: <20230920222231.686275-1-dhowells@redhat.com> References: <20230920222231.686275-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspamd-Queue-Id: 4E62840029 X-Rspam-User: X-Stat-Signature: mag8rymqn8aprgc1ppxjodcbrk5ukce5 X-Rspamd-Server: rspam01 X-HE-Tag: 1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fF5to2J9qel3f7oeRAkQTG3Jp/JGUoV9iJaYBwYjy23T0fUQ08VaeCKzkjDcnjG6HAhbCEZOA6l9KAx55R+rRZPlhReE2NOR6bd7xTArlfVTBjozRrc5gPWwK7EMabZZcfu5NN3O9GKG/6EsTmCzXLqMHI1Ts4Rf0loy3dCUhyw0h8XxBQLkkqSIMYUp3xPZCcT7k5uiP5qFfaYdvATdT+hD78GGOJHNJtjRVWFvemvZJMtN1T8ymI7iys+8mb2VqEyfwlUg7N/f1tMYqwKD5ARArIZZHN6I8Q/0Z94gsp4LLhPU88xULy+S8bgfiCDTYmiqL73p0rIY+gps9TKuHoDqlmieBfT6xiSmbxCB84K474TQerPh7qoh84TdLYpV5cOeZ5W4phO1SXvcdhAM6Rafj8CY9BUPe11roH1StOFbzMPN9ZiwJkMV8HmvG9NtC4X6RUZBon0RZz7u0EsKRw8HK3CddA/xep5uwnOW4X465QiZPWAV7iTNDB3vgkUG5VrKepjOT28GK25lWodOKNyq0BSUkluDGhfrDlJlIPYPi/d5kG5eQokPG+cvbNFiZzbDfDRPjDAv7Z/xM+OxqlYh1lsY/QcvLDSZ64 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 0cf9937f98d3..442d0d238207 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h @@ -341,9 +341,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.