public inbox for linux-next@vger.kernel.org 
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb•auug.org.au>
To: Miguel Ojeda <ojeda@kernel•org>, Christian Brauner <brauner@kernel•org>
Cc: Alice Ryhl <aliceryhl@google•com>,
	Aliet Exposito Garcia <aliet.exposito@gmail•com>,
	Linux Kernel Mailing List <linux-kernel@vger•kernel.org>,
	Linux Next Mailing List <linux-next@vger•kernel.org>
Subject: linux-next: manual merge of the rust tree with the vfs-brauner tree
Date: Tue, 8 Oct 2024 16:56:36 +1100	[thread overview]
Message-ID: <20241008165636.0e8d0d4e@canb.auug.org.au> (raw)

[-- 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 --]

             reply	other threads:[~2024-10-08  5:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-08  5:56 Stephen Rothwell [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-09-16 13:30 linux-next: manual merge of the rust tree with the vfs-brauner tree Mark Brown
2025-09-16 13:45 ` Miguel Ojeda
2025-06-24  6:23 Stephen Rothwell
2025-06-24  8:54 ` Miguel Ojeda
2024-11-11  6:29 Stephen Rothwell
2024-11-11 23:57 ` Miguel Ojeda
2024-10-04  4:42 Stephen Rothwell
2024-10-04  9:25 ` 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=20241008165636.0e8d0d4e@canb.auug.org.au \
    --to=sfr@canb$(echo .)auug.org.au \
    --cc=aliceryhl@google$(echo .)com \
    --cc=aliet.exposito@gmail$(echo .)com \
    --cc=brauner@kernel$(echo .)org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linux-next@vger$(echo .)kernel.org \
    --cc=ojeda@kernel$(echo .)org \
    /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