From bdb4a4c5ea6925119dc5c76a9c0c32a2cba03c81 Mon Sep 17 00:00:00 2001 From: Nicolas Lacasse Date: Mon, 6 Mar 2023 19:33:59 -0800 Subject: [PATCH] hostinet: Allow MSG_OOB in send/recvmsg. This is needed for the python runtime tests (not yet enabled for hostinet). PiperOrigin-RevId: 514593833 --- pkg/sentry/socket/hostinet/socket.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/sentry/socket/hostinet/socket.go b/pkg/sentry/socket/hostinet/socket.go index d8b2fde0a..806055d8e 100644 --- a/pkg/sentry/socket/hostinet/socket.go +++ b/pkg/sentry/socket/hostinet/socket.go @@ -480,6 +480,7 @@ func (s *Socket) recvMsgFromHost(iovs []unix.Iovec, flags int, senderRequested b const allowedRecvMsgFlags = unix.MSG_CTRUNC | unix.MSG_DONTWAIT | unix.MSG_ERRQUEUE | + unix.MSG_OOB | unix.MSG_PEEK | unix.MSG_TRUNC | unix.MSG_WAITALL @@ -653,10 +654,17 @@ func parseUnixControlMessages(unixControlMessages []unix.SocketControlMessage) s return controlMessages } +const allowedSendMsgFlags = unix.MSG_DONTWAIT | + unix.MSG_EOR | + unix.MSG_FASTOPEN | + unix.MSG_MORE | + unix.MSG_NOSIGNAL | + unix.MSG_OOB + // SendMsg implements socket.Socket.SendMsg. func (s *Socket) SendMsg(t *kernel.Task, src usermem.IOSequence, to []byte, flags int, haveDeadline bool, deadline ktime.Time, controlMessages socket.ControlMessages) (int, *syserr.Error) { // Only allow known and safe flags. - if flags&^(unix.MSG_DONTWAIT|unix.MSG_EOR|unix.MSG_FASTOPEN|unix.MSG_MORE|unix.MSG_NOSIGNAL) != 0 { + if flags&^allowedSendMsgFlags != 0 { return 0, syserr.ErrInvalidArgument }