From f7aff0aaa4320505933df838cf5b551b69d5e513 Mon Sep 17 00:00:00 2001 From: Kevin Krakauer Date: Wed, 10 Apr 2019 12:35:43 -0700 Subject: Allow threads with CAP_SYS_RESOURCE to raise hard rlimits. PiperOrigin-RevId: 242919489 Change-Id: Ie3267b3bcd8a54b54bc16a6556369a19e843376f --- test/syscalls/linux/rlimits.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'test/syscalls/linux') diff --git a/test/syscalls/linux/rlimits.cc b/test/syscalls/linux/rlimits.cc index dc31bad9a..5a6174d99 100644 --- a/test/syscalls/linux/rlimits.cc +++ b/test/syscalls/linux/rlimits.cc @@ -25,15 +25,12 @@ namespace { TEST(RlimitTest, SetRlimitHigher) { SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_SYS_RESOURCE))); - SKIP_IF(!IsRunningOnGvisor()); struct rlimit rl = {}; EXPECT_THAT(getrlimit(RLIMIT_NOFILE, &rl), SyscallSucceeds()); - // TODO: Even with CAP_SYS_RESOURCE, gVisor does not allow - // setting a higher rlimit. rl.rlim_max++; - EXPECT_THAT(setrlimit(RLIMIT_NOFILE, &rl), SyscallFailsWithErrno(EPERM)); + EXPECT_THAT(setrlimit(RLIMIT_NOFILE, &rl), SyscallSucceeds()); } TEST(RlimitTest, UnprivilegedSetRlimit) { @@ -56,6 +53,16 @@ TEST(RlimitTest, UnprivilegedSetRlimit) { EXPECT_THAT(setrlimit(RLIMIT_NOFILE, &rl), SyscallFailsWithErrno(EPERM)); } +TEST(RlimitTest, SetSoftRlimitAboveHard) { + SKIP_IF(!ASSERT_NO_ERRNO_AND_VALUE(HaveCapability(CAP_SYS_RESOURCE))); + + struct rlimit rl = {}; + EXPECT_THAT(getrlimit(RLIMIT_NOFILE, &rl), SyscallSucceeds()); + + rl.rlim_cur = rl.rlim_max + 1; + EXPECT_THAT(setrlimit(RLIMIT_NOFILE, &rl), SyscallFailsWithErrno(EINVAL)); +} + } // namespace } // namespace testing -- cgit v1.2.3