From nobody Fri Nov 20 12:04:38 2026 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 4jWDXk5SBvz71XD8 for ; Fri, 20 Nov 2026 12:04:38 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jWDXk3THBz3QGF for ; Fri, 20 Nov 2026 12:04:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795176278; 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=lj3fWHmyxUTKVV2b0epVWPv/xlgN2PMOhWVs975izFo=; b=VkNDjGdZml/70DwAbOOkJ1A6r7n6hiP7ZKEpxdtH/mPE2gDNiFejQCBYoGZ26S3HQq6jxw 8ujG7z/Ci7t+kED9GmaaTVD1zVXWZ/knh8KAUxvyz6aNhFSuF/AAsZEFNjhsvbHZuVNtPo 1AtS/o3Xg3n1OxiEzqI57xgyzEA+StBvVdNSsnM+r6YSKehM52GoY69BTlTbpZ/WBlWR+e 6CbZYKF8v4Xa7GecWRYlJgA2Z0DJgywIjrgedSgB8K0fnr7NRKtRHPsZM1ZInuzH0nb6o/ GWYdTHhjNZczKkYzsDu0w/Eo9ZOWy2UnDFqhvBd3rkFBFLy9V5ASwY0AiBpo8w== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795176278; b=UWJSB7u3Lx9VuNzv7xkia2fDHsMunWCKanyIz7tZ5yLxQi3QZWq3I3kaPKxwSHYQUZ/JYG TrfcVGMy079iZLltTdDDPorFd6VrXeqejS43rAIQa3K1dabTvXB7uOHefgowwEt1Dz6X09 5VSE84TM+mZf+88ppQ0kVPoAAYLHP2FJw/yvJ3LiA5+cQwDZZrLDyrmV4S9EbxTsBUOxdI ahOBr0SRaUfRWH2tU6fXh7pntrU0yecqLbCN0mZAzxbE+W1wt84QMZCyWh8SNXPZeA9Jqy 9Q2jPv5aONpM4ugC4JD3iqIX1wzU0zcyacVq2anGKqL7y9I4g+DadJURzk/M5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795176278; 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=lj3fWHmyxUTKVV2b0epVWPv/xlgN2PMOhWVs975izFo=; b=dGnbLtds2VLTOVKAhsyDHdfcTqFMxAMSgahlKmyEx74Skf31rs67lBvgnJNtH7VR+UQsza h9XRRcH569GyxgXic8YxoIx63xkVe6mhDPXVW2IKJtPNFZ0TvUYHfA0o4bR4zRIqvaasdV IurED2GYKWgQIh9tfDNS6XAqj5CvCqgARzPoMcbPqHj1JUUaP4qElxrcKI8oX39OJw6iRj GEjzrQmSbm3TLtPMnKiF5FXivSzO04+18akMgCFsl99EddgL6H8t2pDMEIABfj8x6L364f 3k/VKQlq9WvRge/0IhcYbj7SJy2wpu2540tSLzxC3S4VsSE0+NSmnZpV12xA+w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jWDXk34FBznkG for ; Fri, 20 Nov 2026 12:04:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 50e0 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 20 Nov 2026 12:04:38 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: 628422c36c6f - stable/15 - geom: Check file flags before handling control request List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 628422c36c6f88bf36992fc117fbb8f79a50647a Auto-Submitted: auto-generated Date: Fri, 20 Nov 2026 12:04:38 +0000 Message-Id: <6b003756.50e0.6963729b@gitrepo.freebsd.org> The branch stable/15 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=628422c36c6f88bf36992fc117fbb8f79a50647a commit 628422c36c6f88bf36992fc117fbb8f79a50647a Author: Dag-Erling Smørgrav AuthorDate: 2026-11-14 16:24:45 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-11-20 12:03:56 +0000 geom: Check file flags before handling control request Pass fflag down to g_ctl_req() and: * Refuse all requests unless fflag has the FREAD bit set * Refuse all but getxml unless fflag also has the FWRITE bit set This should allow us to restore read access to /dev/geom.ctl for group operator; they will then be able to run `gpart list` or `gpart backup` but not commands that actually modify the table. For backward compatibility, we set the FWRITE bit if it is not already set and the calling thread has the PRIV_GEOM privilege, which is automatically granted to a jailed or unjailed superuser. This should cover the case of older binaries (which open /dev/geom.ctl read-only) running as root on a newer kernel. Since we intend to merge this to stable/15, the compatibility code is conditional on COMPAT_FREEBSD14. MFC after: 1 week Event: EuroBSDCon 2026 DevSummit Reviewed by: imp, markj Differential Revision: https://reviews.freebsd.org/D59591 (cherry picked from commit 408a1ec93facc8a02f4f7515fb4e036cce85fa39) --- sys/geom/geom_ctl.c | 46 ++++++++++++++++++++++++++++++++++++++-------- sys/sys/priv.h | 1 + 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/sys/geom/geom_ctl.c b/sys/geom/geom_ctl.c index 9e9c5e25d2d2..f2b44c5ef2f2 100644 --- a/sys/geom/geom_ctl.c +++ b/sys/geom/geom_ctl.c @@ -39,7 +39,9 @@ #include #include #include +#include #include +#include #include #include @@ -552,18 +554,29 @@ g_ctl_getxml(struct gctl_req *req, struct g_class *mp) g_free(gps); } +struct g_ctl_req_args { + struct gctl_req *req; + int fflag; +}; + static void g_ctl_req(void *arg, int flag __unused) { + struct g_ctl_req_args *args = arg; + struct gctl_req *req = args->req; struct g_class *mp; - struct gctl_req *req; char const *verb; + int fflag = args->fflag; g_topology_assert(); - req = arg; mp = gctl_get_class(req, "class"); if (mp == NULL) return; + if ((fflag & FREAD) == 0) { + req->nerror = EPERM; + gctl_error(req, "Read access required"); + return; + } verb = gctl_get_param(req, "verb", NULL); if (verb == NULL) { gctl_error(req, "Verb missing"); @@ -574,18 +587,23 @@ g_ctl_req(void *arg, int flag __unused) } else if (mp->ctlreq == NULL) { gctl_error(req, "Class takes no requests"); } else { + if ((fflag & FWRITE) == 0) { + req->nerror = EPERM; + gctl_error(req, "Write access required"); + return; + } mp->ctlreq(req, mp, verb); } g_topology_assert(); } static int -g_ctl_ioctl_ctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread *td) +g_ctl_ioctl_ctl(struct cdev *dev, u_long cmd, void *data, int fflag, struct thread *td) { - struct gctl_req *req; + struct g_ctl_req_args args = { .req = data, .fflag = fflag }; + struct gctl_req *req = data; int nerror; - req = (void *)data; req->nerror = 0; /* It is an error if we cannot return an error text */ if (req->lerror < 2) @@ -606,7 +624,7 @@ g_ctl_ioctl_ctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct th gctl_dump(req, "request"); if (!req->nerror) { - g_waitfor_event(g_ctl_req, req, M_WAITOK, NULL); + g_waitfor_event(g_ctl_req, &args, M_WAITOK, NULL); if (g_debugflags & G_F_CTLDUMP) gctl_dump(req, "result"); @@ -631,9 +649,21 @@ g_ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread { int error; - switch(cmd) { +#ifdef COMPAT_FREEBSD14 + /* + * Prior to FreeBSD 15, read-only access to geom.ctl granted + * unrestricted access to all GEOM verbs, and libgeom opened + * geom.ctl read-only. To avoid putting the user in a situation + * where their older binaries cannot configure GEOM on a newer + * kernel, we set the FWRITE bit if unset, but only for an + * already-privileged process (e.g. geli(8) during boot). + */ + if ((fflag & FWRITE) == 0 && priv_check(td, PRIV_GEOM) == 0) + fflag |= FWRITE; +#endif /* COMPAT_FREEBSD14 */ + switch (cmd) { case GEOM_CTL: - error = g_ctl_ioctl_ctl(dev, cmd, data, fflag, td); + error = g_ctl_ioctl_ctl(dev, cmd, (void *)data, fflag, td); break; default: error = ENOIOCTL; diff --git a/sys/sys/priv.h b/sys/sys/priv.h index 8df113adfd4c..f51b4199ca55 100644 --- a/sys/sys/priv.h +++ b/sys/sys/priv.h @@ -81,6 +81,7 @@ #define PRIV_SETTIMEOFDAY 18 /* Can call settimeofday. */ #define _PRIV_SETHOSTID 19 /* Removed. */ #define _PRIV_SETDOMAINNAME 20 /* Removed. */ +#define PRIV_GEOM 21 /* Can modify GEOM configuration. */ /* * Audit subsystem privileges.