Skip to content

Commit

Permalink
linux: Adjust rlimit SIGPENDING & MSGQUEUE behaviour to match linprocfs
Browse files Browse the repository at this point in the history
Reviewed by: imp
Pull Request: #1227
  • Loading branch information
ricardobranco777 authored and bsdimp committed May 10, 2024
1 parent 9e01640 commit a7cc56b
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions sys/compat/linux/linux_misc.c
Expand Up @@ -1125,16 +1125,16 @@ linux_getgroups(struct thread *td, struct linux_getgroups_args *args)
}

static bool
linux_get_dummy_limit(l_uint resource, struct rlimit *rlim)
linux_get_dummy_limit(struct thread *td, l_uint resource, struct rlimit *rlim)
{
ssize_t size;
int res, error;

if (linux_dummy_rlimits == 0)
return (false);

switch (resource) {
case LINUX_RLIMIT_LOCKS:
case LINUX_RLIMIT_SIGPENDING:
case LINUX_RLIMIT_MSGQUEUE:
case LINUX_RLIMIT_RTTIME:
rlim->rlim_cur = LINUX_RLIM_INFINITY;
rlim->rlim_max = LINUX_RLIM_INFINITY;
Expand All @@ -1144,6 +1144,23 @@ linux_get_dummy_limit(l_uint resource, struct rlimit *rlim)
rlim->rlim_cur = 0;
rlim->rlim_max = 0;
return (true);
case LINUX_RLIMIT_SIGPENDING:
error = kernel_sysctlbyname(td,
"kern.sigqueue.max_pending_per_proc",
&res, &size, 0, 0, 0, 0);
if (error != 0)
return (false);
rlim->rlim_cur = res;
rlim->rlim_max = res;
return (true);
case LINUX_RLIMIT_MSGQUEUE:
error = kernel_sysctlbyname(td,
"kern.ipc.msgmnb", &res, &size, 0, 0, 0, 0);
if (error != 0)
return (false);
rlim->rlim_cur = res;
rlim->rlim_max = res;
return (true);
default:
return (false);
}
Expand Down Expand Up @@ -1181,7 +1198,7 @@ linux_old_getrlimit(struct thread *td, struct linux_old_getrlimit_args *args)
struct rlimit bsd_rlim;
u_int which;

if (linux_get_dummy_limit(args->resource, &bsd_rlim)) {
if (linux_get_dummy_limit(td, args->resource, &bsd_rlim)) {
rlim.rlim_cur = bsd_rlim.rlim_cur;
rlim.rlim_max = bsd_rlim.rlim_max;
return (copyout(&rlim, args->rlim, sizeof(rlim)));
Expand Down Expand Up @@ -1222,7 +1239,7 @@ linux_getrlimit(struct thread *td, struct linux_getrlimit_args *args)
struct rlimit bsd_rlim;
u_int which;

if (linux_get_dummy_limit(args->resource, &bsd_rlim)) {
if (linux_get_dummy_limit(td, args->resource, &bsd_rlim)) {
rlim.rlim_cur = bsd_rlim.rlim_cur;
rlim.rlim_max = bsd_rlim.rlim_max;
return (copyout(&rlim, args->rlim, sizeof(rlim)));
Expand Down Expand Up @@ -2009,7 +2026,7 @@ linux_prlimit64(struct thread *td, struct linux_prlimit64_args *args)
int error;

if (args->new == NULL && args->old != NULL) {
if (linux_get_dummy_limit(args->resource, &rlim)) {
if (linux_get_dummy_limit(td, args->resource, &rlim)) {
lrlim.rlim_cur = rlim.rlim_cur;
lrlim.rlim_max = rlim.rlim_max;
return (copyout(&lrlim, args->old, sizeof(lrlim)));

Check warning on line 2032 in sys/compat/linux/linux_misc.c

View workflow job for this annotation

GitHub Actions / Style Checker

Missing Signed-off-by: line
Expand Down

0 comments on commit a7cc56b

Please sign in to comment.