mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
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
This commit is contained in:
+11
-2
@@ -247,6 +247,15 @@ type SockAddrUnix struct {
|
||||
Path [UnixPathMax]int8
|
||||
}
|
||||
|
||||
// Linger is struct linger, from include/linux/socket.h.
|
||||
type Linger struct {
|
||||
OnOff int32
|
||||
Linger int32
|
||||
}
|
||||
|
||||
// SizeOfLinger is the binary size of a Linger struct.
|
||||
const SizeOfLinger = 8
|
||||
|
||||
// TCPInfo is a collection of TCP statistics.
|
||||
//
|
||||
// From uapi/linux/tcp.h.
|
||||
@@ -322,8 +331,8 @@ type TCPInfo struct {
|
||||
SndBufLimited uint64
|
||||
}
|
||||
|
||||
// SizeOfTCPInfo is the binary size of a TCPInfo struct (104 bytes).
|
||||
var SizeOfTCPInfo = binary.Size(TCPInfo{})
|
||||
// SizeOfTCPInfo is the binary size of a TCPInfo struct.
|
||||
const SizeOfTCPInfo = 104
|
||||
|
||||
// Control message types, from linux/socket.h.
|
||||
const (
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user