]> git.baikalelectronics.ru Git - kernel.git/commit
virtio: force spec specified alignment on types
authorMichael S. Tsirkin <mst@redhat.com>
Mon, 6 Apr 2020 12:42:55 +0000 (08:42 -0400)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 2 Jun 2020 06:45:13 +0000 (02:45 -0400)
commit00da675c744d47ed7e8ffbb8e18f65855c6e8bbf
tree9c011e62fb646049f2b37002725f98b4654d0c08
parent209caf03c339ca5080435105304e8dbdc58c2c53
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>
drivers/vhost/vhost.c
drivers/vhost/vhost.h
drivers/vhost/vringh.c
include/linux/vringh.h
include/uapi/linux/virtio_ring.h