Fix linuxulator prlimit64(2) with pid == 0. This makes 'ulimit -a'

return something reasonable, and helps linux binaries which attempt
to close all the files, eg apt(8).

Reviewed by:	emaste
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D20692
This commit is contained in:
Edward Tomasz Napierala 2019-07-04 19:40:01 +00:00
parent d2860f22a4
commit 2478d444d1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=349746

View File

@ -2001,10 +2001,14 @@ linux_prlimit64(struct thread *td, struct linux_prlimit64_args *args)
flags |= PGET_CANDEBUG;
else
flags |= PGET_CANSEE;
error = pget(args->pid, flags, &p);
if (error != 0)
return (error);
if (args->pid == 0) {
p = td->td_proc;
PHOLD(p);
} else {
error = pget(args->pid, flags, &p);
if (error != 0)
return (error);
}
if (args->old != NULL) {
PROC_LOCK(p);
lim_rlimit_proc(p, which, &rlim);