From nobody Wed Jun 03 23:48:52 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 4gW4Cn3Zykz6h12S; Wed, 03 Jun 2026 23:48:53 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 4gW4Cn2x2hz3hQk; Wed, 03 Jun 2026 23:48:53 +0000 (UTC) (envelope-from kevans@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1780530533; 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=8XhNyfXVwskoUcXkHQT3txRljKv5XM7AgcWS0ZqYI14=; b=IltjeEHKFeDHt6kx6VABTpcYGEciyHT5FFJ9lzUk44NWbAkmNz4dGlNnFT5lMPLthIIZYB DIOBpkDPTZr1ZrMSpg6Wpz04ET78LNO5rfgdBi5tJ2ZbRFEiTb/mkwUGIoS+oTm9yAa96c RBP8MSvdpAUtVoNQVwyEbmg7p2AlI27lrzxZxVa/TeiURZ15cykv+1+Y6sC64T8fcoolyn Oz9f3k93PmR2dqG8tyixcAyiYwy00OIaJzafQNWI22gYsNcWBVaTpUHVEkdERZ+eSREPaA c25GAnwn1i6FiTGjsLz/yYZyf5PgHwTpx6iys1imyFXlMsPpkTmOOigFWTxYvA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1780530533; a=rsa-sha256; cv=none; b=AWa3nbSfhyfU2j7KDkmgMuEXqrB/cJnH+tEwz1Mxav+hbtgF5FZwI+wD4UTzBl9YiOTiOV sQTALc77KkkZphKNyr6ajtSSMA2rO58VIqlozz48CNH7s673uxmAxPxMmFb1fsTHhFEVIt LgznpJOH7BXgrcY5eapwOL6Q7UPf0MLA40noSRrcHrySPisnt72PaKY7wsLT1MV1xMp2O0 P7O+Y3bpppDD6vyAPNL344WAcn9Z4yHS33QZDInU/t+IdrJA0mYAjZMJYMe7WJNQBoexfA HNLvhdv6JOFHMACTxyVPFgT+NO/arHIiKx1vVmUBKsU0c0RdcCyeCSx+phfxEg== 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=1780530533; 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=8XhNyfXVwskoUcXkHQT3txRljKv5XM7AgcWS0ZqYI14=; b=YGVuscwcb1q+q9reYJzNvXGdKMOi2KGHiHNlp77xlIvOoVdj350KvfvHhnUWj4FFnqgGaA ZtSufMNPdXPsuSYnqtAjGa/CYG37W+84eTRGuyfQaiQWSTW0mdS9iZQlm4+R0LOEI5SKwZ mx6sJrnVFzVwg3ULJmyUGcOWpOEIV5ZPGx4yl4vvgDJe24eA45BQUjIKVtqiz4xDx2kyAG fLlzz2Zzy0+Bwnw9QEI204pdelzxBybeZ2+lCzkaxybuef/zeXXIXrkIObBRver/6PL+v5 plLo3Ep3aVIMDltXICtOaW3PNSRTs846t+pEoSnlsuzIKsimFdFo3TEKQDiTvw== Received: from [10.9.4.95] (unknown [209.182.120.176]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: kevans/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4gW4Cn0FBwzlyP; Wed, 03 Jun 2026 23:48:52 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Message-ID: <4893fb93-ab82-49d0-a08b-27fcad86df5b@FreeBSD.org> Date: Wed, 3 Jun 2026 18:48:52 -0500 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 User-Agent: Mozilla Thunderbird Subject: Re: rights(4) split? CAP_WRITE -> CAP_WRITE_DATA + CAP_WRITE_CTRL To: Konstantin Belousov Cc: "freebsd-hackers@FreeBSD.org" , freebsd-arch@freebsd.org References: <7f5f2137-bd4d-4e27-8049-cf585849103e@FreeBSD.org> <4feb230b-635e-4eca-8d9e-f89df2ad1377@FreeBSD.org> Content-Language: en-US From: Kyle Evans In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 6/3/26 15:45, Konstantin Belousov wrote: > On Wed, Jun 03, 2026 at 09:32:17AM -0500, Kyle Evans wrote: >> Sure, no objection- that was my first inclination, but I renamed it to COMPAT at the last minute to match the COMPAT_FREEBSD* nomenclature. If there aren't any complaints about the notion within the next week or so, I'll go ahead and hack something up. >> >> On 6/3/26 09:17, Mariusz Zaborski wrote: >>> Actually I would feel safer with CAP_WRITE_LEGACY. >>> >>> On Wed, 3 Jun 2026 at 16:15, 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. >>> >>> 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? > > We do not have much bits left in the caps. I would need a new bit for the > D57163 review. Using two more bits leave us without any free bit, as far > as I see. > I'm not a fan of how it's expressed, but index 1 seems to have a lot of unused bits still: /* Available bits for index 1. */ #define CAP_UNUSED1_22 CAPRIGHT(1, 0x0000000000800000ULL) /* ... */ #define CAP_UNUSED1_57 CAPRIGHT(1, 0x0100000000000000ULL) I probably would've spelled it as the full mask: #define CAP_UNUSED1 CAPRIGHT(1, 0x01ffffffff800000ULL) Mark circulated the notion of aliasing some bit for rights that are applied to specific file type, like CAP_PDWAIT/CAP_PDKILL and CAP_INOTIFY_* as examples. I don't really see a reason we couldn't, particularly for these types that aren't at risk of growing write(2) semantics. > There is some versioning mechanism for the cap vector, might be it could > be used.