In particular, the
call to __ubsan_handle_load_invalid_value() with UACCESS enabled
warnings tend to be a real sign that somebody is doing something very
wrong inside a user access region, and kvm seems to be buggy here.
In particular, kvm does
#define emulator_try_cmpxchg_user(t, ptr, old, new) \
(__try_cmpxchg_user((t __user *)(ptr), (t *)(old), *(t
*)(new), efault ## t))
and look at that third argument: "*(t *)(new)". It is doing a pointer
dereference [...] inside the __uaccess_begin_nospec()/__uaccess_end()
region [...] and *both* of those lines are buggy, since they both do memory accesses that are not to user space [...] We also do have that
if (unlikely(!success))
*_old = __old;
inside __try_cmpxchg_user_asm after the actual asm that also seems
buggy and wrong for the exact same reason - it shouldn't be done
within the STAC region.
Comments? I think those old/new things should be moved out one macro
level, and be done inside __try_cmpxchg_user() itself, outside the
uaccess region.
That may require some games for the end-game where we do that "assign
the _old value", and maybe the __uaccess_end needs to be moved into
the success case. But it would be good to do this right. No?