Message ID | 20230607140559.2263470-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 87F49C7EE29 for <linux-mm@archiver.kernel.org>; Wed, 7 Jun 2023 14:30:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26AFB8E0002; Wed, 7 Jun 2023 10:30:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 21B328E0001; Wed, 7 Jun 2023 10:30:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 10A3F8E0002; Wed, 7 Jun 2023 10:30:23 -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 0116F8E0001 for <linux-mm@kvack.org>; Wed, 7 Jun 2023 10:30:22 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A8C598027F for <linux-mm@kvack.org>; Wed, 7 Jun 2023 14:30:22 +0000 (UTC) X-FDA: 80876187084.01.3BE4B25 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 44ACCA0005 for <linux-mm@kvack.org>; Wed, 7 Jun 2023 14:30:18 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="bn/qOzkA"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1686148219; 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=ZWDYDwvuxpsJcpT8CYojB9f+V7RuYt/qz0gEJv/92ubJ0kvDCArmJXRVSnSw8L/eJY4W7s c9a/vEh7VSDZEGkDXwl4+pMXW2a2bj7q7tG3fjg3gTxbOH5ZmP2hCAWwOCYDMiUV5vf1H2 7FEyQqTnoCsuLZeQVlgEPg9RaaPb8jE= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="bn/qOzkA"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686148219; a=rsa-sha256; cv=none; b=ehIRYPJqIESTjLrwBGaH7yTFY4sH0t+O5VcTJqP2blTacJPzBnxz58Sh2INhc4QFaCNaAK gSEZyGYyFpwPgLzlhR2hs8Rynn2LfHCisf1AYv+7QMefelGnVh+hksNd3xOcjFfH5FOfdL jb5SganoZRn5bz4GCI1NqUyZSVvZmds= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686148217; 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=bn/qOzkApdQM/LWC9c1oeeDg0dgq6ElOFl4Di0rErVEsdObvHdvKaa9iA9TRtMLb7pDzpV StYMQY/GpcoOA9MGv1T1gMibxQUZS7Ktd4AUnJQDnZhrKPzsLXsc5sbBfY+QraGjf++hkD U6s6P6QqgSGbj9Z9jGZHrK+D9IgXwTc= 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-635-TJH48CwcMEypUtBg4mC4JQ-1; Wed, 07 Jun 2023 10:06:10 -0400 X-MC-Unique: TJH48CwcMEypUtBg4mC4JQ-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 E0D86800969; Wed, 7 Jun 2023 14:06:09 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE97F2166B25; Wed, 7 Jun 2023 14:06:05 +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 v5 01/14] net: Block MSG_SENDPAGE_* from being passed to sendmsg() by userspace Date: Wed, 7 Jun 2023 15:05:46 +0100 Message-ID: <20230607140559.2263470-2-dhowells@redhat.com> In-Reply-To: <20230607140559.2263470-1-dhowells@redhat.com> References: <20230607140559.2263470-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-Queue-Id: 44ACCA0005 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: dw54ahzodgqfsoxp411aiscm83wu4ioq X-HE-Tag: 1686148218-43425 X-HE-Meta: U2FsdGVkX1/Lsq3wvFw6ydqvZmdbbP4yObHzRk6mORzvtSwe6tXAqYEZFeF0lOG8p0m8VStACZlg9LxG1VtW957A5LJIV8eJde0XZvLhRRpOd+2E+/2XaV80I7JMhzGSxwPKNr4AwvGk2t0/JeMOJiJDHvsNQ8Bx6geyH41014eTCySDbHRz1PWI1DIBqwF29VctP5lRG5DKTROTw9yNsJN+VhWDHePgEjXhxs+COcVQHdbYN7w2YjYZRNhdCY03CbOorWdxlxr2fu/8a5Egg1YKq28Yx01H5wgE6Z2Fv4K7LCPP7gpmRM7Q2vv1gO4eg3nhz4WAv6wEbDmzpkGJ+0bi/mPfroCKsVN4/lHjzrxsZsht30YHaxtBgqsIvWqJwCjeB8PR9/6KEget6pgg8IdbvPUyRbZLzi7apxpFKFu8kt0tqZeerdkGt67+CirIB9Rn1zd6c0mL4v59N3FswO5QFeaXUWSxVIMFIR75R6VJn/4MHuDmxLkvRE/SGQc5I6/8NoqfGYkyuLTkvUvHF7q0qTw0lZfeDKz70ky68NwOxHF4xlx7v3i5sKpaIJqb0MZaoAWOH6qKUlywmokIbkwVB4KPvA7fYJHAvTrGHXjiZyY1I5S+17Dv+zVu0AZLChdHw6YU719Cdr+foBkWlasTOc81XfzACZ0dDKDeMFe0YBg465buEApdELqA5hwQq9oybfBepAqmImAu2mrUecEvffM/Nxmy9fQLbCQPzaEIwJOiuKe6tsJYqZ7hwWAOrSK1DBYjfqlZBA9vwBy04SAhPacEowUwR4HqHXbn+3RIer96B18NZQ8ZXJmDga8rNAnR9w3HIdIrL1Mc72iJpypdP/kpnCjGNDWTYT4irzcYUDu7V98xoqI6NejDM0E+Q53Xr1TKq2xsxvhMkhMpgIXctBACGVUzrtPQhRGYklBpXPUQ1Mt0SWW2hREsByrUH15l8I4SM8sCidg06Dh A/K4SXQ/ Qxf9Y+ebXTZfDfnwDxtFOE4NSsBUpWfdKR85dOy/b09xxrJSmwRfQclta07JVejtFbXG225ipaIti53fB0N/0Xt7Rpqpy56KB2yD0TF56P3X1EJdJB8VWjPP+1DywzLF6rtpVvk1U7iChXtTsss37d3B+O7ZdrzaAg4wHm83UJaiAuBHfv5r4wctV7g3OpTfbhKLbX01KWdUdMOG8jEGhoMKiujvlQgrEW2yeFhy7zznpvINP33z+5ASp01+lZF9jClxKnVqOm4erwcj1U24+SchIjjtxorjJ8U/w5MR6+eu9bUXjicCNrdCXEqI7Fkk8lxptUbri+X1ryuzk4Rq8iWaz7OJ/3OEv+Uz/aPeC0Tc5X6ATVQjEdDw9kKM/W02YSUFxml2//ZDc5bwzMES2G0QvKfK+8wdqYdTDlnRlfx3R+76W/C4WZn5gC9A3lNi/qsrtpdix2Lt9VVKi/hWg3y/pknOrxrq8WacwS8Q0vjqlvZqSWWWGI1MF9aTr4qGnIR0K0HK1efkwUxP6V9+A63uK/7dXfPu5i/3NO4nAc9tEUjvk778xCuBiWg== 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(-)