Skip to content

Commit 4fe38ac

Browse files
dhowellskuba-moo
authored andcommitted
net: Block MSG_SENDPAGE_* from being passed to sendmsg() by userspace
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 <[email protected]> cc: Chuck Lever <[email protected]> cc: Boris Pismenny <[email protected]> cc: John Fastabend <[email protected]> cc: Jens Axboe <[email protected]> cc: Matthew Wilcox <[email protected]> Link: https://lore.kernel.org/r/[email protected]/ [1] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7360132 commit 4fe38ac

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

include/linux/socket.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ struct ucred {
339339
#endif
340340

341341
/* Flags to be cleared on entry by sendmsg and sendmmsg syscalls */
342-
#define MSG_INTERNAL_SENDMSG_FLAGS (MSG_SPLICE_PAGES)
342+
#define MSG_INTERNAL_SENDMSG_FLAGS \
343+
(MSG_SPLICE_PAGES | MSG_SENDPAGE_NOPOLICY | MSG_SENDPAGE_NOTLAST | \
344+
MSG_SENDPAGE_DECRYPTED)
343345

344346
/* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */
345347
#define SOL_IP 0

0 commit comments

Comments
 (0)