From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f66.google.com (mail-ej1-f66.google.com [209.85.218.66]) (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 C11E224468B for ; Sat, 20 Dec 2025 13:26:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.66 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766237219; cv=none; b=L5SN/mO4ZAm1v53rDnBznuel40bd8aQ0LIk839bcLQ76J6A8EuzUcjOc8VSGvnwfthebyV/1ePS+jUvkolJLsAsm7d2IDMtH2cz4U0Cj1x87/YgHhoiAjiF/oIptvnrOo5koVdgIZIAqzCjCnXy9ZEs4JbYr2m7qnE6zLoEKcmM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766237219; c=relaxed/simple; bh=ZszcD9aZyqLmppNl6uOYsAZ/9RvyvzsZifB0jXA3f2M=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Xh8HgC2gs0tiL3Vwp+vTzbgP44PgzvgPJjSEA8yvC6kwyQW19NNEKqNDT6hmToakBRn1aDuzKeEmI3YZ9+KHAow1LkW0Ei36XMVbQPUvys+urcjJG4tM1p27dIhkFjcEFricZG2mWb6t50dpy80ffhhwSJNIoe7OfrqRpgrmS6s= 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=hTHMbCBH; arc=none smtp.client-ip=209.85.218.66 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="hTHMbCBH" Received: by mail-ej1-f66.google.com with SMTP id a640c23a62f3a-b7697e8b01aso490215866b.2 for ; Sat, 20 Dec 2025 05:26:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766237216; x=1766842016; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=J0hMXtp/lfaKs61nOjhlRq2RZbYRAnfd/dUReiralVc=; b=hTHMbCBH4qr1vHUqXbStopOYeZi840obDA6drJtieldITnPh3RiywU5HGgMNzQjUnl nTskan3TloCayerovN+CZPVahOrwI7RUyZ71WxKwJqBR9ElPNOZSd7DRARHu6lvGBKut bJbHrnSb+r+Fp0fSMapd7RHrCHrkqly9eKJMMLDHmUVRNtovDSryf7cZ0MmGBlKA5JS8 1sez7j9iKlOW3CnvB2RWzzBpCpYqFd8zRbW08I1QTz37vTvK1Ieq4TXBYtSBTHGt17rp 3NkT97UUE9riKJ3A0ZpaHNa4ln/WxBcwavKq14zIAn98yxKdKqgQG9YLbY45OaNe9xnE VjdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766237216; x=1766842016; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=J0hMXtp/lfaKs61nOjhlRq2RZbYRAnfd/dUReiralVc=; b=Vr6Bzp26+Nwfxq/rNnOxGl/tMfw1S+pWNXhnKNSBntrzUcXZSqu8iUoxn1JYSpx+h2 wqnD2qhFSjCCcoNeTcIr8ax6L2wH/x6I+flDj33FHHT9uzN2S1npXtDzUlnFzhVRs23q gYBFyL887mmO4/smH5RMR/nd1KytIx5rvTVrtnJhT8Gfz33OfYyMY5EaTQ2zUJtlQC9k j+n/rZAznMAqlSyn8ktETG9OFkp+nID5IULM94IYO0+8dlsN6xXz4k2Koey5z8sWR3XZ UDjqK6l8Kf/9Cu4ajEHUrBApu2B8tViTdKJP4/+7zwTWwDFeW/cqrnjhZ0t5GuBrPQha xPaw== X-Gm-Message-State: AOJu0Yzz53fe5xz3aXVkM5dqCniCdqEtSIhxQyyob0q6RjTkntOi2lVh LuhcoEjLJ7lV0QWKMM9ksNUASg7Gis2rz1Y7D92LRBB6fnegt61JdSiP+MVyrQh7r1M= X-Gm-Gg: AY/fxX4xUy4UEahGBwFT+QsqsifEOucjpO7xuviWKidUgahHvq6gUK31Md8BS9JAdKw KXM3PUnQcCMFDp1kPfnaQCoNDq/VCqLPHFqLdePCIV48sawMeSXl8UhXUtevRVCs/TwQ0jhtBFA xvyPsnlvCX6/YGi19sfJoNWTmjRIayanX9scKmyAbsshyUn6T9pQAsI9ILjgAyb3z+oYq9fj5+H Xerk6MJG6aoVsVCX1axtBaKQsunCWNTC88IQwHxW14MjeoZqlfeUkkrX7RCqsXUAmfBmrXXdXpN bJZoVpniQ0jU4ZQOAcXE3UAyEaH6eRMwbN8dOwQXIJ4lyiAP5ZKoJF3eZfHKiTx1vK+bQMSMY2h t8kSQmJGKm1m7+up9mW7dCj6Wx16r9q95jkx/i3vKFhJNM2tXmqV1CdrfvrlKgzzryMsm0tnlds QWA2fsV2DyBSPLVv6y33ee1R86K8q9PFx7sgKtlR13EajscTAOJ25Y2IbbbnUgIVkEnroxbU9o9 pSVUeqUMutkIVJO0081x0y/1a2+1Q2ILndH5pokwVZgyw== X-Google-Smtp-Source: AGHT+IGQG9QpYLfU4h8xN3mNdzv5dB2m+jacD8KkbE346mRyFnogzecStI4R3a2FK5Ch18aosbwARA== X-Received: by 2002:a17:907:c14:b0:b80:1309:aa09 with SMTP id a640c23a62f3a-b803718387cmr612957166b.47.1766237215643; Sat, 20 Dec 2025 05:26:55 -0800 (PST) Received: from ?IPV6:2003:df:bf2d:e300:6a92:2e3e:53e0:d832? (p200300dfbf2de3006a922e3e53e0d832.dip0.t-ipconnect.de. [2003:df:bf2d:e300:6a92:2e3e:53e0:d832]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b803d3cea32sm436626666b.34.2025.12.20.05.26.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 20 Dec 2025 05:26:55 -0800 (PST) Message-ID: <518143d5-b273-48df-94f0-664116358665@gmail.com> Date: Sat, 20 Dec 2025 14:26:54 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] rust: document safety requirements for fmt::Arguments dereference To: Riccardo , rust-for-linux@vger.kernel.org Cc: linux-kernel@vger.kernel.org References: <20251220130014.3961-1-riccioadami@gmail.com> Content-Language: de-AT-frami, en-US From: Dirk Behme In-Reply-To: <20251220130014.3961-1-riccioadami@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Riccardo, On 20.12.25 14:00, Riccardo wrote: > From: Riccardo Adami If you configure your mail tool to use `Riccardo Adami ` automatically in the `From: ...` (instead of`Riccardo ` which is there at the moment) there is no need to add this `From: ...` manually here. > This patch documents the safety requirements for dereferencing > `fmt::Arguments` in the kernel's `vsnprintf` formatting path. This > clarifies why it is safe to perform the unsafe dereference in > `rust_fmt_argument` and helps future maintainers understand the > invariants, reducing the risk of incorrect modifications. Empty line between the description and the Signed-off-by please. > Signed-off-by: Riccardo Please use your "full" name here. Like you have done in the manually added `From: ...` above: Riccardo Adami > --- If you send newer versions of your patch please use some versioning v2, v3 etc. This has to go into the subject e.g. `[PATCH v2] ...` and needs a change log here below the `---` e.g. v2: Add Signed-off-by .... Maybe you like to have a look to existing patches like https://lore.kernel.org/rust-for-linux/20251218-inline-lock-unlock-v2-1-fbadac8bd61b@google.com/ > rust/kernel/print.rs | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/rust/kernel/print.rs b/rust/kernel/print.rs > index 899bed9c08fd..5f54be97a6a0 100644 > --- a/rust/kernel/print.rs > +++ b/rust/kernel/print.rs > @@ -25,10 +25,10 @@ > // SAFETY: The C contract guarantees that `buf` is valid if it's less than `end`. > let mut w = unsafe { RawFormatter::from_ptrs(buf.cast(), end.cast()) }; > //SAFETY: `ptr` is provided by the kernel formatting path for the `%pA` > -// specifier during `vsnprintf` processing and always points to a valid > -// `fmt::Arguments` value created by the caller. The value lives at least > -// for the duration of this call and is only read here. It is not stored > -// or accessed after returning, so dereferencing it is safe. > + // specifier during `vsnprintf` processing and always points to a valid > + // `fmt::Arguments` value created by the caller. The value lives at least > + // for the duration of this call and is only read here. It is not stored > + // or accessed after returning, so dereferencing it is safe. I have some difficulties matching the description in the commit message above with this change. For me it looks like you just fix the indentation but haven't changed anything on the SAFETY comment itself? Looking at the original file https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/rust/kernel/print.rs?h=v6.19-rc1#n27 I wonder if in the end you want to update the `// SAFETY: TODO.` there? What would match the commit description? But that isn't done here. So if this is the case you might want to check if you sent an intermediate version of you work? Thanks for working on this! Dirk