From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8581F30E0F2 for ; Fri, 13 Feb 2026 08:20:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770970838; cv=none; b=amE/hYGYhzDSlE94UvD00ZNPxFmeUnaVPewZxZtIgUsIp2ZAFMzDCvBZzNbhxNqwIHWW4fvbOVZ1YYHOl3aXK2Kr+5k/+mK0Y/FqZmdNDsqdsGjlP+XEITOTiDR5TZM/1Q22SzQhhaHyWf2kRDWH6Ef9Vp1rUFhSHARIVhYsqlk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770970838; c=relaxed/simple; bh=6VyxhO7wz5zqmdtbBObyeJEMr+6VvbQ5EJFXiUdNjMg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=nCoqKCvMLxVQ00bUdRK0VzdP0iZ5mgFRUvBOLa61nl85JXQpr+JvtwW96aaQPVuGBAPLbphd3V2Yp1PFaV17f7WoNT1jGX1HRYp5QNqUMHcUwy1Qbg6DQj4cbM1Ovli0t4a4haGbWWdsw1KnTftIKUU75DV6+ThQbXhh/lqYB6E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=u6eCvTgs; arc=none smtp.client-ip=209.85.218.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="u6eCvTgs" Received: by mail-ej1-f74.google.com with SMTP id a640c23a62f3a-b8d78d3fabfso48308166b.3 for ; Fri, 13 Feb 2026 00:20:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1770970836; x=1771575636; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=OP9HItSUyt7aKYpexkmYnvlxWsHOkfcAmcdFDm5om3c=; b=u6eCvTgsa5PPlj5mJVa62BSaOWja+uKln9VHNYOYjuYe/+WN+5JZW83C7b4oi+39CZ y05jEWC6WBFal8NSNsGAaGPbfOZU+U4xwV2BSWvhtZg9bFiJjaY9KyCZ/ZINPZroAM2K nkTS+eb0Nnaj2Md6N7gl6i4VRUeJ46rd0beqntkt8X1bxe5X+b8/JgNHFlMKWYjwPk0M Uj7XhVeW5LaHZiSxsKuqxgwUghzAj64kQwslUQUvf901C4+ZKuHC2uZlXt85+LUv2kVH AA5g69yviPvTd3JoHU95AVySVVkOM9c/1/H7sf/FUqJx+FhZ4lCtVD2gxd7fXp35gAok rbyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770970836; x=1771575636; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OP9HItSUyt7aKYpexkmYnvlxWsHOkfcAmcdFDm5om3c=; b=Qwdjmns2ymfoe0oOXGMXp5IMs7WA44ZBNz28cn0g5/nRoKxRjXzD581fWlBnbBOHbT 5bx/HW+CsNU7tKTpY6YScol4lFfh4RifV+0oIoxZt/Iu5nEq1wl/XD6jzWk5QTHj2blu d0VyP2BlBlLhzkoFjBLOJSgF6Tw178eS/PAPpoZ17dkvmB6kZYiiEvLoF8ByvQ+ynZND ir83YQVDConkfq67ekcQy0gG6lEKk/IEwuzyUHX26ueMSs7TPnkR6FqCaoBhIFQmrAIX R7mNT7KFv77WFWyqbiZUJGXQAZwAa7iLvYl82nxawl/1n3u/XqjWbfwcWOxYUi4kfZLO js5g== X-Forwarded-Encrypted: i=1; AJvYcCUWwr+BGwT/g6R/MIAB0c6UM6iMwoV7PNGjkARWXw82+GE5+ga4j51IrpxaG4aBsJ2DYSjU9fQnU5vHu30=@vger.kernel.org X-Gm-Message-State: AOJu0YxzRaNRLpbAT3ZTmHYcAekBzi4oVGSxgUeUMluVsBGRfao5vBjq kvbuPpvPsCXJMyiZWRevtjAbwpoI+LXY5gEvyuhNdoINrgGnujNEIBarRmIvO/4kvQ3DBX4Ffdo Y8sK9bJSUZeoFiuuRnw== X-Received: from ejbgc5.prod.google.com ([2002:a17:906:c8c5:b0:b8e:c3c5:de59]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a17:907:971a:b0:b8e:99f8:8c4d with SMTP id a640c23a62f3a-b8fb44fb32dmr45211966b.51.1770970835754; Fri, 13 Feb 2026 00:20:35 -0800 (PST) Date: Fri, 13 Feb 2026 08:20:34 +0000 In-Reply-To: <20260212-rust-uid-v1-1-deff4214c766@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260212-rust-uid-v1-1-deff4214c766@google.com> Message-ID: Subject: Re: [PATCH] rust: task: clarify comments on task UID accessors From: Alice Ryhl To: Jann Horn Cc: Miguel Ojeda , Boqun Feng , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Greg Kroah-Hartman , "Arve =?utf-8?B?SGrDuG5uZXbDpWc=?=" , Todd Kjos , Carlos Llamas , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Christian Brauner Content-Type: text/plain; charset="utf-8" On Thu, Feb 12, 2026 at 07:00:49PM +0100, Jann Horn wrote: > Linux has separate subjective and objective task credentials, see the > comment above `struct cred`. Clarify which accessor functions operate on > which set of credentials. > > Also document that Task::euid() is a very weird operation. You can see how > weird it is by grepping for task_euid() - binder is its only user. > Task::euid() obtains the objective effective UID - it looks at the > credentials of the task for purposes of acting on it as an object, but then > accesses the effective UID (which the credentials.7 man page describes as > "[...] used by the kernel to determine the permissions that the process > will have when accessing shared resources [...]"). > > For context: > Arguably, binder's use of task_euid() is a theoretical security problem, > which only has no impact on Android because Android has no setuid binaries > executable by apps. > commit 29bc22ac5e5b ("binder: use euid from cred instead of using task") > fixed that by removing that only user of task_euid(), but the fix got > reverted in commit c21a80ca0684 ("binder: fix test regression due to > sender_euid change") because some Android test started failing. > > Signed-off-by: Jann Horn > --- > rust/kernel/task.rs | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/rust/kernel/task.rs b/rust/kernel/task.rs > index 49fad6de0674..33e6d44b9a15 100644 > --- a/rust/kernel/task.rs > +++ b/rust/kernel/task.rs > @@ -223,14 +223,17 @@ pub fn pid(&self) -> Pid { > unsafe { *ptr::addr_of!((*self.as_ptr()).pid) } > } > > - /// Returns the UID of the given task. > + /// Returns the objective real UID of the given task. > #[inline] > pub fn uid(&self) -> Kuid { > // SAFETY: It's always safe to call `task_uid` on a valid task. > Kuid::from_raw(unsafe { bindings::task_uid(self.as_ptr()) }) > } > > - /// Returns the effective UID of the given task. > + /// Returns the objective effective UID of the given task. > + /// > + /// You should probably not be using this; the effective UID is normally > + /// only relevant in subjective credentials. > #[inline] > pub fn euid(&self) -> Kuid { Should this be renamed if it's a weird operation? Alice