From nobody Mon Sep 28 22:39:17 2026 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) (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 63EDE38C42F for ; Sun, 16 Aug 2026 08:05:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.128.175 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786867559; cv=pass; b=Sdc8FL0IYqDl8mOh/wrQD5PU+oxepRvL2ZrjgN6rjFCta6pJM/TDJXv+A5CiX99Ng+Tyu04lk69ua662LTLQAghTFahnn6WA1VbkJ71FfGHOCwlJ+sMJJEXEsYw987+mlEnSOqkb22LL9yzN/UjFI6GQ8tUt+FdqECVRpEWnE8s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786867559; c=relaxed/simple; bh=4H71DKFKue4ha02mwRVH3W1cR/3p6l//psqx577EuQQ=; h=MIME-Version:From:Date:Message-ID:Subject:To:Cc:Content-Type; b=WnLY5bL7cQLW6ZO4xhIs+RUoWeYBgJAzN9983mho2yxwoSAcAEVDfRZlwPe8INZy9PgpN/O65ZCkZ7UuyhfxasgmczkATUnGvFuL5X6LDKDkFaGm4USMFFVxxMcahjqSGje8NlWiA6mX5qqvmsCnRkh9BychMRaN9MoCf/5Okq8= 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=fP5T+lLV; arc=pass smtp.client-ip=209.85.128.175 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="fP5T+lLV" Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-81ed2a06b9eso19558257b3.3 for ; Sun, 16 Aug 2026 01:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1786867557; cv=none; d=google.com; s=arc-20260327; b=QFLmCCuovPprJCHT8Q3h5WLSWlMhmd3rl6EwygzN7P7Uf6WJ9o7XUNcXrowwUSh87e eNu0jt/rAIGiHSYiWfebjPyxSpMC/3J1mdG0fcU4lmtDAq/RLP8K45B4mShQOhpKicN0 o+IpzEo+8RPo8LynOXBmoAYwFK6p1lsHwM6tPThtbPPxwFw5SnY7YQDvgSOzjaFsHGeG SRRsEnZ3CEPMmBwLNID1SR9QE0pZagJXilD+5IYsklxe9ZnuWu48p03IWWQgRXQNccox x265h2wO9pc5yU7I4pSxCEQFpLVoVaLFVF6M2pZr7owa4Fywp0LzM9ky/mZtmdS/JrBy K/ZA== 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=StlUsK9zw1G2L8oITvi9ZhkJQGYcuGs/YnOzS0AQwls=; fh=uemMZHX7075tIBwl70Mun8VUn9GndZ/moHWRvIHfpH0=; b=hm+2H5LqXpl2yYXa8h8/45ubieCot30IvOTINlmfNSnHpWU8aPm2QWL3f78B3wyTFG WjIkJUUvPXN9DXbOtT1YxF7y+PksNI4Dxc8q3Lqv7bVmMw6ytnfcUApToDZGRFVpULMd uXuuUUl4QPzQBk7/TFVfVjcwiJfNf1yxotcGAmQ7eJRAVslN9FWFYsJ+SXFdf48tyMJS 8ahqMbakOu1A6lDFnXU+gnuQM++wpeVJFe0q8clcFYSt/0jfyiY0FvKxroQehssWgOB8 HcIOQpdXjJMp0FVPoOEswl0B+pzUP2saAN4ZgsZJ5LLrzSr+DlTy5XQJFuG6qMLJzrcI Px5A==; 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=1786867557; x=1787472357; 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=StlUsK9zw1G2L8oITvi9ZhkJQGYcuGs/YnOzS0AQwls=; b=fP5T+lLVPigt1oYnwP6LTXfgucVU9aXXOVRC3EFuEiu5xSldJrqzItaTjjMUbtkrWL ZhWLn/54IFZg/yZjIQWN65OsBSGKYf3hv6riqo939IxzNdxr0d9NNTev6aWsvVe9u3HA 3v6qIDeyEJmJe61YLha5H89vxSJQM4oWzsV5V1ZVvwfE3sN84CGiXNsr3n3XKvTqa1tK MsmMyll6ltAI1nvVxOVVV2wOpwELEbJu8yEv2uL8NlaSj49Ll+stauy20uKerKnd7gnP qCrwClR5jhKXo1tIq8ovI5HPvXeZFDHJxVUFjrqcANXmouR0HBpj/2+k6WaZyqt53e37 0t+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786867557; x=1787472357; 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=StlUsK9zw1G2L8oITvi9ZhkJQGYcuGs/YnOzS0AQwls=; b=LMcTj19ySnymMNJGuNfv7dy1Wp12MER8FNLcXoMbBP1QDpSpIOFNc6JUUoBfxjmLRD OTcJA0ylu46fIKvRlAGsNi8MQQoruL9/nQbgWRHP1FipX37WeetZXE3zupL1Dwlmaxyy LJBYPIkrq1Xn1qgQh/NDCnHcyvS503iLiYhRfiBEsOl3toYSFpkWBUgUBeybUU7QYHer nG1GdCIn9Lg64D+btA3LkLykyD+OAokKQUfG6skOjuT3GSFEYpYLE8Jq4OqDlxnANSKj InlbubxOOwEyOOdcuWcGgoTJ0+iofnhxQhvawogdI4qVifgo9YxzYUSoAj+BxWJvW/Sg zAnw== X-Forwarded-Encrypted: i=1; AHgh+RqcNLSkCRFaOLFYkq+6Qdno1yYX4NXR+WZhZEI92DpXoWu364LgHz4WzbxQjSR3XOA4bCJ3gzpWBOuPyKA=@vger.kernel.org X-Gm-Message-State: AOJu0YxycfLRBKl/CRD0Hj++RZDnN7iPaI25Aiv8x1KrjNIA/niHRfgD 3NTQHTS/DH8hRO4Mr93OTwH778UdrAetFhC0AtJbIv4OgQKy78nR2HBAvWc2ys4sc606QMoytc4 MrwdIE3iZvrMt7zSZlObkSkkAUaIPqEo= X-Gm-Gg: AR+sD13o8HasDi8CFuHPSPhTI2Kg3BiRch3piLsanf+apwsy/0c7Kygm9/YEOXl2tJP +Pqv372uHrSHbg9KgC7shjLapvkDV8D2vcP+4eIJFfzTaHVZGR32lzaaNSLYYNdvSqyH6DG6i60 CZSDSmXs8NMXMsYIK6Sms9NUc3jF10JAdCdsdbBKrUek/QuhwD4FQem2EB8SNygyb86WIIsPA9A j2uWTUUG3iPPm/FDXfD1yF9ngoREKpCAcctJzsiPqiE6kb1SIjA9LQI2E5tv3tu2WZuTvLcOZXa SYwkyRygQBlVCR2Mo9qU6bW5eVT38gof587wbi7giIM= X-Received: by 2002:a05:690c:4382:b0:81e:4aa9:d02a with SMTP id 00721157ae682-8370ce2bfc6mr44691917b3.6.1786867557210; Sun, 16 Aug 2026 01:05:57 -0700 (PDT) Received: from 77377267392 named unknown by gmailapi.google.com with HTTPREST; Sun, 16 Aug 2026 01:05:56 -0700 Received: from 77377267392 named unknown by gmailapi.google.com with HTTPREST; Sun, 16 Aug 2026 01:05:56 -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:05:56 -0700 X-Gm-Features: AcwNN1XFYTv3cmUQkzzVPVdfLZC5oh8lNmR0IdT1s-H3zq9p_C8cu36PX9MDPfA Message-ID: Subject: [PATCH] rust: list: add SAFETY comment for container_of in ListItem::prepare_to_insert 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 8d8c1a4d0dbaa2653e667a0bd0b3b24df4d5ebf0 Mon Sep 17 00:00:00 2001 From: Alex Smolya Date: Sun, 16 Aug 2026 09:27:53 +0200 Subject: [PATCH] rust: list: add SAFETY comment for container_of in ListItem::prepare_to_insert Document the safety rationale for `container_of!` in `ListItem::prepare_to_insert` when using `ListLinksSelfPtr`. In the `ListLinksSelfPtr` implementation of `ListItem`, `view_links(me)` delegates to `raw_get_list_links`, which yields a pointer to the `inner` field of `ListLinksSelfPtr`. Therefore, `links_field` is guaranteed to point to that `inner` field, making the `container_of!` calculation 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rust/kernel/list/impl_list_item_mod.rs b/rust/kernel/list/impl_list_item_mod.rs index d84aedfdc..c2a1f77fb 100644 --- a/rust/kernel/list/impl_list_item_mod.rs +++ b/rust/kernel/list/impl_list_item_mod.rs @@ -276,7 +276,8 @@ unsafe fn prepare_to_insert(me: *const Self) -> *mut $crate::list::ListLinks<$nu // SAFETY: The caller promises that `me` points at a valid value of type `Self`. let links_field =3D unsafe { >::view_links(me) }; - // SAFETY: TODO. + // SAFETY: `links_field` originates from `view_links(me)`, which returns 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