From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr2-f12.google.com (mail-wr2-f12.google.com [74.125.225.76]) (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 7B3AB54144D for ; Tue, 22 Sep 2026 12:16:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.225.76 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790079418; cv=none; b=ThHk2FsmtP/KOMJbH5QsOEdWR1i52WwTwEkI4GN7fV00LtIp2bkMVbL1SIwji1OxXO8Rsk3VbTj33JnMh/nzIb53IhOnAAMwiWvn3sweeoFKaTH8c9/SFARMVMUT3SnTFlkU4p6QjweSZbUuoPJuYnlhbVhhJlRK6MmEGKvIMmg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790079418; c=relaxed/simple; bh=be2Y1OoUX2Z3H8XLQu3ekiAnAW4Ns+iopXrYkhiGjFw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Qn3OecAB963cJQxqkBK5hqu+LPym6CMDFnKJriOO8U076kWtU5NcN5G/FOORJVrKFVJxZ1Y6lVQvU6dO29/xy1kUr0bkmUAoPBGwtfUEA4j9286ifINJYvjRkr1N98sc5dhZlc2dUOD4awOxEcEGsfR/wN2iQ2caasGliPsLC1U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=OQZUocIX; arc=none smtp.client-ip=74.125.225.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="OQZUocIX" Received: by mail-wr2-f12.google.com with SMTP id ffacd0b85a97d-482f6350f88so2559066f8f.2 for ; Tue, 22 Sep 2026 05:16:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1790079415; x=1790684215; darn=vger.kernel.org; h=content-transfer-encoding:content-type: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 :content-type; bh=qYZAQI2MQFIAWvU45KsUnqIxxfeReE1kdzg/hPVRdMU=; b=OQZUocIXA25N0fPKAIruZntV3ZEP5EN9YvzISI0VjBPrjdipX7NzMz+lzmuBsDyf12 9VR0htwPwVJwwbAHd5/2A7+BQA1G5ZkIgbBWZC7fbWneEEZwTF7Uka1iUjEAVx4dg5t5 /D+F2VwTjsqGwdh65OAFeJjLmbxfmmAATZqA2d7K2fUdG7Tvj+1z5jMLgq2Orf0uR2VP TwamgpEB0xHuLK2LLBRWj06zls6MheTHDsXVcFQrMVY+iwn7avH3pUwxw8JGOsojM3PB CcNt/a8PcNZqY26jA0M8wD5sEQHLamKAWgOe/al5LPnuhQq9bMGJ3LERbDD09cqhMYL2 wecg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790079415; x=1790684215; h=content-transfer-encoding:content-type: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:content-type; bh=qYZAQI2MQFIAWvU45KsUnqIxxfeReE1kdzg/hPVRdMU=; b=HQ9iyeU5tm1Mdvx7QOAoA91FVYF3ZqJydyu2eD831uWP/cuCNiskFpScPJeJmAaihw aH+z2+KkINYxoV30P9bByPdTp8/K33CXc1UGLXznkdmftn3R7ciBiCXKaKl7PL0qU0hT vA32zIEqo/GpTFZ2408T6XPddRxTVISugQX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94WjFZsyfnM7ZSOBwxc= X-Received: by 2002:a05:6000:29d7:b0:488:5d3e:bf47 with SMTP id ffacd0b85a97d-4885d3ec41fmr4775296f8f.33.1790079414556; Tue, 22 Sep 2026 05:16:54 -0700 (PDT) Received: from ?IPV6:2a00:1028:838d:271e:8e3b:4aff:fe4c:a100? (dynamic-2a00-1028-838d-271e-8e3b-4aff-fe4c-a100.ipv6.o2.cz. [2a00:1028:838d:271e:8e3b:4aff:fe4c:a100]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-488627937b5sm4088822f8f.30.2026.09.22.05.16.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Sep 2026 05:16:54 -0700 (PDT) Message-ID: <0f8f5dd7-06b6-4145-8b85-ed62504e2d4f@suse.com> Date: Tue, 22 Sep 2026 14:16:53 +0200 Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/1] rust: module_param: Fix potentially incorrect access of `SetOnce` To: Priya Bala Govindasamy Cc: mcgrof@kernel.org, da.gomez@kernel.org, samitolvanen@google.com, ojeda@kernel.org, atomlin@atomlin.com, 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, linux-modules@vger.kernel.org, rust-for-linux@vger.kernel.org, ardalan@uci.edu, zhiyunq@cs.ucr.edu, dzueck@uci.edu References: Content-Language: en-US From: Petr Pavlu In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 9/17/26 7:43 PM, Priya Bala Govindasamy wrote: > The `set_param` function casts `kernel_param.arg` to `*const SetOnce` > But the Rust module macro in rust/macros/module.rs initializes `arg` with > `#param_name.as_void_ptr()`, and `#param_name` is a `ModuleParamAccess`, > not a `SetOnce`. > > ModuleParamAccess has default Rust layout but `set_param` accesses its > first field SetOnce assuming it to be at offset 0. This is not > guaranteed by Rust and could cause type confusion leading to data > corruption. > > Fix this by casting `kernel_param.arg` to `ModuleParamAccess` and > then accessing the `value: SetOnce` field. > > Fixes: 0b08fc292842 ("rust: introduce module_param module") > Reported-by: Dylan Zueck > Assisted-by: LLM > Signed-off-by: Priya Bala Govindasamy > --- > rust/kernel/module_param.rs | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/rust/kernel/module_param.rs b/rust/kernel/module_param.rs > index f9a14765a926..7ae87ffe1d6b 100644 > --- a/rust/kernel/module_param.rs > +++ b/rust/kernel/module_param.rs > @@ -75,7 +75,9 @@ pub trait ModuleParam: Sized + Copy { > let new_value = T::try_from_param_arg(arg)?; > > // SAFETY: By function safety requirements, this access is safe. > - let container = unsafe { &*((*param).__bindgen_anon_1.arg.cast::>()) }; > + let param_access = unsafe { &*((*param) > + .__bindgen_anon_1.arg.cast::>()) }; > + let container = ¶m_access.value; > > container > .populate(new_value) This looks ok to me, except for the formatting. I plan to take it on the modules tree, after giving others a bit more time to potentially comment. Reviewed-by: Petr Pavlu -- Thanks, Petr