From owner-svn-src-stable@freebsd.org Wed Aug 15 21:38:14 2018 Return-Path: Delivered-To: svn-src-stable@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 BC89610719B2; Wed, 15 Aug 2018 21:38:14 +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 485077D9E9; Wed, 15 Aug 2018 21:38:11 +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 D60A3102DD; Wed, 15 Aug 2018 21:38:10 +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 w7FLcAB9092437; Wed, 15 Aug 2018 21:38:10 GMT (envelope-from jamie@FreeBSD.org) Received: (from jamie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7FLcAax092436; Wed, 15 Aug 2018 21:38:10 GMT (envelope-from jamie@FreeBSD.org) Message-Id: <201808152138.w7FLcAax092436@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jamie set sender to jamie@FreeBSD.org using -f From: Jamie Gritton Date: Wed, 15 Aug 2018 21:38:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r337875 - stable/11/lib/libjail X-SVN-Group: stable-11 X-SVN-Commit-Author: jamie X-SVN-Commit-Paths: stable/11/lib/libjail X-SVN-Commit-Revision: 337875 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Aug 2018 21:38:14 -0000 Author: jamie Date: Wed Aug 15 21:38:10 2018 New Revision: 337875 URL: https://svnweb.freebsd.org/changeset/base/337875 Log: MFC r331332: If a jail parameter isn't found, try loading a related kernel module. PR: 192092 Modified: stable/11/lib/libjail/jail.c Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libjail/jail.c ============================================================================== --- stable/11/lib/libjail/jail.c Wed Aug 15 21:38:06 2018 (r337874) +++ stable/11/lib/libjail/jail.c Wed Aug 15 21:38:10 2018 (r337875) @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -57,6 +58,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); @@ -885,6 +887,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. @@ -1021,6 +1026,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; } /*