From nobody Thu Apr 2 20:20:25 2026 Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) (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 B2C732BD11 for ; Fri, 13 Feb 2026 05:31:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770960692; cv=none; b=rmU8RT8TfAT9F8FsVP7zzhGa6qx2WbE3cvhCJyJi4E0iD+xcgg+ds0tRLcGixZMaHjfy+mk9v/sgFQ+CqUpsAAr6XPVytF/g8ePlNOpAZ9HXKksnY9VSxV00SEF139HfoQSettGql9Oo8JO6dmSExKtVqAtc3tHxlLJAxy10fnQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770960692; c=relaxed/simple; bh=dFdOAT568Cqh/mmFwcn9/PeCeWaXSGhxD7QVB4HmL5Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EHXsQu1X91UiFLjkax6A8XgJgOYTePd9ZctrQ78CU4o6WNVWfiRT6TE+OSNK2LKWKLdpEo4j+JGFIK1Or35N3vTHh/iDUZXv7dbusP0SLAWtJt+Oct+5WT+KD38gfUYUuT2TJzxZkgOW+AIgqwgMZOHb9VAXKz6f0IjNsaX+Zw0= ARC-Authentication-Results: i=1; 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=OMAi2Pyg; arc=none smtp.client-ip=209.85.128.68 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="OMAi2Pyg" Received: by mail-wm1-f68.google.com with SMTP id 5b1f17b1804b1-482f2599980so6293145e9.0 for ; Thu, 12 Feb 2026 21:31:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770960689; x=1771565489; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nJKGQzb3b9bQwN/lb3i6WMb5fWaM5aaPn20IXUMBUvg=; b=OMAi2PygeaUYIUnushB22y8S3l9naz2PeHljNqcdedkt+CCQlbcG4mNU5rebzqk2s5 0Sc+VbCpzw9OsFYrH67n4RQzleDQYavJe7HOTqd42gj9a4iyyOXiTaQs7ZOZ+8ywO9r1 5SGDaaD/vMWsR011pMI8utHX4HdzaXwYV6LqT4Y5rKuSdBFOmDDZ6i+NguH5ynnQbEiM sUYMKyxc+Rap3N0dohOyBwZD0CK0dvbe0gy91LPR8uPXvOzKmUGGpbNkhSOcFcY5f522 mJz6kTe28aJEnV1Wog5++NiEBH8MoyErMeUygHJNxtbQmafXwfpdGKJ32ZwugNFbBzg8 RjGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770960689; x=1771565489; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=nJKGQzb3b9bQwN/lb3i6WMb5fWaM5aaPn20IXUMBUvg=; b=mqpJuqhaFcFtu8b4ARnu302Y3fhjWJCnwMyAckTQumhv3Xh50cujit3/OiAiPCHR5s zOYzai3u0mAWSLSsNw4BbzpueKFWdVMvxRsv70K9wf89XiL0UBm2R+Djl35GPIGNi9jc Hbi962F1kY/3QFMbE1U4pX5fubU1lJH2MKtP+DUC8qRxWJ4jopjQJHhXML4fVw9qKodE TYnSkJ/Zsb9musDFPYZ44c+EhCXgwarZmdcBTYnLiEfX8+9uMiisS1jMerjP/VSpigga 6jMIe73OvOZ/jC5YPcy2Jc6jJi/Af9ar/56a5k9fIWDO1aUkTvHzPPu+NI/IYiNIu52j 7qBw== X-Gm-Message-State: AOJu0YxAonMo1IqyJQRyI+oM3PDTX3mEZarvzW9J3T2OuTVuywANbsJP YqHiyBgBsmzbT3UMc/H4ixfLX7w8MFdN7FQNehWfVu650LwQ6jsW5lZu X-Gm-Gg: AZuq6aJ1FvTWTWmWxaRtVi1LfXmyjfohDgefD/rxBI9exkkXgNUueOGPj7g8F9Vjj9X rGLRRhg9al5WXjRL8U9FXu2wv9ACWax1xl2wUuHBRzCX3SApAZG+BrB9y85myr9PY4Ous8vc6zq 3WPsh6HygmWNLR4o9jdIgBmHld89BBQtj47VqtgW92tBFuSWq5eexawrW7Q8cKFB2lngDYyh9Vc I342uO2Jpw1qQlFFxlfr+78UNyhfhY24+cMYvrUSTFrCiZy7lvFLENoiv/oKlVPfqpotS7zBI+h hFKGDNj9zJM+nI3Oh1O3Fb2cX8h/ZxTIzXkdbHNNvkeaT0+I9nY3YisBA6NkqJdT+077aHgrVUd ZxSdLf9gFEvQFCNbawHeqCF2zkQrl6rrmXmEmn4IYeltJ6XlrCXW/rhxNA2KShqdXuJB+K2kLmk PSpndNDALdP+c= X-Received: by 2002:a05:600c:524d:b0:483:4807:210c with SMTP id 5b1f17b1804b1-48373a5d7a0mr9408295e9.24.1770960688661; Thu, 12 Feb 2026 21:31:28 -0800 (PST) Received: from localhost ([121.91.57.108]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4834d835f6bsm215737485e9.14.2026.02.12.21.31.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 21:31:28 -0800 (PST) From: Ali Zain To: rust-for-linux@vger.kernel.org Cc: linux-kernel@vger.kernel.org, ojeda@kernel.org, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org, a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu, dakr@kernel.org, Ali Zain Subject: [PATCH] rust: print: Document SAFETY invariants in rust_fmt_argument and call_printk Date: Fri, 13 Feb 2026 10:31:23 +0500 Message-ID: <20260213053123.8869-1-alizainuimx@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260212125427.122362-1-alizainuimx@gmail.com> References: <20260212125427.122362-1-alizainuimx@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace remaining "SAFETY: TODO" comments with proper explanations. Document why the raw pointer cast to `fmt::Arguments` is valid and clarify the invariants required when calling `_printk` through FFI. This does not change behaviour. v2: - Fix rustfmt formatting issue reported by 0-day CI. - Remove extra blank line before unsafe block. Signed-off-by: Ali Zain --- rust/kernel/list.rs | 2 ++ rust/kernel/print.rs | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/rust/kernel/list.rs b/rust/kernel/list.rs index 0d8a201f2..65d33957e 100644 --- a/rust/kernel/list.rs +++ b/rust/kernel/list.rs @@ -589,6 +589,8 @@ pub unsafe fn remove(&mut self, item: &T) -> Option> { // or in this list (with the same `ID`). // - We hold `&mut self`, so there is no concurrent mutation of // the link fields. + // - `T::view_links(item)` returns the embedded link fields for th= is + // object, which remain valid for the lifetime of `item`. =20 let mut item =3D unsafe { ListLinks::fields(T::view_links(item)) }; // SAFETY: The user provided a reference, and reference are never = dangling. diff --git a/rust/kernel/print.rs b/rust/kernel/print.rs index 2ae7b4ce9..c3edc0ab3 100644 --- a/rust/kernel/print.rs +++ b/rust/kernel/print.rs @@ -112,7 +112,6 @@ pub unsafe fn call_printk( // at compile time, a null-terminated module name, and a pointer to // `fmt::Arguments` obtained via `core::ptr::from_ref`. All pointers // are valid for the duration of the call and respect the C ABI. - unsafe { bindings::_printk( format_string.as_ptr(), --=20 2.53.0