Skip to content

Commit

Permalink
KVM: Add a comment describing the /dev/kvm no_compat handling
Browse files Browse the repository at this point in the history
Add a comment explaining the rational behind having both
no_compat open and ioctl callbacks to fend off compat tasks.

Signed-off-by: Marc Zyngier <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
Marc Zyngier authored and bonzini committed Nov 15, 2019
1 parent ed69a6c commit 9cb09e7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ static long kvm_vcpu_compat_ioctl(struct file *file, unsigned int ioctl,
unsigned long arg);
#define KVM_COMPAT(c) .compat_ioctl = (c)
#else
/*
* For architectures that don't implement a compat infrastructure,
* adopt a double line of defense:
* - Prevent a compat task from opening /dev/kvm
* - If the open has been done by a 64bit task, and the KVM fd
* passed to a compat task, let the ioctls fail.
*/
static long kvm_no_compat_ioctl(struct file *file, unsigned int ioctl,
unsigned long arg) { return -EINVAL; }

Expand Down

0 comments on commit 9cb09e7

Please sign in to comment.