svn commit: r366749 - head/sys/compat/linux
Edward Tomasz Napierala
trasz at FreeBSD.org
Fri Oct 16 10:10:10 UTC 2020
Author: trasz
Date: Fri Oct 16 10:10:09 2020
New Revision: 366749
URL: https://svnweb.freebsd.org/changeset/base/366749
Log:
Make linux getrlimit(2) and prlimit(2) return something reasonable
for linux-specific limits. Fixes prlimit (util-linux-2.31.1-0.4ubuntu3.7).
Reviewed by: emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26777
Modified:
head/sys/compat/linux/linux_misc.c
head/sys/compat/linux/linux_misc.h
Modified: head/sys/compat/linux/linux_misc.c
==============================================================================
--- head/sys/compat/linux/linux_misc.c Fri Oct 16 09:58:10 2020 (r366748)
+++ head/sys/compat/linux/linux_misc.c Fri Oct 16 10:10:09 2020 (r366749)
@@ -1373,6 +1373,28 @@ linux_getgroups(struct thread *td, struct linux_getgro
return (0);
}
+static bool
+linux_get_dummy_limit(l_uint resource, struct rlimit *rlim)
+{
+
+ 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;
+ return (true);
+ case LINUX_RLIMIT_NICE:
+ case LINUX_RLIMIT_RTPRIO:
+ rlim->rlim_cur = 0;
+ rlim->rlim_max = 0;
+ return (true);
+ default:
+ return (false);
+ }
+}
+
int
linux_setrlimit(struct thread *td, struct linux_setrlimit_args *args)
{
@@ -1405,6 +1427,12 @@ linux_old_getrlimit(struct thread *td, struct linux_ol
struct rlimit bsd_rlim;
u_int which;
+ if (linux_get_dummy_limit(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)));
+ }
+
if (args->resource >= LINUX_RLIM_NLIMITS)
return (EINVAL);
@@ -1440,6 +1468,12 @@ linux_getrlimit(struct thread *td, struct linux_getrli
struct rlimit bsd_rlim;
u_int which;
+ if (linux_get_dummy_limit(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)));
+ }
+
if (args->resource >= LINUX_RLIM_NLIMITS)
return (EINVAL);
@@ -2137,6 +2171,14 @@ linux_prlimit64(struct thread *td, struct linux_prlimi
u_int which;
int flags;
int error;
+
+ if (args->new == NULL && args->old != NULL) {
+ if (linux_get_dummy_limit(args->resource, &rlim)) {
+ lrlim.rlim_cur = rlim.rlim_cur;
+ lrlim.rlim_max = rlim.rlim_max;
+ return (copyout(&lrlim, args->old, sizeof(lrlim)));
+ }
+ }
if (args->resource >= LINUX_RLIM_NLIMITS)
return (EINVAL);
Modified: head/sys/compat/linux/linux_misc.h
==============================================================================
--- head/sys/compat/linux/linux_misc.h Fri Oct 16 09:58:10 2020 (r366748)
+++ head/sys/compat/linux/linux_misc.h Fri Oct 16 10:10:09 2020 (r366749)
@@ -137,12 +137,12 @@ extern int stclohz;
#define LINUX_P_PID 1
#define LINUX_P_PGID 2
-#define LINUX_RLIMIT_LOCKS RLIM_NLIMITS + 1
-#define LINUX_RLIMIT_SIGPENDING RLIM_NLIMITS + 2
-#define LINUX_RLIMIT_MSGQUEUE RLIM_NLIMITS + 3
-#define LINUX_RLIMIT_NICE RLIM_NLIMITS + 4
-#define LINUX_RLIMIT_RTPRIO RLIM_NLIMITS + 5
-#define LINUX_RLIMIT_RTTIME RLIM_NLIMITS + 6
+#define LINUX_RLIMIT_LOCKS 10
+#define LINUX_RLIMIT_SIGPENDING 11
+#define LINUX_RLIMIT_MSGQUEUE 12
+#define LINUX_RLIMIT_NICE 13
+#define LINUX_RLIMIT_RTPRIO 14
+#define LINUX_RLIMIT_RTTIME 15
#define LINUX_RLIM_INFINITY (~0UL)
More information about the svn-src-head
mailing list