diff options
author | Zach Koopmans <zkoopmans@google.com> | 2021-08-30 15:32:22 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-08-30 15:35:02 -0700 |
commit | dfbcb8903ae8bd0d1ff984889f1b5cf1e041865e (patch) | |
tree | f38c3de45bb102e17971f428fed0099ac69b6a2c /test/syscalls/linux/socket_unix.cc | |
parent | a247e227b1f629392d0a9132dc490a6ef9ee2519 (diff) |
[syserr] Fix SIGBUS on syserr.FromError
Fix syzcaller panic SIGBUS on error handling. Done by
adding an interface, errors.GuestError, which errors can
implement in order to be compared against each other.
PiperOrigin-RevId: 393867554
Diffstat (limited to 'test/syscalls/linux/socket_unix.cc')
-rw-r--r-- | test/syscalls/linux/socket_unix.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/syscalls/linux/socket_unix.cc b/test/syscalls/linux/socket_unix.cc index cf96b2075..43433eaae 100644 --- a/test/syscalls/linux/socket_unix.cc +++ b/test/syscalls/linux/socket_unix.cc @@ -27,7 +27,10 @@ #include "gtest/gtest.h" #include "absl/strings/string_view.h" #include "test/syscalls/linux/unix_domain_socket_test_util.h" +#include "test/util/file_descriptor.h" +#include "test/util/memory_util.h" #include "test/util/socket_util.h" +#include "test/util/temp_path.h" #include "test/util/test_util.h" #include "test/util/thread_util.h" @@ -268,6 +271,18 @@ TEST_P(UnixSocketPairTest, SocketReopenFromProcfs) { } } +// Repro for b/196804997. +TEST_P(UnixSocketPairTest, SendFromMmapBeyondEof) { + TempPath file = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateFile()); + FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(Open(file.path(), O_RDONLY)); + Mapping m = ASSERT_NO_ERRNO_AND_VALUE( + Mmap(nullptr, kPageSize, PROT_READ, MAP_SHARED, fd.get(), 0)); + + auto sockets = ASSERT_NO_ERRNO_AND_VALUE(NewSocketPair()); + ASSERT_THAT(send(sockets->first_fd(), m.ptr(), m.len(), 0), + SyscallFailsWithErrno(EFAULT)); +} + } // namespace } // namespace testing |