From: Linus Torvalds > Sent: 23 October 2024 21:08 > > On Wed, 23 Oct 2024 at 12:17, Linus Torvalds > <torva...@linux-foundation.org> wrote: > > > > NOTE! This is obviously untested and I didn't check that it does the > > cmp/sbb/or the right way around. > > Well, it boots. The code generation (from strncpy_from_user()) seems ok: > > movabs $0x123456789abcdef,%rcx > cmp %rsi,%rcx > sbb %ecx,%ecx > or %rsi,%rcx > > where obviously that constant is the bogus pre-initialized value, not > the actual runtime value.
Would it be better to make the 'bogus' constant one that makes all accesses fail? So you soon find out it any code doesn't get patched. I also wonder how big the table of addresses to patch is. If that gets into inlined functions it could be big. OTOH having a real function that does access_ok(), clac and address masking may not problem. Especially if there is always a (PAGE sized) gap between the highest user address and the lowest kernel address so the 'size' argument to access_ok() can be ignored on the assumption that the accesses are (reasonably) linear. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)