From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 B454536D4EF for ; Fri, 6 Mar 2026 19:28:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772825287; cv=none; b=MR1J9OztrDvgIqjP/zP2K5lXd+GWTyUx1yP3DX8nRbTj3mscjloTJ1B0N7AGdOKcL0oowwGsecywaQqeeyXCfwQ/CBLOdwbd+HazC8SnohED6DVN0s35icfkBJHr3dN880vwXMM6V/rSlAHrpjz8mWfTpOsa9nGgkKNCzuVITTg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772825287; c=relaxed/simple; bh=1wSzry9qXgOGT6an8EaEVFIb7De7cskzidp6Q/iEeZ0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=APfpAUwowbWXGla58NhlLOFtrm3TPg6SuQw6kw7S8lxVEMzykH9T5/phKXZYm18QvUbLxQx4MKT9+ETUdXpzVWOu0M5mBGYyTCYqrKgwvtSLQV17ZtU2Mt/tWBck7oB1ng6Rv3rsy35gjLRtAQP3vRAagsF+j0Xe2Sq5UUroPN0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=RrSPeJQn; arc=none smtp.client-ip=209.85.214.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RrSPeJQn" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2ae523d54d2so8955ad.1 for ; Fri, 06 Mar 2026 11:28:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772825286; x=1773430086; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=PvXYP23IhuFH1eZo6K/xzmMOw61rGrmSbBCOFimt1yM=; b=RrSPeJQnLdLtKC0ennxeJvxxlxVOcRVe2l/C8vOk2RHhFqhvRnGb01aNx6vA2Vpz2L xOyfFl/WVz2E14hgaOoutMZQY/he1ZBVTjPLZ3z43NzUTazwZ+iqky+T4kfo6aUyqFIN dgafzgrhlP3CI0L8A5CiGgTqAAmR/7wt3H5a7iQskbBfIIP19A1A4yZxzNIcufVKl6jk jGmAVEISb76IhMdDrH/mVz8eksJmJmRwhmnLKlyGXMRA2KA493eAFMAo/Sfpfsu4/T16 fyJNU6G2ladry1Zof/+tmT7VMBO2uvBV4QW7RPrxy8s6/fYQwOSH4wThf2OGS0v1k12p vFmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772825286; x=1773430086; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PvXYP23IhuFH1eZo6K/xzmMOw61rGrmSbBCOFimt1yM=; b=Brs/+6kNbbsT9F8vkimf9IJPCDiwRc+HVVhTkIqYukXDuWuVhZ9B0yg2eWfU/DSlIl wDEv8/H9JEerZdPJRF/Ns0CRQWFidmzrcxSVa0kLpvbwdjFFYyXjCUHRiHKbrx4gQNTT OJ1fijkEy0M14/clhECqTUTlMMIm/JBCpcxnDMrREM7DPMips0FzoxTCSJ05TYxYXwMw GrnFXI9f/xxWNMIeg9zVkbruOem8DTCPyLQ7RBJL63rSk8+5zRW04vIy7ibNsxNYaE/S yEmKJmcup4unw/tUI8Z4hAcDUpocj97eY1Zdh+qiPSkUia2Z4G8aoUEPbG6bc5QC4+lf dlNg== X-Forwarded-Encrypted: i=1; AJvYcCUrWHoVwFxzF+ZG9z3D9F52b424BuEIRH7Eq17VjvI1eRhV4Ny9mQ/EspI+6VyNHeY3exQnxZeRN2YiheA=@vger.kernel.org X-Gm-Message-State: AOJu0YzXy2BokYcyi4CoBVcRyxuXMbWIwtYE8RE/hpRqkji0P3xCYZ6/ mOqEdC9JCBCig3tSkue78nQu+0sVnWZPNksK7VsqkB8tR1g0RlKxYZzAwAqYSdXBQw== X-Gm-Gg: ATEYQzxisKNth1bJw8GdzzDTscgP3Lph3wpXycaiBiACp/eMqpjJJ3LrmlSebYXfkk2 K4riOVhzyhVquor+6Bt5nrqnvEAHpzaTG17cgh1AK7S1KtJGU94xEigMXhzSBO8ybA8uKHd51RH 92g1LZ/rMcB/ybfa5AT+3PoTuu36bWRHrH2SLk42mU/5h3AQNVGwlFT0PMwdvJNQyMSoiu3aYU8 IOVcr9JGQX6mkarADnPAhwubv+frgjYkd7FduqrNNkunHFO0jCQmW+PL9ahI5Lz5vrj+UI4/KF3 Et6dmLTmhMK34Zf5xzthue09uEvYqBiH7NyeZinYyOm22QHb1m4bvu0LLlfjJCAuL8f2I7La+6l oXy9+XsHQoLIl1bejAAJ+GxLpRs/o75DHQC18nFnxFaEqbfO6saw6HnSP0uka0NA1Sb7V8Zlxik +VqO7bmjogWyo9ynPCQPyw6tMkVruLwBGgFDLFf9gVtxTD8d+ur/zAhgoqCeBmQSCah/4= X-Received: by 2002:a17:902:d487:b0:2a7:4151:2c74 with SMTP id d9443c01a7336-2ae8ad895d7mr224085ad.16.1772825285389; Fri, 06 Mar 2026 11:28:05 -0800 (PST) Received: from google.com (197.23.125.34.bc.googleusercontent.com. [34.125.23.197]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c739e0cb598sm2259382a12.13.2026.03.06.11.28.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 11:28:04 -0800 (PST) Date: Fri, 6 Mar 2026 19:27:59 +0000 From: Sami Tolvanen To: Matthew Wood Cc: Miguel Ojeda , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Aaron Tomlin , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Tamir Duberstein , David Gow , =?iso-8859-1?Q?Jos=E9_Exp=F3sito?= , linux-modules@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/8] rust: module_param: wire StringParam into the module! macro Message-ID: <20260306192759.GA1369418@google.com> References: <20260226234736.428341-1-thepacketgeek@gmail.com> <20260226234736.428341-3-thepacketgeek@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260226234736.428341-3-thepacketgeek@gmail.com> On Thu, Feb 26, 2026 at 03:47:28PM -0800, Matthew Wood wrote: > +/// Set a string module parameter from a string. > +/// > +/// Similar to [`set_param`] but for [`StringParam`]. > +/// > +/// # Safety > +/// > +/// Same requirements as [`set_param`]. > +unsafe extern "C" fn set_string_param( > + val: *const c_char, > + param: *const bindings::kernel_param, > +) -> c_int { > + if val.is_null() { > + crate::pr_warn!("Null pointer passed to `module_param::set_string_param`"); > + return EINVAL.to_errno(); > + } > + > + crate::error::from_result(|| { > + // SAFETY: val points to a valid C string from the kernel. > + let cstr_param = unsafe { StringParam::from_ptr(val) }; > + > + // SAFETY: By function safety requirements, param.arg points to our SetOnce. > + let container = unsafe { &*((*param).__bindgen_anon_1.arg.cast::>()) }; I do realize this matches set_param, and there's a good chance I missed something when reading the macros, but doesn't arg actually point to ModuleParamAccess here? Since the struct is not repr(C), isn't the compiler technically speaking allowed to reorder the fields, which means SetOnce might not actually be at offset 0? > + > + container > + .populate(cstr_param) > + .then_some(0) > + .ok_or(kernel::error::code::EEXIST) Does this mean the behavior for Rust modules differs from C modules if the user specifies multiple instances of the same parameter? I believe we just use the last value of the parameter instead of failing in C. Sami