Re: [PATCH] x86/uaccess: Implement get_kernel()
From: Peter Zijlstra
Date: Fri Apr 10 2015 - 07:34:34 EST
On Fri, Apr 10, 2015 at 01:14:27PM +0200, Ingo Molnar wrote:
> +/*
> + * Simple copy-from-possibly-faulting-kernel-addresses method that
> + * avoids the STAC/CLAC SMAP overhead.
> + *
> + * NOTE: this does not propagate the error code of faulting kernel
> + * addresses properly. You can recover it via uaccess_catch()
> + * if you really need to.
> + */
> +#define get_kernel(dst, src) \
> +do { \
> + typeof(*(src)) __val; \
Should we make that:
typeof(*(src)) __val = (dst);
> + \
> + switch (sizeof(__val)) { \
> + case 1: __get_kernel_asm_ex(__val, src, "b", "b", "=q"); break; \
> + case 2: __get_kernel_asm_ex(__val, src, "w", "w", "=r"); break; \
> + case 4: __get_kernel_asm_ex(__val, src, "l", "k", "=r"); break; \
> + case 8: __get_kernel_asm_ex(__val, src, "q", " ", "=r"); break; \
> + default: __get_kernel_BUILD_ERROR(); \
> + } \
> + (dst) = __val; \
> +} while (0)
Such that when we fault, the value is unmodified? The way it is we'll
assign whatever was on stack for __val, which seems undesirable, no?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/