mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 18:39:59 +00:00
bpf: do not blindly change rlimit in reuseport net selftest
[ Upstream commit262f9d811c
] If the current process has unlimited RLIMIT_MEMLOCK, we should should leave it as is. Fixes:941ff6f11c
("bpf: fix rlimit in reuseport net selftest") Signed-off-by: John Sperbeck <jsperbeck@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
43c7313ec7
commit
9c9cd35cb3
1 changed files with 9 additions and 4 deletions
|
@ -437,14 +437,19 @@ void enable_fastopen(void)
|
|||
}
|
||||
}
|
||||
|
||||
static struct rlimit rlim_old, rlim_new;
|
||||
static struct rlimit rlim_old;
|
||||
|
||||
static __attribute__((constructor)) void main_ctor(void)
|
||||
{
|
||||
getrlimit(RLIMIT_MEMLOCK, &rlim_old);
|
||||
rlim_new.rlim_cur = rlim_old.rlim_cur + (1UL << 20);
|
||||
rlim_new.rlim_max = rlim_old.rlim_max + (1UL << 20);
|
||||
setrlimit(RLIMIT_MEMLOCK, &rlim_new);
|
||||
|
||||
if (rlim_old.rlim_cur != RLIM_INFINITY) {
|
||||
struct rlimit rlim_new;
|
||||
|
||||
rlim_new.rlim_cur = rlim_old.rlim_cur + (1UL << 20);
|
||||
rlim_new.rlim_max = rlim_old.rlim_max + (1UL << 20);
|
||||
setrlimit(RLIMIT_MEMLOCK, &rlim_new);
|
||||
}
|
||||
}
|
||||
|
||||
static __attribute__((destructor)) void main_dtor(void)
|
||||
|
|
Loading…
Reference in a new issue