diff options
author | Dean Deng <deandeng@google.com> | 2019-12-20 08:43:15 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-12-20 08:44:53 -0800 |
commit | 822d847ccaa1e6016b818bee289b5e33335f9fee (patch) | |
tree | 1ac3d9a4eac9b02b4be10b6212f9132c3c6c2164 /pkg | |
parent | 29955a4797e8264f75886a989dbc81b2b5443f4c (diff) |
Check for valid nfds before copying in an fd set.
Otherwise, CopyInFDSet will try to allocate a negative-length slice.
PiperOrigin-RevId: 286584907
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/sentry/strace/select.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/pkg/sentry/strace/select.go b/pkg/sentry/strace/select.go index dea309fda..c77d418e6 100644 --- a/pkg/sentry/strace/select.go +++ b/pkg/sentry/strace/select.go @@ -36,6 +36,9 @@ func fdsFromSet(t *kernel.Task, set []byte) []int { } func fdSet(t *kernel.Task, nfds int, addr usermem.Addr) string { + if nfds < 0 { + return fmt.Sprintf("%#x (negative nfds)", addr) + } if addr == 0 { return "null" } |