From owner-svn-src-head@freebsd.org Fri Oct 16 10:10:10 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 835F842F786; Fri, 16 Oct 2020 10:10:10 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CCMN22s4Zz4jJ8; Fri, 16 Oct 2020 10:10:10 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 45487ED10; Fri, 16 Oct 2020 10:10:10 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09GAAAe5024792; Fri, 16 Oct 2020 10:10:10 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09GAA9J0024790; Fri, 16 Oct 2020 10:10:09 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <202010161010.09GAA9J0024790@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Fri, 16 Oct 2020 10:10:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366749 - head/sys/compat/linux X-SVN-Group: head X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: head/sys/compat/linux X-SVN-Commit-Revision: 366749 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Oct 2020 10:10:10 -0000 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)