diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2020-04-06 14:42:55 +0200 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2020-06-02 08:45:13 +0200 |
commit | a865e420b9561235851c3f5d483c82ef389d29bd (patch) | |
tree | 9c011e62fb646049f2b37002725f98b4654d0c08 /drivers/vhost/vringh.c | |
parent | virtio-mmio: Delete an error message in vm_find_vqs() (diff) | |
download | linux-a865e420b9561235851c3f5d483c82ef389d29bd.tar.xz linux-a865e420b9561235851c3f5d483c82ef389d29bd.zip |
virtio: force spec specified alignment on types
The ring element addresses are passed between components with different
alignments assumptions. Thus, if guest/userspace selects a pointer and
host then gets and dereferences it, we might need to decrease the
compiler-selected alignment to prevent compiler on the host from
assuming pointer is aligned.
This actually triggers on ARM with -mabi=apcs-gnu - which is a
deprecated configuration, but it seems safer to handle this
generally.
Note that userspace that allocates the memory is actually OK and does
not need to be fixed, but userspace that gets it from guest or another
process does need to be fixed. The later doesn't generally talk to the
kernel so while it might be buggy it's not talking to the kernel in the
buggy way - it's just using the header in the buggy way - so fixing
header and asking userspace to recompile is the best we can do.
I verified that the produced kernel binary on x86 is exactly identical
before and after the change.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'drivers/vhost/vringh.c')
-rw-r--r-- | drivers/vhost/vringh.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c index ba8e0d6cfd97..e059a9a47cdf 100644 --- a/drivers/vhost/vringh.c +++ b/drivers/vhost/vringh.c @@ -620,9 +620,9 @@ static inline int xfer_to_user(const struct vringh *vrh, */ int vringh_init_user(struct vringh *vrh, u64 features, unsigned int num, bool weak_barriers, - struct vring_desc __user *desc, - struct vring_avail __user *avail, - struct vring_used __user *used) + vring_desc_t __user *desc, + vring_avail_t __user *avail, + vring_used_t __user *used) { /* Sane power of 2 please! */ if (!num || num > 0xffff || (num & (num - 1))) { |