Message ID | 20221023174307.1868939-1-pbonzini@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [GIT,PULL] KVM patches for Linux 6.1-rc2 | expand |
On Sun, Oct 23, 2022 at 10:43 AM Paolo Bonzini <pbonzini@redhat.com> wrote: > > x86: > > - add compat implementation for KVM_X86_SET_MSR_FILTER ioctl Side note: this should probably have used compat_uptr_t bitmap; ... .bitmap = compat_ptr(cr->bitmap), instead of doing that __u32 bitmap; ... .bitmap = (__u8 *)(ulong)cr->bitmap, because not only are those casts really ugly, using that 'compat_uptr_t" and "compat_ptr()" helper also really explains what is going on. compat_ptr() also happens to get the address space right (ie it returns a "void __user *" pointer). But since the non-compat 'struct kvm_msr_filter_range' bitmap member doesn't get that right either (because it uses the same type for kernel pointers as for user pointers - ugly uglt), that isn't such a big deal. The kvm code clearly doesn't do proper user pointer typing, and just uses random casts instead. Linus
The pull request you sent on Sun, 23 Oct 2022 13:43:07 -0400:
> https://git.kernel.org/pub/scm/virt/kvm/kvm.git tags/for-linus
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/05b4ebd2c7cbb3671c376754b37b4963dd08a3a2
Thank you!
On 10/24/22 00:15, Linus Torvalds wrote: > > compat_ptr() also happens to get the address space right (ie it > returns a "void __user *" pointer). But since the non-compat 'struct > kvm_msr_filter_range' bitmap member doesn't get that right either > (because it uses the same type for kernel pointers as for user > pointers - ugly uglt), that isn't such a big deal. The kvm code > clearly doesn't do proper user pointer typing, and just uses random > casts instead. In general KVM ioctl arguments very rarely have __user pointers in them, so there's not much need for compat ioctls at all. KVM_GET_DIRTY_LOG and KVM_CLEAR_DIRTY_LOG get it right, but this one indeed can be improved with compat_ptr(). Will do for 6.2, thanks for the review. Paolo