From nobody Sat Mar 26 02:17:08 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7523C1A4C275; Sat, 26 Mar 2022 02:17:08 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KQMzS2vBxz4bNY; Sat, 26 Mar 2022 02:17:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648261028; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=veXqOi61g6d+/q3ywCd5OODvPimkdS8UNP8b6mTZH5E=; b=Q8loO47YVPMtIO6Nvsa080GgCqfpo6/F+yEgr6qHmDFia0EombYSc0rF4IO7ZCxRCLP7CE INYuA0t51ui+RwxrYlFyeyFenWz+8To42eTt8BYCO0EA2mYT0tOhGOfSgYNR8u9UFD/3Ik VRR7A5TldFQt6W6D4H5U7FHHV8HBNpep/LfG5IBtvlJd/yz+BIs8pn+0PzglzRZ1snjdSe y92uw01XUHAZJt8qUbOpS2xFeUbbxZSPHhhdt4pXeiYrLPvDOK83ewZZ/bBYjI+yC+o434 yITzZTl4WDDKXoE7gdHio7x5vyYqULcE8w0gfndAZ2WgBIPI+0f4YZVOrmPyeQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4071018798; Sat, 26 Mar 2022 02:17:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22Q2H8WS045460; Sat, 26 Mar 2022 02:17:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22Q2H8IP045459; Sat, 26 Mar 2022 02:17:08 GMT (envelope-from git) Date: Sat, 26 Mar 2022 02:17:08 GMT Message-Id: <202203260217.22Q2H8IP045459@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jamie Gritton Subject: git: 8f1543785f77 - main - jail: handle jailsys parameters in modification permission test List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jamie X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8f1543785f77086494c73310ba8f5d09b61ff7eb Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648261028; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=veXqOi61g6d+/q3ywCd5OODvPimkdS8UNP8b6mTZH5E=; b=xaeuNOZJTJPvsAKYPSGOeIQtMoccuH1/PNUxyxMFA3sVfOZqfy+KzzVqD9veY3RO5Zn8ma D+bbpPm5mSRi88KeqmU0lEtIKe0SCBCZb6RLVkI0LHB+4bz8H3gU7fPfVNoD/VOaRyo/cN e//kyN+hfQolQmbdHEyAsEcGnAz7CvebLmsUhRI9UIDdgxMuaPxH3VRefGO/r37nPQH0Hl JstR8buy7RfrM17g/jYYc9rYcrqfHSSwDzV7PeqLnkot/YGhUl0YLhOln7sraHVLyMGVC/ Oq+gvhhDtud2+To0fr39ml+opCLiZahCbiamKDgIAbZRpucs9JAdZvidgyRD/A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648261028; a=rsa-sha256; cv=none; b=QXe+HkcS8auokZzOc5JHRrm2HH/QCvIL/5A8cTd/zvkna6PFOmrR9n7dCBx9Herc046NZd Y+iDazhR2IEi7zzTkrnWijJwglMQ8kl0jaRWCTcFVZypnz9ULzxlVNXez6xP4dW0Z3Fi/j kJ6CuoKcnGZMbU/T4+utg1LVdAdnwXAEw5b42INKwaMCThCxK90S8BWexHFROgnwKX6NzN l3VYt3Bv7lD1WI3S+N5fMABd8ZEu33Yd98NCs3omxDSDcM3r5sPB+xmJB90epCsw4/Hs2D S1G1AEhRrlL/qBdOcJyn2Rfm17zmVdhyeuClLlA+Tqn2GftRfDgQQdLMjIut2Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jamie: URL: https://cgit.FreeBSD.org/src/commit/?id=8f1543785f77086494c73310ba8f5d09b61ff7eb commit 8f1543785f77086494c73310ba8f5d09b61ff7eb Author: Jamie Gritton AuthorDate: 2022-03-26 02:16:51 +0000 Commit: Jamie Gritton CommitDate: 2022-03-26 02:16:51 +0000 jail: handle jailsys parameters in modification permission test Avoid a null dereference when a value-less jailsys parameter is passed to "jail -m". There was already code to handle boolean parameters, but in reality any parameter could be passed without a value. --- usr.sbin/jail/jail.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/usr.sbin/jail/jail.c b/usr.sbin/jail/jail.c index eb3b19f2cb82..63096146f176 100644 --- a/usr.sbin/jail/jail.c +++ b/usr.sbin/jail/jail.c @@ -790,7 +790,9 @@ static int rdtun_params(struct cfjail *j, int dofail) { struct jailparam *jp, *rtparams, *rtjp; - int nrt, rval; + const void *jp_value; + size_t jp_valuelen; + int nrt, rval, bool_true; if (j->flags & JF_RDTUN) return 0; @@ -818,15 +820,25 @@ rdtun_params(struct cfjail *j, int dofail) rtjp = rtparams + 1; for (jp = j->jp; rtjp < rtparams + nrt; jp++) { if (JP_RDTUN(jp) && strcmp(jp->jp_name, "jid")) { - if (!((jp->jp_flags & (JP_BOOL | JP_NOBOOL)) && - jp->jp_valuelen == 0 && - *(int *)jp->jp_value) && - !(rtjp->jp_valuelen == jp->jp_valuelen && - !((jp->jp_ctltype & CTLTYPE) == - CTLTYPE_STRING ? strncmp(rtjp->jp_value, - jp->jp_value, jp->jp_valuelen) : - memcmp(rtjp->jp_value, jp->jp_value, - jp->jp_valuelen)))) { + jp_value = jp->jp_value; + jp_valuelen = jp->jp_valuelen; + if (jp_value == NULL && jp_valuelen > 0) { + if (jp->jp_flags & (JP_BOOL | + JP_NOBOOL | JP_JAILSYS)) { + bool_true = 1; + jp_value = &bool_true; + jp_valuelen = sizeof(bool_true); + } else if ((jp->jp_ctltype & CTLTYPE) == + CTLTYPE_STRING) + jp_value = ""; + else + jp_valuelen = 0; + } + if (rtjp->jp_valuelen != jp_valuelen || + (CTLTYPE_STRING ? strncmp(rtjp->jp_value, + jp_value, jp_valuelen) + : memcmp(rtjp->jp_value, jp_value, + jp_valuelen))) { if (dofail) { jail_warnx(j, "%s cannot be " "changed after creation",