Message ID | 20230405165339.3468808-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 B7F45C77B62 for <linux-mm@archiver.kernel.org>; Wed, 5 Apr 2023 16:54:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 78DE86B0083; Wed, 5 Apr 2023 12:54:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 684B46B0095; Wed, 5 Apr 2023 12:54:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3EBC06B0093; Wed, 5 Apr 2023 12:54:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 2C6286B0092 for <linux-mm@kvack.org>; Wed, 5 Apr 2023 12:54:44 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0887F1C6A06 for <linux-mm@kvack.org>; Wed, 5 Apr 2023 16:54:44 +0000 (UTC) X-FDA: 80647936488.26.CA20589 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 5572920004 for <linux-mm@kvack.org>; Wed, 5 Apr 2023 16:54:42 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GyC+EHaT; spf=pass (imf13.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=1680713682; 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=OMwy0qt4L2slgfHXAMvoFhpKJLhShXlB6/4lgaiCeU4=; b=ADSNgP2n6GiBzRMZV5JGI8nKcB3YYmVEkR550G734QaaZ3Qweq3VB70YV89DEKz0kxeEhR dW2scKxlA70uzOg6Er74QJvGMVztWfNcw/oBSGKGhk/npNMq82lvmkLwIUU6DXLCw4cH6O U0BABuU7jeNM/9WqZ/a8tXDVbOBFYh0= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GyC+EHaT; spf=pass (imf13.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680713682; a=rsa-sha256; cv=none; b=FJsRv92sjlxVLuHKliLGW/sM292OPREQdSBwbRZ543FgP1Hs+5QmNjtfG5VU372QPgvim3 TOS0gR/vxfVJplRUnLku/yNpMx3h24S7xsiNYxyFaF/D12ySjAzksk1/AlFAuP7yWxDoBv ogLA/KSz0EdgCX/b6np+Wc3rS6kai9A= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680713681; 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=OMwy0qt4L2slgfHXAMvoFhpKJLhShXlB6/4lgaiCeU4=; b=GyC+EHaTcAe1EVxUF330CWQcciaBgviOvY+fGvsBjb7EM9dDrUsnboO2eEVSzXyZIaHPD8 qSoL3QpVarIk1QHGK9Exq32sp4ERczJIwBBWssQcUVtwYZ8WYSv0f/ALT0s2AUWIhK2/aq fM+kjMk0MJgzLg/87hzwcaChQxYdZPA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.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-160-4RoSPamyNOOyKJ-8OPZdCA-1; Wed, 05 Apr 2023 12:54:36 -0400 X-MC-Unique: 4RoSPamyNOOyKJ-8OPZdCA-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 044E23823A0B; Wed, 5 Apr 2023 16:54:34 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2DAE2166B26; Wed, 5 Apr 2023 16:54:31 +0000 (UTC) From: David Howells <dhowells@redhat.com> To: netdev@vger.kernel.org Cc: David Howells <dhowells@redhat.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Willem de Bruijn <willemdebruijn.kernel@gmail.com>, Matthew Wilcox <willy@infradead.org>, 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>, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH net-next v4 17/20] ip, udp: Make sendmsg(MSG_SPLICE_PAGES) copy unspliceable data Date: Wed, 5 Apr 2023 17:53:36 +0100 Message-Id: <20230405165339.3468808-18-dhowells@redhat.com> In-Reply-To: <20230405165339.3468808-1-dhowells@redhat.com> References: <20230405165339.3468808-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 5572920004 X-Rspam-User: X-Stat-Signature: 5ygsx4cebsbi8ruadfnbbspm6xhgqoeo X-HE-Tag: 1680713682-334846 X-HE-Meta: U2FsdGVkX1/0Ti7jgAvr7WFDzHncZt6cIJXTNdamA6xrrzgggL2Jn+tGOLWrs/Uoa+e3wf8Eery9F+kqDq70ChVM1sNjIqROjhohYC8mPa+CUmMrPi6AGrxe/+hfwQUq1Q5lYMHCe0xbMFrvrg8yrsyDYZaJ0PweBShh+qR7CSWJqJQg44pujl0r7VK/g888IsYpRQk8y/RMKnMqGGRQYcfH5iub1ViXZK9kxH15JWg2/XpOXJouZJMTlG6JSM9LgGAyq2QBVlYAyKsAr5/UmFxdcN+34bq3bDI9Fc0mSa95whuXt1bEjTQLWmlPYNdqbzF9+cr7S98QNAz6sNHAdbzUryk462+prttxSHZf7YrzEJXSB8RF6P+UC1Wm+060cIRJBtSeO5OG3P2s4oufHbE6VChZxzmbM95AgnkonweZXWW2hHpPesxWfewQ+VZupb23RUG2H+NWPALRRBhccS0K4m6L9QnObfH73OdSAjA7qgT5z7q/Nz9gn8cshK/lVV+ArYPqrR4y0RQI1s5xigjCuGlfWTs8Kqqss5Vp6wUf8dC3v5jIDr5G3O0Kq00vcuwbS45qB8WJJywWnU9Evg9XUCOg70sawArDu0QBsm3ef1ReVXO5eUzCLyNS1YpEeAtRKvjKEuGwYvnWnqPEVYf/c4dKU0XyGGnpHXighqXGSV6h0F1xGu+JchPpwmeSmgvgF94YoIleCMTq3DinXithBjl8LnlWu4/srhDW+bZhgrNRct28vEyQk5sENRCvoz+naLjL2fs+hpTf5zdHp6ri4IwaBOt1dyXMktV7BmPbJPoLVRsvh8KbOLF32gMMM3QF8wUX827E8ei71jmlwGOKk9tISQ1Fxzt7cM65PTzT4G7y24cYdZxndjXpRY8pBSpeTCYM1Vkcgz6sBBamPacfJ6DZgwTYWwfi8qM2Ak5C3LWbV2r2LgD/rnBDSeKOC4X/BQFd/guCq1+48sr W6mNcuW1 LhPcTlukqntSkYDvGKPK4kBA4TX8s/E1fGOfSRbsjy3a7ICkOLxn3MLf7gBLIYuSzSl0kF/Jkj3StdHWlqZsOh9UC2w+N3lzNXrs/s3NQLD8XXbZeUC/4fYqPAcjMDcyGMAp8oAqXDKFjmj1vATInTjm7JZWEREI1VEJYy5K9xBmcWM5dWyLuL3J7s+S1g7+3zofXL5uEGU3Ei/44pOnnVqpWO7NcwqhvYtBnOiAzRprVd4ryQxGiZI9H/la9HGjv0g63ymH78JkQtmc4adgatkxRIZ+Gb+hbqVa7rLnLsHhPsP5H+nIliIzhKpL2Z90rYxddJtEcysEJ1RKJmqQu1uKncC6zShS687VurAVN+qzGCy1+rdfr2iGP5ku8CujDraD1XZtKVr2xfk0HI1coYRyDpVePNY27gAGhd+ECk9yK8a+t443JisaoG2fpNZ89s16s6wBc8ut8wKoSfojjSFXwtkRpKxoDiAX3d95k1rG7asmCgppEYg5W9D1nhA0OpkpjbuuZHVws94ZXDsbZrkny6Q== 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), part 1
|
expand
|
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 13d19867ffd3..e34c86b1b59a 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -967,13 +967,32 @@ static int __ip_splice_pages(struct sock *sk, struct sk_buff *skb, struct page *page = NULL, **pages = &page; ssize_t copy = *pcopy; size_t off; + bool put = false; int err; copy = iov_iter_extract_pages(&msg->msg_iter, &pages, copy, 1, 0, &off); if (copy <= 0) return copy ?: -EIO; + 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) { + iov_iter_revert(&msg->msg_iter, copy); + return -ENOMEM; + } + 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) { iov_iter_revert(&msg->msg_iter, copy); return err;
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(+)