linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* linux-next: manual merge of the rust tree with the vfs-brauner tree
@ 2024-10-04  4:42 Stephen Rothwell
  2024-10-04  9:25 ` Miguel Ojeda
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Rothwell @ 2024-10-04  4:42 UTC (permalink / raw)
  To: Miguel Ojeda, Christian Brauner
  Cc: Alice Ryhl, Linux Kernel Mailing List, Linux Next Mailing List

[-- Attachment #1: Type: text/plain, Size: 3536 bytes --]

Hi all,

Today's linux-next merge of the rust tree got a conflict in:

  rust/kernel/types.rs

between commit:

  e7572e5deaf3 ("rust: types: add `NotThreadSafe`")

from the vfs-brauner tree and commits:

  c4277ae2a630 ("rust: types: avoid repetition in `{As,From}Bytes` impls")
  432526d4ff32 ("rust: enable `clippy::undocumented_unsafe_blocks` lint")

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/types.rs
index 3238ffaab031,28d9e5ea3df4..000000000000
--- a/rust/kernel/types.rs
+++ b/rust/kernel/types.rs
@@@ -514,42 -527,23 +527,44 @@@ impl_frombytes! 
  /// mutability.
  pub unsafe trait AsBytes {}
  
- // SAFETY: Instances of the following types have no uninitialized portions.
- unsafe impl AsBytes for u8 {}
- unsafe impl AsBytes for u16 {}
- unsafe impl AsBytes for u32 {}
- unsafe impl AsBytes for u64 {}
- unsafe impl AsBytes for usize {}
- unsafe impl AsBytes for i8 {}
- unsafe impl AsBytes for i16 {}
- unsafe impl AsBytes for i32 {}
- unsafe impl AsBytes for i64 {}
- unsafe impl AsBytes for isize {}
- unsafe impl AsBytes for bool {}
- unsafe impl AsBytes for char {}
- unsafe impl AsBytes for str {}
- // SAFETY: If individual values in an array have no uninitialized portions, then the array itself
- // does not have any uninitialized portions either.
- unsafe impl<T: AsBytes> AsBytes for [T] {}
- unsafe impl<T: AsBytes, const N: usize> AsBytes for [T; N] {}
+ macro_rules! impl_asbytes {
+     ($($({$($generics:tt)*})? $t:ty, )*) => {
+         // SAFETY: Safety comments written in the macro invocation.
+         $(unsafe impl$($($generics)*)? AsBytes for $t {})*
+     };
+ }
+ 
+ impl_asbytes! {
+     // SAFETY: Instances of the following types have no uninitialized portions.
+     u8, u16, u32, u64, usize,
+     i8, i16, i32, i64, isize,
+     bool,
+     char,
+     str,
+ 
+     // SAFETY: If individual values in an array have no uninitialized portions, then the array
+     // itself does not have any uninitialized portions either.
+     {<T: AsBytes>} [T],
+     {<T: AsBytes, const N: usize>} [T; N],
+ }
 +
 +/// Zero-sized type to mark types not [`Send`].
 +///
 +/// Add this type as a field to your struct if your type should not be sent to a different task.
 +/// Since [`Send`] is an auto trait, adding a single field that is `!Send` will ensure that the
 +/// whole type is `!Send`.
 +///
 +/// If a type is `!Send` it is impossible to give control over an instance of the type to another
 +/// task. This is useful to include in types that store or reference task-local information. A file
 +/// descriptor is an example of such task-local information.
 +///
 +/// This type also makes the type `!Sync`, which prevents immutable access to the value from
 +/// several threads in parallel.
 +pub type NotThreadSafe = PhantomData<*mut ()>;
 +
 +/// Used to construct instances of type [`NotThreadSafe`] similar to how `PhantomData` is
 +/// constructed.
 +///
 +/// [`NotThreadSafe`]: type@NotThreadSafe
 +#[allow(non_upper_case_globals)]
 +pub const NotThreadSafe: NotThreadSafe = PhantomData;

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: linux-next: manual merge of the rust tree with the vfs-brauner tree
  2024-10-04  4:42 Stephen Rothwell
@ 2024-10-04  9:25 ` Miguel Ojeda
  0 siblings, 0 replies; 7+ messages in thread
From: Miguel Ojeda @ 2024-10-04  9:25 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Miguel Ojeda, Christian Brauner, Alice Ryhl,
	Linux Kernel Mailing List, Linux Next Mailing List

On Fri, Oct 4, 2024 at 6:42 AM Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> Today's linux-next merge of the rust tree got a conflict in:
>
>   rust/kernel/types.rs
>
> between commit:
>
>   e7572e5deaf3 ("rust: types: add `NotThreadSafe`")
>
> from the vfs-brauner tree and commits:
>
>   c4277ae2a630 ("rust: types: avoid repetition in `{As,From}Bytes` impls")
>   432526d4ff32 ("rust: enable `clippy::undocumented_unsafe_blocks` lint")
>
> from the rust tree.
>
> I fixed it up (see below) and can carry the fix as necessary. This

Looks good, thanks as usual!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* linux-next: manual merge of the rust tree with the vfs-brauner tree
@ 2024-10-08  5:56 Stephen Rothwell
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Rothwell @ 2024-10-08  5:56 UTC (permalink / raw)
  To: Miguel Ojeda, Christian Brauner
  Cc: Alice Ryhl, Aliet Exposito Garcia, Linux Kernel Mailing List,
	Linux Next Mailing List

[-- Attachment #1: Type: text/plain, Size: 5040 bytes --]

Hi all,

Today's linux-next merge of the rust tree got a conflict in:

  rust/kernel/types.rs

between commit:

  e7572e5deaf3 ("rust: types: add `NotThreadSafe`")

from the vfs-brauner tree and commits:

  567cdff53e71 ("rust: types: avoid repetition in `{As,From}Bytes` impls")
  67b3fa4288fa ("rust: kernel: move `FromBytes` and `AsBytes` traits to a new `transmute` module")

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/types.rs
index 3238ffaab031,5ea9126c8c93..000000000000
--- a/rust/kernel/types.rs
+++ b/rust/kernel/types.rs
@@@ -468,88 -329,3 +329,24 @@@ pub enum Either<L, R> 
      /// Constructs an instance of [`Either`] containing a value of type `R`.
      Right(R),
  }
 +
- /// Types for which any bit pattern is valid.
- ///
- /// Not all types are valid for all values. For example, a `bool` must be either zero or one, so
- /// reading arbitrary bytes into something that contains a `bool` is not okay.
- ///
- /// It's okay for the type to have padding, as initializing those bytes has no effect.
- ///
- /// # Safety
- ///
- /// All bit-patterns must be valid for this type. This type must not have interior mutability.
- pub unsafe trait FromBytes {}
- 
- // SAFETY: All bit patterns are acceptable values of the types below.
- unsafe impl FromBytes for u8 {}
- unsafe impl FromBytes for u16 {}
- unsafe impl FromBytes for u32 {}
- unsafe impl FromBytes for u64 {}
- unsafe impl FromBytes for usize {}
- unsafe impl FromBytes for i8 {}
- unsafe impl FromBytes for i16 {}
- unsafe impl FromBytes for i32 {}
- unsafe impl FromBytes for i64 {}
- unsafe impl FromBytes for isize {}
- // SAFETY: If all bit patterns are acceptable for individual values in an array, then all bit
- // patterns are also acceptable for arrays of that type.
- unsafe impl<T: FromBytes> FromBytes for [T] {}
- unsafe impl<T: FromBytes, const N: usize> FromBytes for [T; N] {}
- 
- /// Types that can be viewed as an immutable slice of initialized bytes.
- ///
- /// If a struct implements this trait, then it is okay to copy it byte-for-byte to userspace. This
- /// means that it should not have any padding, as padding bytes are uninitialized. Reading
- /// uninitialized memory is not just undefined behavior, it may even lead to leaking sensitive
- /// information on the stack to userspace.
- ///
- /// The struct should also not hold kernel pointers, as kernel pointer addresses are also considered
- /// sensitive. However, leaking kernel pointers is not considered undefined behavior by Rust, so
- /// this is a correctness requirement, but not a safety requirement.
- ///
- /// # Safety
- ///
- /// Values of this type may not contain any uninitialized bytes. This type must not have interior
- /// mutability.
- pub unsafe trait AsBytes {}
- 
- // SAFETY: Instances of the following types have no uninitialized portions.
- unsafe impl AsBytes for u8 {}
- unsafe impl AsBytes for u16 {}
- unsafe impl AsBytes for u32 {}
- unsafe impl AsBytes for u64 {}
- unsafe impl AsBytes for usize {}
- unsafe impl AsBytes for i8 {}
- unsafe impl AsBytes for i16 {}
- unsafe impl AsBytes for i32 {}
- unsafe impl AsBytes for i64 {}
- unsafe impl AsBytes for isize {}
- unsafe impl AsBytes for bool {}
- unsafe impl AsBytes for char {}
- unsafe impl AsBytes for str {}
- // SAFETY: If individual values in an array have no uninitialized portions, then the array itself
- // does not have any uninitialized portions either.
- unsafe impl<T: AsBytes> AsBytes for [T] {}
- unsafe impl<T: AsBytes, const N: usize> AsBytes for [T; N] {}
- 
 +/// Zero-sized type to mark types not [`Send`].
 +///
 +/// Add this type as a field to your struct if your type should not be sent to a different task.
 +/// Since [`Send`] is an auto trait, adding a single field that is `!Send` will ensure that the
 +/// whole type is `!Send`.
 +///
 +/// If a type is `!Send` it is impossible to give control over an instance of the type to another
 +/// task. This is useful to include in types that store or reference task-local information. A file
 +/// descriptor is an example of such task-local information.
 +///
 +/// This type also makes the type `!Sync`, which prevents immutable access to the value from
 +/// several threads in parallel.
 +pub type NotThreadSafe = PhantomData<*mut ()>;
 +
 +/// Used to construct instances of type [`NotThreadSafe`] similar to how `PhantomData` is
 +/// constructed.
 +///
 +/// [`NotThreadSafe`]: type@NotThreadSafe
 +#[allow(non_upper_case_globals)]
 +pub const NotThreadSafe: NotThreadSafe = PhantomData;

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* linux-next: manual merge of the rust tree with the vfs-brauner tree
@ 2024-11-11  6:29 Stephen Rothwell
  2024-11-11 23:57 ` Miguel Ojeda
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Rothwell @ 2024-11-11  6:29 UTC (permalink / raw)
  To: Miguel Ojeda, Christian Brauner
  Cc: Alice Ryhl, Gary Guo, Linux Kernel Mailing List,
	Linux Next Mailing List

[-- Attachment #1: Type: text/plain, Size: 1532 bytes --]

Hi all,

Today's linux-next merge of the rust tree got a conflict in:

  rust/kernel/task.rs

between commits:

  e7572e5deaf3 ("rust: types: add `NotThreadSafe`")
  8ad1a41f7e23 ("rust: file: add `Kuid` wrapper")
  e0020ba6cbcb ("rust: add PidNamespace")

from the vfs-brauner tree and commit:

  d072acda4862 ("rust: use custom FFI integer types")

from the rust tree.

I fixed it up (I think - 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/task.rs
index 5120dddaf916,5bce090a3869..000000000000
--- a/rust/kernel/task.rs
+++ b/rust/kernel/task.rs
@@@ -4,17 -4,9 +4,17 @@@
  //!
  //! C header: [`include/linux/sched.h`](srctree/include/linux/sched.h).
  
+ use crate::ffi::{c_int, c_long, c_uint};
 -use crate::types::Opaque;
 -use core::{marker::PhantomData, ops::Deref, ptr};
 +use crate::{
 +    bindings,
 +    pid_namespace::PidNamespace,
 +    types::{ARef, NotThreadSafe, Opaque},
 +};
 +use core::{
 +    cmp::{Eq, PartialEq},
-     ffi::{c_int, c_long, c_uint},
 +    ops::Deref,
 +    ptr,
 +};
  
  /// A sentinel value used for infinite timeouts.
  pub const MAX_SCHEDULE_TIMEOUT: c_long = c_long::MAX;

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: linux-next: manual merge of the rust tree with the vfs-brauner tree
  2024-11-11  6:29 Stephen Rothwell
@ 2024-11-11 23:57 ` Miguel Ojeda
  0 siblings, 0 replies; 7+ messages in thread
From: Miguel Ojeda @ 2024-11-11 23:57 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Miguel Ojeda, Christian Brauner, Alice Ryhl, Gary Guo,
	Linux Kernel Mailing List, Linux Next Mailing List

On Mon, Nov 11, 2024 at 7:29 AM Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> I fixed it up (I think - see below) and can carry the fix as

Looks good to me -- thanks!

You will get the conflict in the upcoming round again, but this time
without build failures, hopefully! The hash has not changed.

Thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* linux-next: manual merge of the rust tree with the vfs-brauner tree
@ 2025-06-24  6:23 Stephen Rothwell
  2025-06-24  8:54 ` Miguel Ojeda
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Rothwell @ 2025-06-24  6:23 UTC (permalink / raw)
  To: Miguel Ojeda, Christian Brauner
  Cc: Alice Ryhl, Linux Kernel Mailing List, Linux Next Mailing List,
	Tamir Duberstein

[-- Attachment #1: Type: text/plain, Size: 740 bytes --]

Hi all,

Today's linux-next merge of the rust tree got a conflict in:

  rust/kernel/sync/poll.rs

between commit:

  6efbf978891b ("poll: rust: allow poll_table ptrs to be null")

from the vfs-brauner tree and commit:

  fcad9bbf9e1a ("rust: enable `clippy::ptr_as_ptr` lint")

from the rust tree.

I fixed it up (I used the former change) 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

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: linux-next: manual merge of the rust tree with the vfs-brauner tree
  2025-06-24  6:23 linux-next: manual merge of the rust tree with the vfs-brauner tree Stephen Rothwell
@ 2025-06-24  8:54 ` Miguel Ojeda
  0 siblings, 0 replies; 7+ messages in thread
From: Miguel Ojeda @ 2025-06-24  8:54 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Miguel Ojeda, Christian Brauner, Alice Ryhl,
	Linux Kernel Mailing List, Linux Next Mailing List,
	Tamir Duberstein

On Tue, Jun 24, 2025 at 8:23 AM Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> I fixed it up (I used the former change) and can carry the fix as
> necessary.

Looks good to me, thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-06-24  8:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-24  6:23 linux-next: manual merge of the rust tree with the vfs-brauner tree Stephen Rothwell
2025-06-24  8:54 ` Miguel Ojeda
  -- strict thread matches above, loose matches on Subject: below --
2024-11-11  6:29 Stephen Rothwell
2024-11-11 23:57 ` Miguel Ojeda
2024-10-08  5:56 Stephen Rothwell
2024-10-04  4:42 Stephen Rothwell
2024-10-04  9:25 ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).