mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
rlimits test: don't exceed nr_open.
Even superuser cannot raise RLIMIT_NOFILE above /proc/sys/fs/nr_open, so start the test by lowering the limits before raising. Change-Id: Ied6021c64178a6cb9098088a1a3384db523a226f PiperOrigin-RevId: 242965249
This commit is contained in:
committed by
Shentubot
parent
89cc8eef9b
commit
c8368e477b
@@ -29,6 +29,12 @@ TEST(RlimitTest, SetRlimitHigher) {
|
||||
struct rlimit rl = {};
|
||||
EXPECT_THAT(getrlimit(RLIMIT_NOFILE, &rl), SyscallSucceeds());
|
||||
|
||||
// Lower the rlimit first, as it may be equal to /proc/sys/fs/nr_open, in
|
||||
// which case even users with CAP_SYS_RESOURCE can't raise it.
|
||||
rl.rlim_cur--;
|
||||
rl.rlim_max--;
|
||||
ASSERT_THAT(setrlimit(RLIMIT_NOFILE, &rl), SyscallSucceeds());
|
||||
|
||||
rl.rlim_max++;
|
||||
EXPECT_THAT(setrlimit(RLIMIT_NOFILE, &rl), SyscallSucceeds());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user