Re: [PATCH v5] rust: alloc: satisfy POSIX alignment requirement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 12, 2025 at 03:47:11PM -0500, Tamir Duberstein wrote:
> Looks like I wasn't the only one to fall into the trap (rust/kernel/io.rs):
> 
>     #[inline]
>     const fn io_addr_assert<U>(&self, offset: usize) -> usize {
>         build_assert!(Self::offset_valid::<U>(offset, SIZE));
> 
>         self.addr() + offset
>     }
> 
> since offset isn't known at compile time, this can easily be misused?

Well, that's intentional.

iomem.readb(0x0)     // succeeds if SIZE >=1
iomem.readb(foo)     // fails if foo is not known at compile time
iomem.try_readb(foo) // succeeds if self.maxsize() >= 1




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux