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 7B45D541453 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=1790079419; cv=none; b=l1ed0AS6lR0VDPA9CIfjduWpcVv+OHJC1SWDajpcXOrS+Q187q/dQxrSLOcsYHD4yoJvdiqbApiKiL5Zf0F+XuACuIUopzKGQXWEmnn3AJs8N8mBOYgXMT66Qr1Epk/bCbWbndkA6g4NumPJK14Oh7GUqlBI6LWFqiu+mXij7Xg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790079419; c=relaxed/simple; bh=be2Y1OoUX2Z3H8XLQu3ekiAnAW4Ns+iopXrYkhiGjFw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=FCyWbHMcs1WOLilhsBLtGA8gkqJvpJwZMrAgImEe2zpFCc9xCZ+o5Pq20fq68LFb3JLh81dPwHx1pb1WJq/yolRF6PfA2B/b1dV9ho8+J4X11TxoPK8VzwJMeVCHaDuBs9wYZAM6omcuaUtUoQBUauHvOX0XbKRjgYCQx3iHxPM= 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-482f6350f91so2425481f8f.1 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=TPdxmmhh9HKI63h25Wt3IuP2rswH2b7MB0vfdf+ij0N4zPbzXuywWq4ZQ5Oj8+pMan DvL1Ht+vantTgeqz8XKvPZEb/HQ3n+Esq4EmmW+qwogUuMWuhvod5rlWzZEPTXK4AH+3 +VSwsdZRq+EkbQ7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UFBBR8i4yarQ7vgaVkGmMlsf8W/7U= 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: linux-modules@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