Message ID | 20230607181920.2294972-2-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 B0D63C7EE25 for <linux-mm@archiver.kernel.org>; Wed, 7 Jun 2023 18:19:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 01ABF900002; Wed, 7 Jun 2023 14:19:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F0CD66B0074; Wed, 7 Jun 2023 14:19:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6075900002; Wed, 7 Jun 2023 14:19:37 -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 C7A426B0072 for <linux-mm@kvack.org>; Wed, 7 Jun 2023 14:19:37 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6DE321C79A4 for <linux-mm@kvack.org>; Wed, 7 Jun 2023 18:19:37 +0000 (UTC) X-FDA: 80876764794.25.361CBDE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 9FC8120029 for <linux-mm@kvack.org>; Wed, 7 Jun 2023 18:19:34 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X+75NLCH; spf=pass (imf13.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=1686161974; a=rsa-sha256; cv=none; b=U1gN3xnR6pkcargki5+TnDV1OMU3EA8sRQbBWwRH/8d5I3H/o5jx/ZpxTbUNPCK2wBfNB3 ZPrdS76oy/iXX/G8xQqkiwt+3mrC9YMruYVfCWs/XSqYjfJiLPjMYAHkE36Yg+YFUoxiuF yToTXkOjAxZy0imdVl5PbA2YxfnohTA= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X+75NLCH; spf=pass (imf13.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=1686161974; 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=704Gul1es5vKB8f3fNlqLP0xfed1dEhsuWb+SLm3klg=; b=XYVIUsFQJ9Y7j3fAxVQKQu7hRxA9LzjD7JNvAH18L7gQRt0+FrWkpf2qp+58i6UfxX+Auf l981PRYFRU97oTTz/CNqQZA/brTkSUbMJq1XTJfwpDVo2kxFl3W8aAdV5tEjFTyClZtf4B qdEl4AMEeOFvxj4p9FxPewFVRvJMDz4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686161973; 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=704Gul1es5vKB8f3fNlqLP0xfed1dEhsuWb+SLm3klg=; b=X+75NLCHdNw9IUdjV0vY4keSL11jwbhdJAxDrikGBHUkfYJGVjJRj8ZaUW3Uskf5RMZg9E 2IOkwpXxe6PsJdgmdyvDAw7fCJ/JZ2sMrkCmVdLqwq0AypDbRBZJ2ozmCsvKLL8jFxS0/z 0ABj1JALZcyy4sshI3xFqbR5r0xRwHA= 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-639-mJrSACM1MtWkA-dGsaZ40A-1; Wed, 07 Jun 2023 14:19:30 -0400 X-MC-Unique: mJrSACM1MtWkA-dGsaZ40A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B083C3C0F220; Wed, 7 Jun 2023 18:19:28 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4158140D1B66; Wed, 7 Jun 2023 18:19:26 +0000 (UTC) From: David Howells <dhowells@redhat.com> To: netdev@vger.kernel.org, Linus Torvalds <torvalds@linux-foundation.org> Cc: David Howells <dhowells@redhat.com>, Chuck Lever <chuck.lever@oracle.com>, Boris Pismenny <borisp@nvidia.com>, John Fastabend <john.fastabend@gmail.com>, Jakub Kicinski <kuba@kernel.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Paolo Abeni <pabeni@redhat.com>, Willem de Bruijn <willemdebruijn.kernel@gmail.com>, David Ahern <dsahern@kernel.org>, Matthew Wilcox <willy@infradead.org>, Jens Axboe <axboe@kernel.dk>, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v6 01/14] net: Block MSG_SENDPAGE_* from being passed to sendmsg() by userspace Date: Wed, 7 Jun 2023 19:19:07 +0100 Message-ID: <20230607181920.2294972-2-dhowells@redhat.com> In-Reply-To: <20230607181920.2294972-1-dhowells@redhat.com> References: <20230607181920.2294972-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 9FC8120029 X-Stat-Signature: y1hsxuhwbzh13iqyondc5m8zfxdjf7rg X-Rspam-User: X-HE-Tag: 1686161974-955396 X-HE-Meta: U2FsdGVkX1+HQK7BoCOL5JXJDZvl4R9rwdZuszGmuqkXHtDterJ2P3owrgXjgfBWvVtMk45PEfkUKTPmy26NgsUE/kzzAb9q4muoSk3p09tvU9481M2uX9lqroxH3t/mldyD2eEnO/7DhomaPKDZ3w6ntcF6lGriFRkDOd0hUWAB/gdYQLOf0DzhkrVAd2Q4cyk0y8yrEzmaYxslGZh6Aony4o3Vv3BwGcS+QBYn1QzTjKaunL/oBUVhlbrhy+8Z7OFv8otE9KkEvTem7YuSftI6LdF5xnFm0EShtPbj53q9JRj+GsXqwOctjj4jKn7X20PU/ATp6KKM3fgxzALflaNpo2rxut6FpgNIQw5fNQSeWG4EjrTaAYj13Fp8tGO82D+6ZrTZTKxQoruXqRBTwfpTXIsMWvwrqqg1qTkg9QSeVR2J8+TkUW2l5d6OwFMg/4lSdLRRR2+BSx0Ri9IcFMNFQTDnYTdZZKMKWlqPwqy/+3hFyXcFv3hQf125q8fwPQEBZRE+3/uK1Vr/GE8pREzHM3gH/y1dbdqWIvhu4D0HxieQ+Dx3lud7/1tnnMro1RVBlp46yKWFbU/IoKTWfVttHtVwtyfLotWDeX6F4k/p2n0XQ/cmY/IeMqygB6jajphw2/SVCmSnZz8rq+qeCBE2IBI3L55Fh9jcn6Y9r5CPdRiMicX+3K07H3Wk3XtXdlCB8UZFiQhwcXFVJj9iM4rwGUDO2/tOzXlVXUHSkQ950ZMs2qR8SyRo4bI+6+BbgK+nQkEwp1C+d6rKUnoZ7bvozB9WFwT79JrbvyVHXuBFltj5pBruggSdcMI62+Y4iEV87RtAbBqOAUvaHBasoZcf7lAnTkCO+eks3/ZNyrXNB05bu9w0lGZ336tBxZgwsO52CSfolzlqqsznlRYNA0M/t1f+0cWUTNhSVS3iLqv61kGBg8dU+GeMDQCDQcAiazfKHODyn0nZ/3f/Uyy 1U3KzTCH nFs4AsCJWfl0qroBtoD+l/rbTVSmPVsIw8QcSirreuVmGiCguPYlEwRcjqRH959Wkj1h8tFHV1v95p8TU/jTHRSxj6nlqn2aijHzotrWscpHPg3nyiJ8ohfxuwEdrXoJ845o/v+C3XsLe82N8UQNtsGwrvE81z0ye18pt16Bt5VtFole+RWD8LePKNdyW6Rg7ZGBAaqtlgDtniaiIygGhUVsoZpTYsgsPKh+wlK2uUJ8XmL6ZA96v0y9Zhs2J554/zkF18Ol5QjKcbu8VFD6cwdLNg5kTM+HppjDjqvf49XVDMkVavDxSspKjzvyAENYJ2GDEAkuHUWcXlMixwh7Jv0HPjHdZ2qGr4wvzd4oG2W4mDKs/ol5IGMuT39+h9Bvk5cZPGVCXov+5bDvE/sf/mo+VJY6DnsLg4oshrZEsd6SYgOrCn4aIoXRTGw9zc4DwX34nJQt0b6NxSrOL89rTKtpNho07xFgU5SA7/JU0eK3o0Mp+IyYiqcoQfHrfmUn1IFetAcZdUzRh1Mj+uSiGcW/uAp+UXkqCV72NuevmcVJORGHLeBVuOJ/gkA== 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: Rewrite splice-to-socket, fix SPLICE_F_MORE and handle MSG_SPLICE_PAGES in AF_TLS
|
expand
|
diff --git a/include/linux/socket.h b/include/linux/socket.h index bd1cc3238851..3fd3436bc09f 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -339,7 +339,9 @@ struct ucred { #endif /* Flags to be cleared on entry by sendmsg and sendmmsg syscalls */ -#define MSG_INTERNAL_SENDMSG_FLAGS (MSG_SPLICE_PAGES) +#define MSG_INTERNAL_SENDMSG_FLAGS \ + (MSG_SPLICE_PAGES | MSG_SENDPAGE_NOPOLICY | MSG_SENDPAGE_NOTLAST | \ + MSG_SENDPAGE_DECRYPTED) /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */ #define SOL_IP 0
It is necessary to allow MSG_SENDPAGE_* to be passed into ->sendmsg() to allow sendmsg(MSG_SPLICE_PAGES) to replace ->sendpage(). Unblocking them in the network protocol, however, allows these flags to be passed in by userspace too[1]. Fix this by marking MSG_SENDPAGE_NOPOLICY, MSG_SENDPAGE_NOTLAST and MSG_SENDPAGE_DECRYPTED as internal flags, which causes sendmsg() to object if they are passed to sendmsg() by userspace. Network protocol ->sendmsg() implementations can then allow them through. Note that it should be possible to remove MSG_SENDPAGE_NOTLAST once sendpage is removed as a whole slew of pages will be passed in in one go by splice through sendmsg, with MSG_MORE being set if it has more data waiting in the pipe. Signed-off-by: David Howells <dhowells@redhat.com> cc: Jakub Kicinski <kuba@kernel.org> cc: Chuck Lever <chuck.lever@oracle.com> cc: Boris Pismenny <borisp@nvidia.com> cc: John Fastabend <john.fastabend@gmail.com> cc: Eric Dumazet <edumazet@google.com> cc: "David S. Miller" <davem@davemloft.net> cc: Paolo Abeni <pabeni@redhat.com> cc: Jens Axboe <axboe@kernel.dk> cc: Matthew Wilcox <willy@infradead.org> cc: netdev@vger.kernel.org Link: https://lore.kernel.org/r/20230526181338.03a99016@kernel.org/ [1] --- include/linux/socket.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)