Re: linux-next: manual merge of the rust tree with the driver-core tree

Greg KH
2024-12-17T08:15:19Z

On Tue, Dec 17, 2024 at 02:09:39PM +1100, Stephen Rothwell wrote:
> Hi all,
>
> Today's linux-next merge of the rust tree got a conflict in:
>
> rust/kernel/miscdevice.rs
>
> between commit:
>
> 0d8a7c7bf47a ("rust: miscdevice: access file in fops")
>
> from the driver-core tree and commit:
>
> 27c7518e7f1c ("rust: finish using custom FFI integer types")
> 1bae8729e50a ("rust: map `long` to `isize` and `char` to `u8`")
>
> 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.
>
> --
> Cheers,
> Stephen Rothwell
>
> diff --cc rust/kernel/miscdevice.rs
> index ebc82e7dfc80,8f88891fb1d2..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},
> };
> @@@ -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,
> }

Looks good to me, thansk!

greg k-h