From: Stephen Rothwell <sfr@canb•auug.org.au>
To: Greg KH <greg@kroah•com>
Cc: Miguel Ojeda <ojeda@kernel•org>,
Alice Ryhl <aliceryhl@google•com>,
Greg Kroah-Hartman <gregkh@linuxfoundation•org>,
Linux Kernel Mailing List <linux-kernel@vger•kernel.org>,
Linux Next Mailing List <linux-next@vger•kernel.org>,
Tamir Duberstein <tamird@gmail•com>
Subject: Re: linux-next: manual merge of the rust tree with the driver-core tree
Date: Thu, 23 Jan 2025 14:30:25 +1100 [thread overview]
Message-ID: <20250123143025.66cde6bc@canb.auug.org.au> (raw)
In-Reply-To: <20250114154623.080e160f@canb.auug.org.au>
[-- Attachment #1: Type: text/plain, Size: 4415 bytes --]
Hi all,
On Tue, 14 Jan 2025 15:46:23 +1100 Stephen Rothwell <sfr@canb•auug.org.au> wrote:
>
> Today's linux-next merge of the rust tree got a conflict in:
>
> rust/kernel/miscdevice.rs
>
> between commit:
>
> 88441d5c6d17 ("rust: miscdevice: access the `struct miscdevice` from fops->open()")
>
> from the driver-core tree and commit:
>
> 14686571a914 ("rust: kernel: change `ForeignOwnable` pointer to mut")
>
> from the rust tree.
>
> I fixed it up (see below) and can carry the fix as necessary. This
> is now fixed as far as linux-next is concerned, but any non trivial
> conflicts should be mentioned to your upstream maintainer when your tree
> is submitted for merging. You may also want to consider cooperating
> with the maintainer of the conflicting tree to minimise any particularly
> complex conflicts.
>
> 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},
> + ffi::{c_int, c_long, c_uint, c_ulong},
> + fs::File,
> prelude::*,
> + seq_file::SeqFile,
> str::CStr,
> types::{ForeignOwnable, Opaque},
> };
> @@@ -151,17 -132,8 +147,17 @@@ pub trait MiscDevice: Sized
> _cmd: u32,
> _arg: usize,
> ) -> Result<isize> {
> - kernel::build_error!(VTABLE_DEFAULT_ERROR)
> + build_error!(VTABLE_DEFAULT_ERROR)
> }
> +
> + /// Show info for this fd.
> + fn show_fdinfo(
> + _device: <Self::Ptr as ForeignOwnable>::Borrowed<'_>,
> + _m: &SeqFile,
> + _file: &File,
> + ) {
> - kernel::build_error!(VTABLE_DEFAULT_ERROR)
> ++ build_error!(VTABLE_DEFAULT_ERROR)
> + }
> }
>
> const fn create_vtable<T: MiscDevice>() -> &'static bindings::file_operations {
> @@@ -230,12 -188,8 +226,12 @@@ unsafe extern "C" fn fops_open<T: MiscD
> Err(err) => 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<T: Misc
> // SAFETY: Ioctl calls can borrow the private data of the file.
> let device = unsafe { <T::Ptr as ForeignOwnable>::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 { <T::Ptr as ForeignOwnable>::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,
> }
This is now a conflict between the driver-core tree and Linus' tree.
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2025-01-23 3:30 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-14 4:46 linux-next: manual merge of the rust tree with the driver-core tree Stephen Rothwell
2025-01-14 8:39 ` Miguel Ojeda
2025-01-23 3:30 ` Stephen Rothwell [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-11-20 7:11 Stephen Rothwell
2025-11-20 9:15 ` Miguel Ojeda
2025-11-20 11:27 ` Tamir Duberstein
2025-11-21 4:39 ` Stephen Rothwell
2025-11-21 12:16 ` Tamir Duberstein
2025-11-21 15:56 ` Miguel Ojeda
2025-11-21 16:07 ` Greg KH
2025-11-23 16:39 ` Miguel Ojeda
2025-11-21 19:21 ` Danilo Krummrich
2025-11-14 4:18 Stephen Rothwell
2025-12-05 3:23 ` Stephen Rothwell
2025-11-10 1:31 Stephen Rothwell
2025-11-10 1:24 Stephen Rothwell
2025-12-05 3:22 ` Stephen Rothwell
2025-09-23 16:44 Mark Brown
2025-09-23 16:49 ` Danilo Krummrich
2025-09-23 19:24 ` Miguel Ojeda
2025-09-24 8:04 ` Mark Brown
2025-09-24 8:25 ` Miguel Ojeda
2025-09-16 13:27 Mark Brown
2025-07-23 1:26 Stephen Rothwell
2025-07-23 12:49 ` Miguel Ojeda
2025-07-21 4:25 Stephen Rothwell
2025-07-21 8:24 ` Miguel Ojeda
2025-07-18 11:01 Stephen Rothwell
2025-07-18 10:46 Stephen Rothwell
2025-07-18 16:43 ` Danilo Krummrich
2025-07-18 10:26 Stephen Rothwell
2025-07-18 10:47 ` Stephen Rothwell
2025-07-15 8:26 Stephen Rothwell
2025-07-15 8:21 Stephen Rothwell
2025-07-11 8:04 Stephen Rothwell
2025-07-11 9:27 ` Tamir Duberstein
2025-07-11 7:59 Stephen Rothwell
2025-07-11 9:48 ` Miguel Ojeda
2025-07-01 7:46 Stephen Rothwell
2025-07-01 9:12 ` Miguel Ojeda
2025-03-21 7:56 Stephen Rothwell
2025-03-21 20:54 ` Miguel Ojeda
2025-04-01 3:21 ` Stephen Rothwell
2025-04-01 7:42 ` Greg KH
2025-01-14 4:37 Stephen Rothwell
2025-01-14 8:38 ` Miguel Ojeda
2025-01-23 3:28 ` Stephen Rothwell
2025-01-13 4:12 Stephen Rothwell
2025-01-13 11:13 ` Miguel Ojeda
2025-01-23 3:31 ` Stephen Rothwell
2024-12-17 3:09 Stephen Rothwell
2024-12-17 8:15 ` Greg KH
2024-12-18 0:18 ` Miguel Ojeda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250123143025.66cde6bc@canb.auug.org.au \
--to=sfr@canb$(echo .)auug.org.au \
--cc=aliceryhl@google$(echo .)com \
--cc=greg@kroah$(echo .)com \
--cc=gregkh@linuxfoundation$(echo .)org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linux-next@vger$(echo .)kernel.org \
--cc=ojeda@kernel$(echo .)org \
--cc=tamird@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox