Rust and UB
Rust and UB
Posted Aug 15, 2024 23:50 UTC (Thu) by tialaramex (subscriber, #21167)In reply to: Rust and UB by pbonzini
Parent article: Standards for use of unsafe Rust in the kernel
In practice the LInux kernel cannot assume whatever nonsense it got from userspace is really a pointer.
At best it's an address, a large integer. So, we've got an address. We check this address meets all our rules (it's in the right part of the memory etc.) and then I think Aria's ptr::with_addr lets us turn a (copy of a) pointer we kept for this purpose (e.g. pointing into the userspace memory of the process that called us) into a pointer to the specific address requested. If so that's not Undefined Behaviour.
