From owner-svn-src-all@freebsd.org Wed Mar 21 23:50:47 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 10837F4F51D; Wed, 21 Mar 2018 23:50:47 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B5ECD6FA05; Wed, 21 Mar 2018 23:50:46 +0000 (UTC) (envelope-from jamie@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 B0EC21503; Wed, 21 Mar 2018 23:50:46 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2LNok2Z071226; Wed, 21 Mar 2018 23:50:46 GMT (envelope-from jamie@FreeBSD.org) Received: (from jamie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2LNokLZ071225; Wed, 21 Mar 2018 23:50:46 GMT (envelope-from jamie@FreeBSD.org) Message-Id: <201803212350.w2LNokLZ071225@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jamie set sender to jamie@FreeBSD.org using -f From: Jamie Gritton Date: Wed, 21 Mar 2018 23:50:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331332 - head/lib/libjail X-SVN-Group: head X-SVN-Commit-Author: jamie X-SVN-Commit-Paths: head/lib/libjail X-SVN-Commit-Revision: 331332 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Mar 2018 23:50:47 -0000 Author: jamie Date: Wed Mar 21 23:50:46 2018 New Revision: 331332 URL: https://svnweb.freebsd.org/changeset/base/331332 Log: If a jail parameter isn't found, try loading a related kernel module. Modified: head/lib/libjail/jail.c Modified: head/lib/libjail/jail.c ============================================================================== --- head/lib/libjail/jail.c Wed Mar 21 23:46:26 2018 (r331331) +++ head/lib/libjail/jail.c Wed Mar 21 23:50:46 2018 (r331332) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -59,6 +60,7 @@ __FBSDID("$FreeBSD$"); static int jailparam_import_enum(const char **values, int nvalues, const char *valstr, size_t valsize, int *value); static int jailparam_type(struct jailparam *jp); +static int kldload_param(const char *name); static char *noname(const char *name); static char *nononame(const char *name); @@ -892,6 +894,9 @@ jailparam_type(struct jailparam *jp) "sysctl(0.3.%s): %s", name, strerror(errno)); return (-1); } + if (kldload_param(name) >= 0 && sysctl(mib, 2, mib + 2, &miblen, + desc.s, strlen(desc.s)) >= 0) + goto mib_desc; /* * The parameter probably doesn't exist. But it might be * the "no" counterpart to a boolean. @@ -1028,6 +1033,33 @@ jailparam_type(struct jailparam *jp) jp->jp_valuelen = 0; } return (0); +} + +/* + * Attempt to load a kernel module matching an otherwise nonexistent parameter. + */ +static int +kldload_param(const char *name) +{ + int kl; + + if (strcmp(name, "linux") == 0 || strncmp(name, "linux.", 6) == 0) + kl = kldload("linux"); + else if (strcmp(name, "sysvmsg") == 0 || strcmp(name, "sysvsem") == 0 || + strcmp(name, "sysvshm") == 0) + kl = kldload(name); + else { + errno = ENOENT; + return (-1); + } + if (kl < 0 && errno == EEXIST) { + /* + * In the module is already loaded, then it must not contain + * the parameter. + */ + errno = ENOENT; + } + return kl; } /*