From patchwork Fri Sep 22 12:02:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13395710 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 EC915CD4F5B for ; Fri, 22 Sep 2023 12:03:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6484D6B02D8; Fri, 22 Sep 2023 08:03:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D0726B02DB; Fri, 22 Sep 2023 08:03:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 44D1B6B02D9; Fri, 22 Sep 2023 08:03:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2D4476B02D6 for ; Fri, 22 Sep 2023 08:03:12 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 02506810D5 for ; Fri, 22 Sep 2023 12:03:11 +0000 (UTC) X-FDA: 81264097824.15.A7F3B7E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 2038BA0056 for ; Fri, 22 Sep 2023 12:03:09 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Hud4A50b; spf=pass (imf15.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=1695384190; a=rsa-sha256; cv=none; b=aAf6QUkB0CCewKHU+7tgDpya9iBBR5p1MVqhsptHqPP2Wl/BmT93jYWNdauR99pydsdEl9 H4p7b0u73gxE27L2HtsP624HVn2izOA5IISjSZOrEI/ty2EjW5TLYVAB1D2fi/OOm833ry o/eGMD8ZOlWmi1IGTGOngaxWnP2Ddwk= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Hud4A50b; spf=pass (imf15.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=1695384190; 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=l03KcXdFf+T8vwjFZB2NYEKTVAV0GjpBASzGJ2iJP/BaLUVQXoSCvwviiElZfY9PAnaCjq DWEpbDFc8ZYMCiWdgYUoJkVRVDeIzZwqu0fwrY3QsJq3gqZuSqm3+KkM3J/GXJZ+jY0G/8 Ql6gMNktMBkkb+p/h55zbqXm2htoXJI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695384189; 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=Hud4A50bwwRJTYJDo//yyPJ+Iq9lWs82AXubdCphe06Pzt+Vcv8cZwCpU1ucXvAi5/pE/1 ktOulKJJ+Hwfx7nMo66MMXMzNxjT6fLY8DdxZX/KbbhBXtqAQro7PfRMVgFFC0JEayKjEA mDPHWsfMQmgtDTUJrQ1VTdTNf9jap7k= 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-453-H4_9D-FgOQa1s3eUdZamVw-1; Fri, 22 Sep 2023 08:03:06 -0400 X-MC-Unique: H4_9D-FgOQa1s3eUdZamVw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 3B74285A5BA; Fri, 22 Sep 2023 12:03:05 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25F1420268D7; Fri, 22 Sep 2023 12:03:03 +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 v6 13/13] iov_iter, net: Move hash_and_copy_to_iter() to net/ Date: Fri, 22 Sep 2023 13:02:27 +0100 Message-ID: <20230922120227.1173720-14-dhowells@redhat.com> In-Reply-To: <20230922120227.1173720-1-dhowells@redhat.com> References: <20230922120227.1173720-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 2038BA0056 X-Stat-Signature: jwp1rdgc688z7hmkjdexq94w3uckct1u X-Rspam-User: X-HE-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0BS9QZ3If+AB1SWx5A0A5nBzV0di/btyg3AKiBJe/uSPZgqgu9/83ublRH4lRICjPVVgT4lIe4WD5nBjeQQUT3JVhbjzFPiYmLg0DVGxmmiyNFI9o0sPjgDJ8iiaOmSfxNoDzwiuNE4QuE6Du+fbjCgz6GmFwo6n4Tkgh2pKSMxSeyk1f+GW88fS0gzRJdHgSxWjb4sudKnOY/Ck4eVfTBwpErJchwUrYisl52D0PcnXXbpffQilGq7WT48paFBt03t109dgrUlGLFee/jo+MrtfXtlLut9sKAXArPs16SVptTJ1ibgvCfIZHVs1gDZyKNGpAMI95T8YAcjpNknorwP8zm8ZPOhXcBFGDg4ZzW3daec/YnShYHQX9SVc7lbCPPvouESC9GGbjc7mj96oCmyWfIZqPZfg0DUhIVw3y09TiUp69KPI8y4x9axBct2YUbGwTlzCDyNSEy09Smwr78KRNOkLr2fX3ZjmtyBibTqw5plcbZNfhrr/YS4/Ft3quSJK4GEopVVt2GWUFPGj7bgF0jHDi0PNbSOTYqZCtg7Uyx/Td/7ije4cMBWUAw68POeTE+xu7BliHJBKz4H1Bb+KRdyq8nBx5N8ZyGzOwBz3 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.