Message ID | 20230329141354.516864-18-dhowells@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 29215C74A5B for <linux-mm@archiver.kernel.org>; Wed, 29 Mar 2023 14:14:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7461E6B0092; Wed, 29 Mar 2023 10:14:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F6346B0093; Wed, 29 Mar 2023 10:14:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5490E6B0095; Wed, 29 Mar 2023 10:14:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3ADDB6B0092 for <linux-mm@kvack.org>; Wed, 29 Mar 2023 10:14:54 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 08334C087B for <linux-mm@kvack.org>; Wed, 29 Mar 2023 14:14:54 +0000 (UTC) X-FDA: 80622132108.23.10DF25E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 3950DC0021 for <linux-mm@kvack.org>; Wed, 29 Mar 2023 14:14:51 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FSI+KyXh; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1680099292; 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=vWPvILWC7NBdevnbDDsys9XJnr3/cfzKJoNpaM2CnAc=; b=ARkd1dh95vZlSeJyKzT5Nsaq5nYc5Lf5AQCJkmlToYs1roV9vJebrIZUSn0Gp0SXZ4g0Mt 0d/s9n55IFB+7N4atrI68h6l9a+h1MYZaI3mQomPwBc3nJinL4viEF11PUyWnDGNkUvxMZ 7yc2iXdxhAN0cnF6ydr/EL5cnqCf3Cs= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FSI+KyXh; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680099292; a=rsa-sha256; cv=none; b=t/QstaGfDbcA4S0p4lQ0YIrl+IGUcSnu04wc8heBmWkombBUODsOMOpG61qpqfutM3JWM9 XAfiY3YHvl2Oxh148tnF/aoO51T3uz3Y4pH9lkfssHQoZqNrHsZCqKMBstSN9f3sI+SnCa I8CHrSNuym9hkb072/ZcmRl/r9y1A7E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680099291; 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=vWPvILWC7NBdevnbDDsys9XJnr3/cfzKJoNpaM2CnAc=; b=FSI+KyXh+2/YdW6/xxN7eVFCkMQANmgjZXHTwByL76B37RT5IZckHDYMGvBbemr/Av/bcI 1RARGV8IIwGWmPsl3UZpqTOTkGP0HkxG9q9Qe1YDEqolAGnDrhF9U2RltVeblcXqm+BCZQ iKN2aHNpOFJUjGVeYHj4D6LTwkWizwk= 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-612-2VMedOL2PkqYySq_Hlwhxg-1; Wed, 29 Mar 2023 10:14:47 -0400 X-MC-Unique: 2VMedOL2PkqYySq_Hlwhxg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76C28185A7A9; Wed, 29 Mar 2023 14:14:46 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8174D2166B33; Wed, 29 Mar 2023 14:14:44 +0000 (UTC) From: David Howells <dhowells@redhat.com> To: Matthew Wilcox <willy@infradead.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: David Howells <dhowells@redhat.com>, Al Viro <viro@zeniv.linux.org.uk>, Christoph Hellwig <hch@infradead.org>, Jens Axboe <axboe@kernel.dk>, Jeff Layton <jlayton@kernel.org>, Christian Brauner <brauner@kernel.org>, Chuck Lever III <chuck.lever@oracle.com>, Linus Torvalds <torvalds@linux-foundation.org>, netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Willem de Bruijn <willemdebruijn.kernel@gmail.com> Subject: [RFC PATCH v2 17/48] ip, udp: Make sendmsg(MSG_SPLICE_PAGES) copy unspliceable data Date: Wed, 29 Mar 2023 15:13:23 +0100 Message-Id: <20230329141354.516864-18-dhowells@redhat.com> In-Reply-To: <20230329141354.516864-1-dhowells@redhat.com> References: <20230329141354.516864-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 3950DC0021 X-Stat-Signature: mrqtjjtrberhftaqarrjzp671mt93rs6 X-HE-Tag: 1680099291-410495 X-HE-Meta: U2FsdGVkX1/ie2PkAqjkcs2l/+OYGk3bbm1aN/x3hTdJrmSMlVvKmwghLXLBaWbjRe7gNp75evQ3UtMo5ddKe9ud/7zF4gxsgPdDb1fxgGVyMlskXZknsZVs9DmcMGnfoQaTNI4CRJmxVFEWl7+Pr48mPlPUS4e0XnlmfNue2+mJ2tbwanPXa5izj0TOISlsunJXV/JY8WlvdO1CxDVii2UaKI+3nxR0an6s+X+8c1lh6QQR18IZ1j0RDnV8k1Gj+wCsjbzp+kkDOHq8Dg3cm9bFBqJ+fDepmGBEpbJlCx7KnIztckHpDveyO+AKPbYM6uOOP8G1pWM1GR99fwxac/1PyWfFNwxHSkWSEcdAxDfRO6Cpsq5sCpM6AHTGHvEzdIVgznQOb6/anpPZMD1AzJHL2G3Kb1+w35tqdrnxkf87d0c0zbwKBWteQL1Pz9hsL/KoPnhXPlSNCKNRkuc9vJNXw8QrA9TKIBzPV3FaMCAoz42I0DTh21FbcdmG80wwFpB0yGk4YmUsOGURxIuBfPtEAzVmMyrmOrrBVK36fClc+K8CxDfo9dr3kzBMrYBuGUKMztSQ2LgFufRZbuit7aUU7gxzUwewa2oJzrt0zo9cmIQfGVwqoQ5o0suBq83gJ4NzgNc8A3LC6zaAawPRKRSjLCF4zJZxOBvISzk/fb0tG2fMDfb85Ce6V2GOFVovZhQftxqlFh+hmQBhpRnTLhFhnq/KG90o5IPhCP49N2IvaZbvTyUY9fsWi6k5mlQnXYWAOuf1Ds3BjVbfd7gAbPuUYOqUS9gwgNxaAEV8ndW2dj5b1w11P0aodFlUKEHeGbpWCduR9OjRM0Mo4cMDJkX6j6RaJkamP4SbYM2Ok2yYndoHbLXJjTai8k8gcXJw+yA0tILliNM3ShqBcqLAEgQuEHmMhr4EONE9n43Im+oM5eErGt37+uaAMPNYHtCjE/lvHS/HZhzeKda8Ezt dVpUKzw4 Jj6cE94QRgCYAsn9Nbk5peYyklgFAH56EgK4Bt0G7IUdU9oT24zPBQYZ7HauSl5ZFiLggMsOL90EGPU2Y/rl1yuurRRQNz/fYcZZBBKUEw1IeY5BJLsG5EACv8Ld/oEUUFEOGD0bwkpUQpyUlQIGIa7GKaiNxu0mD7Z0vibGbCJ8nOq4Hu0xalroxHUPmJ6MeSfZ11N2buxpBX9eR0A/BxPHBQY95xtUsg/xvB86TyzvFIor+6W2nOSwex+xyCUie6RqZ9FsxDyMW2zqLz/JKK/Fu7z+kATE9Ik+tBv/T9eu+mbmCRd7EVwMU71gXBPmXIz3+N3znabPN3mncxv3MrfxDaSBeZizTXYrwF8CB63ejnaVH1swG6Dw7qLt2XkTaMFJw7/hpAACwa+PD6Xp4oQ2o8cNXFT8KxxAsvpo/JEtzI5HsjhnMNyxAvHhcOGhLbyIsF+G526xjMiEJBMuKBJTY/6FNpnTAz7QLFCbfbbQsiyEfFfWxlzkTUPeVqHxsadyoBc6Gm/kLpGyO0dHipysSng== 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: <linux-mm.kvack.org> |
Series |
splice, net: Replace sendpage with sendmsg(MSG_SPLICE_PAGES)
|
expand
|
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 07736da70eab..e4aeaab704c8 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -1263,6 +1263,7 @@ static int __ip_append_data(struct sock *sk, struct msghdr *msg = from; struct page *page = NULL, **pages = &page; size_t off; + bool put = false; copy = iov_iter_extract_pages(&msg->msg_iter, &pages, copy, 1, 0, &off); @@ -1271,7 +1272,25 @@ static int __ip_append_data(struct sock *sk, goto error; } + if (!sendpage_ok(page)) { + const void *p = kmap_local_page(page); + void *q; + + q = page_frag_memdup(NULL, p + off, copy, + sk->sk_allocation, ULONG_MAX); + kunmap_local(p); + if (!q) { + err = copy ?: -ENOMEM; + goto error; + } + page = virt_to_page(q); + off = offset_in_page(q); + put = true; + } + err = skb_append_pagefrags(skb, page, off, copy); + if (put) + put_page(page); if (err < 0) goto error;
If sendmsg() with MSG_SPLICE_PAGES encounters a page that shouldn't be spliced - a slab page, for instance, or one with a zero count - make __ip_append_data() copy it. Signed-off-by: David Howells <dhowells@redhat.com> cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com> cc: "David S. Miller" <davem@davemloft.net> cc: Eric Dumazet <edumazet@google.com> cc: Jakub Kicinski <kuba@kernel.org> cc: Paolo Abeni <pabeni@redhat.com> cc: Jens Axboe <axboe@kernel.dk> cc: Matthew Wilcox <willy@infradead.org> cc: netdev@vger.kernel.org --- net/ipv4/ip_output.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)