From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66A27192B85 for ; Tue, 28 Jan 2025 18:58:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738090681; cv=none; b=YSb8QlTqB1o1Mgab5QNXHi7bOF6Hbtj7iJHS2vFTsmxxG7TtIgiV4/+oOJRrBoLuhhLz53PPq0ozgi/LEPkvBsZXm6KrePu1AHDrmhMiOubKhBdaRBnq8nRxCtRq0BagWfEqpsG3/ifAOVLwUqVvmSMLjfal7FykiCBj0o8g/Ms= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738090681; c=relaxed/simple; bh=aIuVdobKLDkoK5Tb1/qO82pG6HKfuyAmL3p05ohxoJ4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HJN7CQR+GaBY0FhjICj+eVfUDC7f/PBKxAtXGlIFP5Esoak0nJXsT0zP/6wvPicBAOGBb7/knJdbQhscy8OvpTnO7If2cbW5P5NXgvK2gsRc7ey+vaxioKcYU5efkqXVLl2sDcjw8FsW5jFx3r5jz3m9rLUh1oqZU4UFq7wPRHw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=DR1aybGn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="DR1aybGn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71241C4CED3; Tue, 28 Jan 2025 18:58:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738090680; bh=aIuVdobKLDkoK5Tb1/qO82pG6HKfuyAmL3p05ohxoJ4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DR1aybGntCgaCGt25c/iLZbbAL0br05wBwKMf1WdJJl8ilg5HplTvuqMpSu+UwOqT sq5aCTDwTnfTxxPhHLfaVhEyVloUuS8m80m8dferLrfXGl2V6Y8UzBrgG/S91FcGkn axzoBJfDWiJmIEDUu4X0hi9Ez4jh4U2D3U2YgurE= Date: Tue, 28 Jan 2025 19:57:57 +0100 From: Greg KH To: Linus Torvalds , Andrew Morton Cc: linux-kernel@vger.kernel.org, Stephen Rothwell , Al Viro Subject: Re: [GIT PULL] Driver core / debugfs updates for 6.14-rc1 Message-ID: <2025012824-concept-scoring-6e2e@gregkh> References: 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: On Tue, Jan 28, 2025 at 07:57:21PM +0100, Greg KH wrote: > The following changes since commit 5bc55a333a2f7316b58edc7573e8e893f7acb532: > > Linux 6.13-rc7 (2025-01-12 14:37:56 -0800) > > are available in the Git repository at: > > git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git tags/driver-core-6.14-rc1 > > for you to fetch changes up to 01b3cb620815fc3feb90ee117d9445a5b608a9f7: > > rust: device: Use as_char_ptr() to avoid explicit cast (2025-01-16 11:07:27 +0100) > > ---------------------------------------------------------------- > Driver core and debugfs updates > > Here is the big set of driver core and debugfs updates for 6.14-rc1. > It's coming late in the merge cycle as there are a number of merge > conflicts with your tree now, and I wanted to make sure they were > working properly. To resolve them, look in linux-next, and I will send > the "fixup" patch as a response to the pull request. And here's the merge resolution patch that I've used to get a clean build with your tree: diff --cc kernel/module/sysfs.c index 254017b58b64,f99616499e2e..000000000000 --- a/kernel/module/sysfs.c +++ b/kernel/module/sysfs.c @@@ -196,8 -190,8 +190,8 @@@ static int add_notes_attrs(struct modul nattr->attr.mode = 0444; nattr->size = info->sechdrs[i].sh_size; nattr->private = (void *)info->sechdrs[i].sh_addr; - nattr->read = sysfs_bin_attr_simple_read; + nattr->read_new = sysfs_bin_attr_simple_read; - ++nattr; + *(gattr++) = nattr++; } ++loaded; } diff --cc rust/kernel/lib.rs index b11fa08de3c0,545d1170ee63..000000000000 --- a/rust/kernel/lib.rs +++ b/rust/kernel/lib.rs @@@ -13,16 -13,12 +13,17 @@@ #![no_std] #![feature(arbitrary_self_types)] - #![feature(coerce_unsized)] - #![feature(dispatch_from_dyn)] + #![cfg_attr(CONFIG_RUSTC_HAS_COERCE_POINTEE, feature(derive_coerce_pointee))] + #![cfg_attr(not(CONFIG_RUSTC_HAS_COERCE_POINTEE), feature(coerce_unsized))] + #![cfg_attr(not(CONFIG_RUSTC_HAS_COERCE_POINTEE), feature(dispatch_from_dyn))] + #![cfg_attr(not(CONFIG_RUSTC_HAS_COERCE_POINTEE), feature(unsize))] #![feature(inline_const)] #![feature(lint_reasons)] - #![feature(unsize)] +// Stable in Rust 1.83 +#![feature(const_maybe_uninit_as_mut_ptr)] +#![feature(const_mut_refs)] +#![feature(const_ptr_write)] +#![feature(const_refs_to_cell)] // Ensure conditional compilation based on the kernel configuration works; // otherwise we may silently break things like initcall handling. @@@ -37,12 -33,10 +38,13 @@@ pub use ffi pub mod alloc; #[cfg(CONFIG_BLOCK)] pub mod block; - mod build_assert; + #[doc(hidden)] + pub mod build_assert; pub mod cred; pub mod device; +pub mod device_id; +pub mod devres; +pub mod driver; pub mod error; #[cfg(CONFIG_RUST_FW_LOADER_ABSTRACTIONS)] pub mod firmware; diff --cc rust/kernel/miscdevice.rs index dfb363630c70,b3a6cc50b240..000000000000 --- a/rust/kernel/miscdevice.rs +++ b/rust/kernel/miscdevice.rs @@@ -10,11 -10,9 +10,12 @@@ use crate::{ bindings, + device::Device, error::{to_result, Error, Result, VTABLE_DEFAULT_ERROR}, + fs::File, + ffi::{c_int, c_long, c_uint, c_ulong}, prelude::*, + seq_file::SeqFile, str::CStr, types::{ForeignOwnable, Opaque}, }; @@@ -151,17 -132,8 +147,17 @@@ pub trait MiscDevice: Sized _cmd: u32, _arg: usize, ) -> Result { - kernel::build_error!(VTABLE_DEFAULT_ERROR) + build_error!(VTABLE_DEFAULT_ERROR) } + + /// Show info for this fd. + fn show_fdinfo( + _device: ::Borrowed<'_>, + _m: &SeqFile, + _file: &File, + ) { - kernel::build_error!(VTABLE_DEFAULT_ERROR) ++ build_error!(VTABLE_DEFAULT_ERROR) + } } const fn create_vtable() -> &'static bindings::file_operations { @@@ -230,12 -188,8 +226,12 @@@ unsafe extern "C" fn fops_open return err.to_errno(), }; - // SAFETY: The open call of a file owns the private data. - unsafe { (*file).private_data = ptr.into_foreign() }; + // This overwrites the private data with the value specified by the user, changing the type of + // this file's private data. All future accesses to the private data is performed by other + // fops_* methods in this file, which all correctly cast the private data to the new type. + // + // SAFETY: The open call of a file can access the private data. - unsafe { (*raw_file).private_data = ptr.into_foreign().cast_mut() }; ++ unsafe { (*raw_file).private_data = ptr.into_foreign() }; 0 } @@@ -274,12 -225,7 +270,12 @@@ unsafe extern "C" fn fops_ioctl::borrow(private) }; - match T::ioctl(device, cmd, arg) { + // SAFETY: + // * The file is valid for the duration of this call. + // * There is no active fdget_pos region on the file on this thread. + let file = unsafe { File::from_raw_file(file) }; + - match T::ioctl(device, file, cmd, arg as usize) { ++ match T::ioctl(device, file, cmd, arg) { Ok(ret) => ret as c_long, Err(err) => err.to_errno() as c_long, } @@@ -299,12 -245,7 +295,12 @@@ unsafe extern "C" fn fops_compat_ioctl< // SAFETY: Ioctl calls can borrow the private data of the file. let device = unsafe { ::borrow(private) }; - match T::compat_ioctl(device, cmd, arg) { + // SAFETY: + // * The file is valid for the duration of this call. + // * There is no active fdget_pos region on the file on this thread. + let file = unsafe { File::from_raw_file(file) }; + - match T::compat_ioctl(device, file, cmd, arg as usize) { ++ match T::compat_ioctl(device, file, cmd, arg) { Ok(ret) => ret as c_long, Err(err) => err.to_errno() as c_long, } diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index c24ccefb015e..e2c2a2ef1c12 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -1310,7 +1310,7 @@ new_device_store(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_WO(new_device); -static int __i2c_find_user_addr(struct device *dev, void *addrp) +static int __i2c_find_user_addr(struct device *dev, const void *addrp) { struct i2c_client *client = i2c_verify_client(dev); unsigned short addr = *(unsigned short *)addrp; diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c index 7d3b24c8ecae..4fe1a9c0bc1b 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -438,7 +438,7 @@ static int omnia_mcu_get_features(const struct i2c_client *mcu_client) return reply; } -static int omnia_match_mcu_client(struct device *dev, void *data) +static int omnia_match_mcu_client(struct device *dev, const void *data) { struct i2c_client *client;