summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/socket/netstack
diff options
context:
space:
mode:
authorNayana Bidari <nybidari@google.com>2020-03-02 16:30:51 -0800
committergVisor bot <gvisor-bot@google.com>2020-03-02 16:31:52 -0800
commit43abb24657e737dee1108ff0d512b2e1b6d8a3f6 (patch)
treeb217bfeb0656f0a4988432e581f0023234b6850b /pkg/sentry/socket/netstack
parentd80b6a6e498fa9301250572a1abcfa68c5aaaa1c (diff)
Fix panic caused by invalid address for Bind in packet sockets.
PiperOrigin-RevId: 298476533
Diffstat (limited to 'pkg/sentry/socket/netstack')
-rw-r--r--pkg/sentry/socket/netstack/netstack.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/pkg/sentry/socket/netstack/netstack.go b/pkg/sentry/socket/netstack/netstack.go
index 1eeb37446..13a9a60b4 100644
--- a/pkg/sentry/socket/netstack/netstack.go
+++ b/pkg/sentry/socket/netstack/netstack.go
@@ -712,6 +712,10 @@ func (s *SocketOperations) Connect(t *kernel.Task, sockaddr []byte, blocking boo
// Bind implements the linux syscall bind(2) for sockets backed by
// tcpip.Endpoint.
func (s *SocketOperations) Bind(t *kernel.Task, sockaddr []byte) *syserr.Error {
+ if len(sockaddr) < 2 {
+ return syserr.ErrInvalidArgument
+ }
+
family := usermem.ByteOrder.Uint16(sockaddr)
var addr tcpip.FullAddress