summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/socket/epsocket
diff options
context:
space:
mode:
authorIan Gudger <igudger@google.com>2019-04-18 11:50:26 -0700
committerShentubot <shentubot@google.com>2019-04-18 11:51:41 -0700
commit133700007a8495c7d8df53801b1d34345d6c5cf8 (patch)
tree36e95255f49cb1bc56a7e166233240cc0fed2465 /pkg/sentry/socket/epsocket
parent4524790ff668674149ad6ae6eec805369be0c6e3 (diff)
Only emit unimplemented syscall events for unsupported values.
Only emit unimplemented syscall events for setting SO_OOBINLINE and SO_LINGER when attempting to set unsupported values. PiperOrigin-RevId: 244229675 Change-Id: Icc4562af8f733dd75a90404621711f01a32a9fc1
Diffstat (limited to 'pkg/sentry/socket/epsocket')
-rw-r--r--pkg/sentry/socket/epsocket/epsocket.go31
1 files changed, 29 insertions, 2 deletions
diff --git a/pkg/sentry/socket/epsocket/epsocket.go b/pkg/sentry/socket/epsocket/epsocket.go
index 78f43178f..f370b803b 100644
--- a/pkg/sentry/socket/epsocket/epsocket.go
+++ b/pkg/sentry/socket/epsocket/epsocket.go
@@ -783,10 +783,10 @@ func getSockOptSocket(t *kernel.Task, s socket.Socket, ep commonEndpoint, family
return int32(v), nil
case linux.SO_LINGER:
- if outLen < syscall.SizeofLinger {
+ if outLen < linux.SizeOfLinger {
return nil, syserr.ErrInvalidArgument
}
- return syscall.Linger{}, nil
+ return linux.Linger{}, nil
case linux.SO_SNDTIMEO:
// TODO: Linux allows shorter lengths for partial results.
@@ -1126,6 +1126,33 @@ func setSockOptSocket(t *kernel.Task, s socket.Socket, ep commonEndpoint, name i
s.SetRecvTimeout(v.ToNsecCapped())
return nil
+ case linux.SO_OOBINLINE:
+ if len(optVal) < sizeOfInt32 {
+ return syserr.ErrInvalidArgument
+ }
+
+ v := usermem.ByteOrder.Uint32(optVal)
+
+ if v == 0 {
+ socket.SetSockOptEmitUnimplementedEvent(t, name)
+ }
+
+ return syserr.TranslateNetstackError(ep.SetSockOpt(tcpip.OutOfBandInlineOption(v)))
+
+ case linux.SO_LINGER:
+ if len(optVal) < linux.SizeOfLinger {
+ return syserr.ErrInvalidArgument
+ }
+
+ var v linux.Linger
+ binary.Unmarshal(optVal[:linux.SizeOfLinger], usermem.ByteOrder, &v)
+
+ if v != (linux.Linger{}) {
+ socket.SetSockOptEmitUnimplementedEvent(t, name)
+ }
+
+ return nil
+
default:
socket.SetSockOptEmitUnimplementedEvent(t, name)
}