Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux: Adjust rlimit SIGPENDING & MSGQUEUE behaviour to match linprocfs #1227

Merged
merged 1 commit into from
May 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions sys/compat/linux/linux_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1125,16 +1125,16 @@
}

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 @@
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 @@
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 @@
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,10 +2026,10 @@
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
Loading