summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorAyush Ranjan <ayushranjan@google.com>2021-10-25 13:43:37 -0700
committergVisor bot <gvisor-bot@google.com>2021-10-25 13:46:41 -0700
commit4d07fc952d6bb5aa70b4bc9ff5e6457987f1721c (patch)
tree75442613af4360c670d235f541e0811d68dd1442 /test
parenta8a66d899fe075c2a23b21edd0aab4e658ad7e81 (diff)
Do not leak non-permission mode bits in mq_open(2).
As caught by syzkaller, we were leaking non-permission bits while passing the user generated mode. DynamicBytesFile panics in this case. Reported-by: syzbot+5abe52d47d56a5a98c89@syzkaller.appspotmail.com PiperOrigin-RevId: 405481392
Diffstat (limited to 'test')
-rw-r--r--test/syscalls/linux/mq.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/test/syscalls/linux/mq.cc b/test/syscalls/linux/mq.cc
index 36181f149..839877a67 100644
--- a/test/syscalls/linux/mq.cc
+++ b/test/syscalls/linux/mq.cc
@@ -34,8 +34,6 @@ namespace gvisor {
namespace testing {
namespace {
-using ::testing::_;
-
// PosixQueue is a RAII class used to automatically clean POSIX message queues.
class PosixQueue {
public:
@@ -124,8 +122,13 @@ PosixError MqClose(mqd_t fd) {
// Test simple opening and closing of a message queue.
TEST(MqTest, Open) {
SKIP_IF(IsRunningWithVFS1());
- EXPECT_THAT(MqOpen(O_RDWR | O_CREAT | O_EXCL, 0777, nullptr),
- IsPosixErrorOkAndHolds(_));
+ ASSERT_NO_ERRNO(MqOpen(O_RDWR | O_CREAT | O_EXCL, 0777, nullptr));
+}
+
+TEST(MqTest, ModeWithFileType) {
+ SKIP_IF(IsRunningWithVFS1());
+ // S_IFIFO should be ignored.
+ ASSERT_NO_ERRNO(MqOpen(O_RDWR | O_CREAT | O_EXCL, 0777 | S_IFIFO, nullptr));
}
// Test mq_open(2) after mq_unlink(2).