From nobody Mon Sep 28 22:41:20 2026 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (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 4FBDD38C42F for ; Sun, 16 Aug 2026 08:06:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.128.180 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786867568; cv=pass; b=FIJZvj8Ca71U97YteN31mRbI/hKWGfjeSbUz9ga6+kmNNo4Z5IsGo/SdyXy4CJQZHw/YkZxgB12v9J4l2kqQZSjARv8ARZfp4Mljgh2x1cvn5uHg52yHxlllQYjeUzhHYPCKbCD4ku0E7eyToKZLwJPGIwNKvxF9Hdk/1Q/b4Gc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786867568; c=relaxed/simple; bh=spN01miLZ+1EuMHCCi2TsGrFMZYCSvwaVtnaL2vV8/M=; h=MIME-Version:From:Date:Message-ID:Subject:To:Cc:Content-Type; b=dNMQtSoq3+KESEfPIGtX60wV+Q+iV/9IbryL8OCrfvj9S5AOYV7NTKUKUKf6VtNR7gBBifB8FYPpgqMK4+BQKlCijhL1VLeIPkVdQ1sm9GXrNqt7QM4PcjSl3lU2R3+E3EAVYYbd00EDQJQQWQoqNdQIRBZFv49HEz+ZSWfWOFc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jC0E5CPy; arc=pass smtp.client-ip=209.85.128.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jC0E5CPy" Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-80cebd41372so36041947b3.3 for ; Sun, 16 Aug 2026 01:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1786867566; cv=none; d=google.com; s=arc-20260327; b=DpZ2a6bBZqDtBk7ABiKnI9TAGwOUzc9alGD27hVESfQ6SoWssfm5OsRyzeKDWRvwSV XSdOXs2c82n+zQ84OU9vhI97JTnKcuIrMlgSmN/qCJinekruZ9yEWjjrqtTR5ws6uhH9 BIfNtOepvCtJtJAhxgh6kHLNUGalgDZLkIkFu2he1csMMSAjPD7G3C7dwu3E+oWdrpdp 0Ar7tFYPK778tUhQcNSoJ9Z48V40QhQa558BxPoHn+GNKfOmu6DI3AzCDoZs2DYu1aed gI4uERAmCqZ07aV4JqdFphWJTO1uDaNXET+BYPtlYc1iDRDcn6malTQjvBajL0wwvCOy gDCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:subject:message-id:date:from:mime-version:dkim-signature; bh=kqZ0XBSF1HGWqR58xlsXfstkBupWwokqDVn/yufUMU8=; fh=5LLoUc2bU/7mE0wB/3Wu60M0KUI8+11rbTzEFFBUEvU=; b=W4oXbV/RXXKxH2TGL/xw3qfUi+CwLJCPcnETKXirAtIwlUVHANRhK847h30OHs+IV7 ryLwbZbsug4lNUtf7Hg9tG0kVRPmm8ebjh21vE5kYxZdSnZ02GR5RqyWfCXJfiEGcQj2 WmsJNWuNBTxZuh+fjZVXqxcPClim5vBld+5Viws6PKUJtCqg7Jbuhb0DgVv9btmsebPg GuIuMVnmhskHnQzlZ+UyHZX55sVkRbNN0URUXmypDnw0wQhweYBVxbAHwsPCOd505LvV uCvS/g56vKK5zrlgXPqSxQCPrB/q2Z48jbK2vc33SscZOhOQTG9iG04QrGoaUmdaqzxE 7fow==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786867566; x=1787472366; darn=vger.kernel.org; h=content-type:cc:to:subject:message-id:date:from:mime-version:from :to:cc:subject:date:message-id:reply-to:content-type; bh=kqZ0XBSF1HGWqR58xlsXfstkBupWwokqDVn/yufUMU8=; b=jC0E5CPyxPXy7XzTVkJhm6hA/2eyeOqK7ymVWwGMsfvdVmJ0X0kWTQBqz0I4QwGwdG 9W15W8W1P1/ZklYSFcxi9RNSud23/M3A3kKggKTg1MZi/rfEvMzu0yyo9uhRQ2Vcv1jJ dgbriw9AE95+DrYASbQz6tSn3aWR1hJQOpvjW80y+C6BjcFAd1MZ6ZR9W4BVBPIyrUvO n4cM5+qgo6pedSEspLofUS0tWVvykPjttFptwMMngYvRSEMb3zXO+Cv9sb0LUZfBgjSl Gwui6Pp3jAsl/z3usvAZrfHL01xHvnRLkw6PMuCqmc97VmVWRAhJOEj40CnY5cYGvjUz mRHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786867566; x=1787472366; h=content-type:cc:to:subject:message-id:date:from:mime-version :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=kqZ0XBSF1HGWqR58xlsXfstkBupWwokqDVn/yufUMU8=; b=UFnrTEex/i3qctsB1Ho+bryS7ULe5aYayV6h9K3Oyif7JmM13iFpydu0sR6OF6zFTU xS017YEtVlH1HuY7vyIkHGvFhqx13wMpGKEB58oOqg/rMs6zdswmH8akd++wxc7b6Iaj BoW5vthxIt1P3oX/UIh5SKo6sfT7CF2hz1CjWKytz9PTmeG9wMvC4l+eWJULy59/HGiW RKh2z8zXVtTlO5TUbzZmN/4I16J5aJ0TSJaB008p3LxtAApt3MTgSvGGMilotrMjf2/K bsuYLDdU2pKRe4wU9qM5SCkASV+0ehelt71o8+LOwXZ8k9l42PaIwQbkV0c5w/PEVPY7 2gCg== X-Forwarded-Encrypted: i=1; AHgh+RrJl9WmtFeadPeB6feECyYNdty937JIIGtdpQHKsYhNcvoHJhwG+sIVcMwyzNzb2CPtG6stIxNnJeTPmAo=@vger.kernel.org X-Gm-Message-State: AOJu0YysP4MTXTezMGZmVr+gbheTFXiMvZ/LDjngdqDy5ahn9l/f6eHp 3umhABEwDx6ckHcysceSGw8BpgKFCHNj4nKydmgyLlOPlNgR2vfCYpAhGf+YE58aZMXMUB6wdO2 qxTPISYgAk/1KD2hYQjVfZoOzIAFv2gg= X-Gm-Gg: AR+sD12c5OXa2lYysvt6NvGVRafb7360fCzO/Bz5wyeYmyU4Cw9XQnnBlRZRlnXacmD q4hYOvupgZNYa0I8Lz77F1w56bY/f+tJ6aPbP3p5Qup+aFD8zX/OhXF/aEelt2zTxVRO+rVeLDE RcH77+JSqKZALWEOjpmzM0SLmR+GevAJsZNwW6yM8An0QsuIMyEqhC1LLgon+qSkijHAmNADMro h/No+pAZjZL9QrYHAub2DqnOfmWY5wql3kLNksNj7nKz3jX5UNv/ND0eYsJ0y7b62nCibg9FX2F nSLgBStSSO2WGqy61RHV33mdLI399ynV8a/Zxzt2vio= X-Received: by 2002:a05:690c:d20:b0:81e:799f:d55e with SMTP id 00721157ae682-83710b8b446mr63979557b3.19.1786867566325; Sun, 16 Aug 2026 01:06:06 -0700 (PDT) Received: from 77377267392 named unknown by gmailapi.google.com with HTTPREST; Sun, 16 Aug 2026 01:06:04 -0700 Received: from 77377267392 named unknown by gmailapi.google.com with HTTPREST; Sun, 16 Aug 2026 01:06:04 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Alexander Smoliyaninov Date: Sun, 16 Aug 2026 01:06:04 -0700 X-Gm-Features: AcwNN1XVHQN0yNPizzu4Mk1FiSzGE4Vrd152VeFm6B736_YPIllOd0hEDxUqbjI Message-ID: Subject: [PATCH] rust: list: add SAFETY comment for container_of in ListItem::view_value To: ojeda@kernel.org Cc: boqun@kernel.org, gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org, a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu, dakr@kernel.org, daniel.almeida@collabora.com, tamird@kernel.org, acourbot@nvidia.com, work@onurozkan.dev, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From 500f0ac27706fe5d41d82659525bc52b7a46d33c Mon Sep 17 00:00:00 2001 From: Alex Smolya Date: Sun, 16 Aug 2026 09:57:20 +0200 Subject: [PATCH] rust: list: add SAFETY comment for container_of in ListItem::view_value Document the safety rationale for `container_of!` in `ListItem::view_value` when using `ListLinksSelfPtr`. In the `ListLinksSelfPtr` implementation of `ListItem`, the caller guarantees that `links_field` originates from `prepare_to_insert` or `view_links`. Both methods return a pointer to the `inner` field of `ListLinksSelfPtr` within `Self`. Therefore, calculating the containing pointer via `container_of!` is sound and in-bounds of the allocation. Suggested-by: Miguel Ojeda Link: https://github.com/Rust-for-Linux/linux/issues/351 Signed-off-by: Alex Smolya --- rust/kernel/list/impl_list_item_mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rust/kernel/list/impl_list_item_mod.rs b/rust/kernel/list/impl_list_item_mod.rs index c2a1f77fb..423afbf84 100644 --- a/rust/kernel/list/impl_list_item_mod.rs +++ b/rust/kernel/list/impl_list_item_mod.rs @@ -329,7 +329,9 @@ unsafe fn view_links(me: *const Self) -> *mut $crate::list::ListLinks<$num> { // `ListArc` containing `Self` until the next call to `post_remove`. The value cannot // be destroyed while a `ListArc` reference exists. unsafe fn view_value(links_field: *mut $crate::list::ListLinks<$num>) -> *const Self { - // SAFETY: TODO. + // SAFETY: The caller promises that `links_field` originates from + // `prepare_to_insert` or `view_links`, which both return a pointer to the + // `inner` field of a `ListLinksSelfPtr` inside `Self`. let container =3D unsafe { $crate::container_of!( links_field, $crate::list::ListLinksSelfPtr, inner --=20 2.55.0