Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3499101rdb; Wed, 13 Sep 2023 14:05:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEnLarJcCPFD7/2AqbtlUgmK8lV3tL2b7bhN4x8BT1C+gKzOnjv01nQOfBZw1Ub8Q+DE+oc X-Received: by 2002:a05:6870:d205:b0:1bf:a95:7a3f with SMTP id g5-20020a056870d20500b001bf0a957a3fmr4311190oac.54.1694639101070; Wed, 13 Sep 2023 14:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694639101; cv=none; d=google.com; s=arc-20160816; b=zNTxoPWZj2qgCuv0mHCQDBXzVlgRhzQJkDUxZYmUpxZZ1MQgmIpvAOmy/8hPogZoMh w+j8ZrgPBVasU+i34Sry0whdvfdW9C6OB2sCIznhWqTJh2C4Jn671FygSed8MGpqAzfc ifwLAC/sxL+LiOOvp1nRaacID5+8WKDjrRqEPx7JZvDbI4LUi2g8NtODoKZswfzE+cCg VF0DMSL8uyP7pB1IwSn8ApHKHEUYiRnmAeyw0v4BhANU/loUvY4vRE9HUj+nva2Cowae UFKNEgN98Xq9nrkjbIEEFKGSvrD0Uf9d9fEfMjgMtfreczRFhYWiT4F97PUXhqsuAbrW iEHQ== 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:cc:to:from :dkim-signature; bh=c2st9mzpODW5EfnFYy73QjLkmO48eOaJEcOSoL9qczM=; fh=D00b+ExO44XKLceYW8cVdIEOVtr2e1iL7r354EPHkWw=; b=OLRt8UXE7T8ksn3XU3ChXvoTAxzEiOxgUBmC7+PxqUwoT4bo46Yak9jXD6B1tCfYot WlKHxhkSRn6gJ6T7xs0AYB2YnOTAVrAuqqlrUK01PGQ+u6aaXukWkhuJlO+NxRpYcuVE MVh32u1GEXl6t5AFB1bcXF2ajJVK+12whiVM3unXGOoVcMUxi5aWEKymEdeJlv1m6TMj TC/BlaBdvyDh+xYi4LlnW/ZsTX9VU/4kiT44JbuE69cg9PG2KM3RIe04pCXNYcU24pSK oGgu6dxrGJS6NKcFkawWzNe9Ixb+sMii5CAttx7NAfC7Vu5HmDg8DVZ07DfOd+O170eG rzoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jTPv8luH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id 205-20020a6301d6000000b00573fe94635asi10855353pgb.642.2023.09.13.14.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 14:05:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jTPv8luH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 753F28029AED; Wed, 13 Sep 2023 09:59:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231325AbjIMQ67 (ORCPT + 99 others); Wed, 13 Sep 2023 12:58:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231326AbjIMQ6U (ORCPT ); Wed, 13 Sep 2023 12:58:20 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EA9231BFE for ; Wed, 13 Sep 2023 09:57:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694624249; 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=jTPv8luHErXXN8O+zfc9gdL2+9jP/3NiBXnbclwOHr01pbGPTiLkpGFLA464WMon6hoVee dJCWzxhVqAeicj3yJU/nWVfmvge0aaW13XQvAD3jQzzCDfCvrKU+rTThYAXpKg+jkLF3d1 7zOnqo5QcZBDzGuHHDbMksppNz1r3QU= 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 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:59:16 -0700 (PDT) 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.