From nobody Sun Feb 04 22:53:09 2024 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 4TSlCn5KvBz590B1; Sun, 4 Feb 2024 22:53:09 +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 4TSlCn2dybz4Ybb; Sun, 4 Feb 2024 22:53:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707087189; 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=26PUn/PkRZ39SZ1tuKa3+V6pb0AIHiH+IG4hs5BkT3s=; b=Q7aMILb/RX8u64iFHjqytPJ9526bvGAG6eGA50jyfBg8u3cUc7mxchHB8tMHXd5ACXbE8F R10RV7V0ciwmXY3exLk02ULECejPkV2T/o1vZWclq4WfJcTw65qAzdjI/umPGJWIqjVQQ3 Uir6dMc5VhZTpbYi3L7JWgiwabwmd9xk/D+x+I0ZoQ/EAhUM/SEA0tE5mUC1h8Y9lissT8 Rgtoi4EubrfUFZRaj5C2j23+2oHsd3A0L9KrG6wN7+AjXd0VSItW/vhrc3LTIvCXe7tm7y FibeQRC205oLlEmNyvn5n0UNZU5qRrvGB6HSf6/l+jFh128L/bZ5xb9q86J/tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707087189; 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=26PUn/PkRZ39SZ1tuKa3+V6pb0AIHiH+IG4hs5BkT3s=; b=vK0gclcMab18B/W+vpoqh0hFc/QexI1BNM2wdLGHftG1z66EDhuBGLFK8uoRlrk60jDP49 Pg0nuSLE0aByGOVcEupfRywqXGXM+AmnaYBJic65EE+cMnxnkrujcDU5mcHFHFSZvKnRX5 WBsQI3OQWH+3zVwvRYkDhwYJLKzJ0+x/Z//bGRbyKzSfeIuwK8lZv0QNsxsiJ8rGceXYia sof7ygDqePdfMsXCfzlieLGuQ8SLMr2oa3lB3HHCl9Qe8WzdDN2+cjKaJFaa2DZkePNWYr ebCwGFrR8R10IlVuH2AMjn4qh1a5DzgLb+zI7dC+9D+S3R1Lcx8xc58YIu9d1w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707087189; a=rsa-sha256; cv=none; b=ArX3Sw5B6nKaOafOAxg3bKzyXOtP4uEfqleaxLfafYKEOaYCKePCHKAhWiRv+mPZMAC3Dw E6WHT+hDDAs/gc7uE3DZYHKPY07Ghu4ZS2Fa6HfywcMwaO3nxRhrlps2QeYx34a/YnhGco johHLjC0BvufDcn8t96iI/I+6o+ytxMtL+ADjYKyR3Uu5KYr1zz6tvmZTlnhOEw1x5vsXK S/z3aEo5T+4fy50eDEs+kIF41UoZJIWzA7wuYDyoY6ijP5CmZD1s8IhhlujYwp2HDTbziw mEXcyDXDlCcv80zWAEbMLC4wNRmUiXjIdbYETY7qdiifyq2YpmKhj4EONFT7kA== 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 4TSlCn1j7dzGg0; Sun, 4 Feb 2024 22:53:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 414Mr97b084956; Sun, 4 Feb 2024 22:53:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 414Mr9bt084953; Sun, 4 Feb 2024 22:53:09 GMT (envelope-from git) Date: Sun, 4 Feb 2024 22:53:09 GMT Message-Id: <202402042253.414Mr9bt084953@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: dfabf3efaa79 - main - libjail: Guard against programmer error in jailparam_export() 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dfabf3efaa795e657f3858b7e2d0b11f8a51ecb5 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=dfabf3efaa795e657f3858b7e2d0b11f8a51ecb5 commit dfabf3efaa795e657f3858b7e2d0b11f8a51ecb5 Author: Mark Johnston AuthorDate: 2024-02-04 02:22:09 +0000 Commit: Mark Johnston CommitDate: 2024-02-04 22:52:30 +0000 libjail: Guard against programmer error in jailparam_export() If the caller didn't use jailparam_import() to fetch the parameter value, an attempt to export it will trigger a segfault. Make it a bit easier to figure out what's happening in this situation. PR: 276809 Reviewed by: jamie MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43732 --- lib/libjail/jail.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/libjail/jail.c b/lib/libjail/jail.c index 864c6981db2b..8e5b420d677b 100644 --- a/lib/libjail/jail.c +++ b/lib/libjail/jail.c @@ -737,6 +737,12 @@ jailparam_export(struct jailparam *jp) int i, nval, ival; char valbuf[INET6_ADDRSTRLEN]; + if (jp->jp_value == NULL) { + snprintf(jail_errmsg, JAIL_ERRMSGLEN, + "parameter %s was not imported", jp->jp_name); + errno = EINVAL; + return (NULL); + } if ((jp->jp_ctltype & CTLTYPE) == CTLTYPE_STRING) { value = strdup(jp->jp_value); if (value == NULL)