From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=178.63.66.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796225147; b=vRx30wKle/NYgEADwhWxrYN194z/OjOYWEqTtf7CR1jWbRCZKPxphMy2Fy83UJfY7o5/ wnuDUEmuWQnLlUJP/QrNQIShtMtOvan7VjyXNx2Cav7xhalQ0thcegqvsril7h91y7v94 1yfwAGu1ROoyIid7i+DXEPOa/hAZrVWhfjPlkXJz3Kgep/3cnsxYhQCLA1XzubjGpg59X oHATfajm6Gf6wt4Los2QCnVbdw0jvqTPKIubi74CqHew30NnNrcrfkpq3TXehjFwTaLNc EmefXxEcz/mWJETwlkiPN2kyegbZm0wfDsqrde+K5Cbw+OdkPlH9+HXDYds1dmnSunA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796225147; h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=PYHPdotXEsaowoVt+omlHvj2tN3B+6TF/1nc1tJwkVc=; b=4yU6iLb8MUCof+p+vrAKj0Lagdj6PVqHqzkEu5ppVZi6RsOloH7DZ3lh/tKzy5a1czHy YyGm9MVWxE0UY9Xd/qu9aW8HdpWA+Yx4AI4QbgGFDdMBI/x4UvvhLxC0YvlypekGQAgcn pHIGLxAdQPV5dujhUwhCXFFQaj7yke4cPozswPbphJ/IuEp1FxVoNUsSdUmx8WWdvJW1K 05fC9fGEnk1b/9WMPXsVNYwLkSxjGKrlWq1BELMlBVeOpu2e/dHUplHivXpMBGKQfn0ml Nj58PFpvH27FF70sMrnWg8dilRUekv40x1nZKGD2gBLHQRdDk23CVaQ8sid7vBbXxMQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=hallyn.com; spf=pass smtp.mailfrom=hallyn.com; dkim=pass header.d=hallyn.com header.i=@hallyn.com header.a=rsa-sha256 header.s=mail header.b=GDS2CnmB; arc=none smtp.remote-ip=178.63.66.53 Received: from mail.hallyn.com (mail.hallyn.com [178.63.66.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF355606A322 for ; Wed, 2 Dec 2026 15:25:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DF355606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=hallyn.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hallyn.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=hallyn.com header.i=@hallyn.com header.a=rsa-sha256 header.s=mail header.b=GDS2CnmB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hallyn.com; s=mail; t=1796225137; bh=R5ZDSsWk595bh6GDM01Ik92Rd50SyMBsgwlGNQbbBso=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GDS2CnmBmmaT554BHOLxtJ2V/RmFWhUAnwzI+GQ2F/GuqpgM2U7iAk29VFO3lsILL dYyYRsbEJPdfLGhMIlb3xwwzUuM2WYwCifW427D2exHLffPOOBh89xxPDREMO8L3KJ 3HeaXwL+Th72k6YWQjQf8gdE7SwCOhMzun8RGIUSfOjx6c+5I004M/8dDhKAnLb5oN QwlR8EvdH2q6stS7KbNFEzuFdu66EqVJNxa0InIc2JIwLenP5G12aWGYqHvlvXFpSU dPRV4tx8D4kErLee3/U2Zg8tMSa7OPojvcyeKROdoBBGR5N8bRqiNqnbFEC5gN5lP0 rUHVMyOCCv5rw== Received: by mail.hallyn.com (Postfix, from userid 1001) id 1A663195A; Wed, 2 Dec 2026 09:25:37 -0600 (CST) Date: Wed, 2 Dec 2026 09:25:37 -0600 From: "Serge E. Hallyn" To: gregkh@linuxfoundation.org Cc: mic@digikod.net, brauner@kernel.org, gnoack@google.com, jmorris@namei.org, john.johansen@canonical.com, kpsingh@kernel.org, matt@bobrowski.net, paul@paul-moore.com, sergeh@kernel.org, stephen.smalley.work@gmail.com, stable@vger.kernel.org Subject: Re: FAILED: patch "[PATCH] capabilities: Check PR_SET_SECUREBITS with ns_capable()" failed to apply to 6.6-stable tree Message-ID: References: <2026120222-aspirin-anyplace-2c7d@gregkh> X-Mailing-List: stable@vger.kernel.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: <2026120222-aspirin-anyplace-2c7d@gregkh> On Wed, Dec 02, 2026 at 01:59:22PM +0100, gregkh@linuxfoundation.org wrote: > > The patch below does not apply to the 6.6-stable tree. > If someone wants it applied there, or to any other stable or longterm > tree, then please email the backport, including the original git commit > id to . Hm, yeah, Mickaël, is this really needed for stable? > To reproduce the conflict and resubmit, you may use the following commands: > > git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y > git checkout FETCH_HEAD > git cherry-pick -x 2ff5a29db0f542226d5bd029459de9703fc2a2ae > # > git commit -s > git send-email --to '' --in-reply-to '2026120222-aspirin-anyplace-2c7d@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..' > > Possible dependencies: > > > > thanks, > > greg k-h > > ------------------ original commit in Linus's tree ------------------ > > >From 2ff5a29db0f542226d5bd029459de9703fc2a2ae Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= > Date: Wed, 18 Nov 2026 15:54:28 +0100 > Subject: [PATCH] capabilities: Check PR_SET_SECUREBITS with ns_capable() > MIME-Version: 1.0 > Content-Type: text/plain; charset=UTF-8 > Content-Transfer-Encoding: 8bit > > PR_SET_SECUREBITS checks CAP_SETPCAP with cap_capable(), which skips the > LSM capable hooks, so a task can change privileged securebits despite an > LSM denial. > > Use ns_capable() instead, as PR_CAPBSET_DROP already does. Move the > check to a helper that only requires CAP_SETPCAP when needed, so that > changes limited to the unprivileged securebits still do not reach the > LSMs or set PF_SUPERPRIV. > > Cc: Christian Brauner > Cc: Günther Noack > Cc: James Morris > Cc: John Johansen > Cc: KP Singh > Cc: Matt Bobrowski > Cc: Paul Moore > Cc: Serge Hallyn > Cc: Stephen Smalley > Cc: stable@vger.kernel.org > Reviewed-by: Serge Hallyn (AMD) > Fixes: 3898b1b4ebff ("capabilities: implement per-process securebits") > Link: https://patch.msgid.link/20261118145431.2551578-2-mic@digikod.net > Signed-off-by: Mickaël Salaün > > diff --git a/security/commoncap.c b/security/commoncap.c > index d47ab3022343..9794a594bdd9 100644 > --- a/security/commoncap.c > +++ b/security/commoncap.c > @@ -1283,6 +1283,26 @@ static int cap_prctl_drop(unsigned long cap) > return commit_creds(new); > } > > +/* > + * Doing anything with securebits requires privilege (go read about the > + * "sendmail capabilities bug"), except for unprivileged bits. Indeed, the > + * SECURE_ALL_UNPRIVILEGED bits are not restrictions enforced by the kernel but > + * by user space on itself. Only checking CAP_SETPCAP when it is needed keeps > + * LSMs from seeing (and logging) a capability check for unprivileged changes. > + */ > +static bool securebits_need_setpcap(unsigned long old, unsigned long new) > +{ > + const unsigned long unpriv_and_locks = SECURE_ALL_UNPRIVILEGED | > + SECURE_ALL_UNPRIVILEGED << 1; > + const unsigned long changed = old ^ new; > + > + /* For legacy reasons, a non-change requires privilege. */ > + if (!changed) > + return true; > + > + return changed & ~unpriv_and_locks; > +} > + > /** > * cap_task_prctl - Implement process control functions for this security module > * @option: The process control function requested > @@ -1346,28 +1366,9 @@ int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3, > /* cannot change a locked bit */ > return -EPERM; > > - /* > - * Doing anything requires privilege (go read about the > - * "sendmail capabilities bug"), except for unprivileged bits. > - * Indeed, the SECURE_ALL_UNPRIVILEGED bits are not > - * restrictions enforced by the kernel but by user space on > - * itself. > - */ > - if (cap_capable(current_cred(), current_cred()->user_ns, > - CAP_SETPCAP, CAP_OPT_NONE) != 0) { > - const unsigned long unpriv_and_locks = > - SECURE_ALL_UNPRIVILEGED | > - SECURE_ALL_UNPRIVILEGED << 1; > - const unsigned long changed = old->securebits ^ arg2; > - > - /* For legacy reason, denies non-change. */ > - if (!changed) > - return -EPERM; > - > - /* Denies privileged changes. */ > - if (changed & ~unpriv_and_locks) > - return -EPERM; > - } > + if (securebits_need_setpcap(old->securebits, arg2) && > + !ns_capable(current_user_ns(), CAP_SETPCAP)) > + return -EPERM; > > new = prepare_creds(); > if (!new)