From nobody Wed Jun 03 20:46:27 2026 X-Original-To: freebsd-hackers@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 4gW09K6txtz6ghGH; Wed, 03 Jun 2026 20:46:29 +0000 (UTC) (envelope-from markj@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 "smtp.freebsd.org", Issuer "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gW09K68cwz3LfN; Wed, 03 Jun 2026 20:46:29 +0000 (UTC) (envelope-from markj@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780519589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e79FPdAdkxB527hUV3YwOLXouB0hw2B7fWYpdiJJTds=; b=UOGV89KHGADshNJyAzX6S+D8y70r5xLaDQ9mmxyMamB2hJAokelnVC30xSXwcfkkrdJgWs eHPy2T385j7ECC7VLQ/WdZS+YXmTxxFL9WH6CayA3zJP/Q39Hem8VaIKj/pSYgLBr16295 wQeLvxPiUQ7BKpX7diRF4a+gFeGcXq3exECH5n7XiR8VEKoANvVECfFr01DIEaX2HkLmNu c5dhuGIEBh0duWNReuJCpJJSNIIlwgv8lvctUfniTMF/S1vq54bB1cN+Lg0o1xhKnYo17l snhlbr3c4jdrDOo59Mo3DLB/oizwVLEoXWvgf71XL+byDa3NLzaz/YBfXQnGug== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1780519589; a=rsa-sha256; cv=none; b=d49e1EnCI/HtQxSAhVecvPFfAmXf4BZ0B4ezmv8wptEUA0TgHcgbbdTpZ1RZhI08bltM6H ufOofDX+WP0Uc0XcOch22qdMLhw2b73iWan0vihZN1sfw9M3WoSkiW8minywFSKeldTrak iJbGxd04+F5LAejIQIf5crR+92wZmruapRxW7xqvD3nu+LYI8oticxfTEvxR7V+dFPLD30 iDuipkJ650mn0SXlAJKC6SG4kEuPpXgbNNpW4XOnKIGePpuEsB73S83Y4i1L50oz+sl5Lk QtQlbtK3+4xM/vOJpdv4Fi0gI4YHQKrdooD5vU80U8UOGOCijflKoLRB0PsLPw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780519589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e79FPdAdkxB527hUV3YwOLXouB0hw2B7fWYpdiJJTds=; b=Lnao4w79PbPiGw31+GFnojuy0LXDD3sResLz7BjWQp2b1pUtBroUfwGGRXNfl0OQPVSX0K kH00uaWXE9c8pE2LDpeD4F52q9a0ZN6NjbiGrTVibZuwTy3ZSiFnJizTi6x94voIOy7m7u gz75pkVhZCRikFTObhaM3WhbB2LIfcXst0+4UAc/sNGarMX8VN9wZ6oe8PCN5l4AZ1AK/7 yic7InVlTmEhYi5K74DfkqAaR4hMIaJm6/VZEfE92q4w1SOYw4p9JnKLlf/cCqA5uoidJr jtFfqVfFTKXYGQNML9eATvhJt1+XtnmDPA1dDJC7WIQUsSkGFe8SJTz+ZY8ySA== Received: from nuc (192-0-220-237.cpe.teksavvy.com [192.0.220.237]) (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) (Authenticated sender: markj) by smtp.freebsd.org (Postfix) with ESMTPSA id 4gW09K2TB0zQht; Wed, 03 Jun 2026 20:46:29 +0000 (UTC) (envelope-from markj@freebsd.org) Date: Wed, 3 Jun 2026 16:46:27 -0400 From: Mark Johnston To: Kyle Evans Cc: Mariusz Zaborski , "freebsd-hackers@FreeBSD.org" , freebsd-arch@freebsd.org, pjd@freebsd.org Subject: Re: rights(4) split? CAP_WRITE -> CAP_WRITE_DATA + CAP_WRITE_CTRL Message-ID: References: <7f5f2137-bd4d-4e27-8049-cf585849103e@FreeBSD.org> <4feb230b-635e-4eca-8d9e-f89df2ad1377@FreeBSD.org> List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4feb230b-635e-4eca-8d9e-f89df2ad1377@FreeBSD.org> On Wed, Jun 03, 2026 at 09:15:11AM -0500, Kyle Evans wrote: > On 6/3/26 03:04, Mariusz Zaborski wrote: > > Hello, > > > > I think the idea of splitting CAP_WRITE into CAP_WRITE_DATA and CAP_WRITE_CTRL makes sense, especially for cases where a process should be able to exchange data but not transfer file descriptors. > > > > From my perspective, the biggest concern is the capability change itself. While source compatibility can largely be preserved by making CAP_WRITE an alias for CAP_WRITE_DATA | CAP_WRITE_CTRL, there is still some potential for compatibility issues with existing applications and binaries that rely on the current semantics of CAP_WRITE. > > > > My alternative proposal would be that we slice off two entirely new bits in index 1 and still make `CAP_WRITE` an alias, but rename the current assignment to `CAP_WRITE_COMPAT`. We don't have any precedent for it, but I'd then handle translation at the cap_rights_*(2) border and unset the new `CAP_WRITE` if `CAP_WRITE_COMPAT` is unset when limiting, and unset `CAP_WRITE_LEGACY` if *either* of the new `CAP_WRITE_*` rights are missing. Just a couple of comments: - Why CAP_WRITE_* instead of CAP_SEND_*? CAP_WRITE and CAP_SEND are aliased today, but now that you're introducing rights specific to sockets, CAP_SEND_* seems clearer. - Rather than allocating new bits, maybe we should consider repurposing some indices which are only used with other file types? For instance, CAP_PDKILL can only ever apply to procdescs, CAP_INOTIFY_* only apply to inotify descriptors, etc.. There are still a fair number of bits left, but it wouldn't be too hard to run out of them. Is there some reason we can't define aliased rights? > I don't know how I feel about it, but I bet it would work. > > > Other than that, the use case seems reasonable, and being able to explicitly prohibit SCM_RIGHTS on a socketpair could be a useful hardening measure > > > > Thanks, > > Mariusz > > > > > > On Tue, 2 Jun 2026 at 20:19, Kyle Evans > wrote: > > > > Hi, > > > > I'm looking at an application where it would be useful to be able to construct a socketpair(2) that can't be used to send fds over, out of an abundance of caution.  The application in prison0 is effectively a broker between two jails that it hands each an end of the socketpair, then steps out of the way -- I don't see a reason to leave it capable of carrying SCM_RIGHTS. > > > > I'd like to propose splitting CAP_WRITE into CAP_WRITE_DATA and CAP_WRITE_CTRL, with CAP_WRITE being an alias for DATA|CTRL.  The caveat is that I don't know if being able to revoke data but not control messages is really feasible or useful, off-hand. > > > > In any event, my plan would be to use the last bit available in rights idx 0 for the CTRL right, rename the current CAP_WRITE to CAP_WRITE_DATA, and create a new CAP_WRITE name for the two combined.   There's some chance for breakage in applications that haven't been rebuilt with the new definition of CAP_WRITE, but I suspect most of them aren't attempting to send control messages.  The in-kernel users of CAP_WRITE look like they could mostly be scoped down to CAP_WRITE_DATA specifically, though maybe that gets a little awkward in `flags_to_rights` mapping of O_WRONLY/O_RDWR. > > > > Thoughts? Terrible idea? > > > > Thanks, > > > > Kyle Evans > > > >