From: Philipp R. <pr...@pa...> - 2000-11-11 14:50:04
|
On Sat, Nov 11, 2000 at 10:59:04AM +0900, NIIBE Yutaka wrote: > Jesper Skov wrote: > > The below patch is based on an old patch from Philipp Rumpf. It allows > > the kernel to make unaligned access if it should happen to think that > > it a good thing to do. > > Thanks, installed. I think the patch leaves a security hole: if you put_user to an unaligned invalid address, the kernel will oops. The fix is something like (optimized for code size not speed) static inline void unaligned_memcpy(void *dst, void *src, int count, struct pt_regs *regs) { int failed; while(count--) { asm volatile(" 1: mov.b @(%2),%0 bra 4f 2: mov.b %0,@(%3) 3: mov #1,%1 4: .section __ex_table,\"a\" .long 1b,2b .previous" : "=r" (tmp), "=r" (failed) : "r" (dst++), "r" (src++), "0" (0), "1" (0)); if (failed) { die_if_no_fixup("invalid unaligned access", regs, ???); return; } } } (my apologies for the ugly code). An alternative fix, and one which I think I like better, is to try the search_exception_table before doing any unaligned handling - unaligned userspace pointers aren't the kernel's job to deal with. |