]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.14.38/virtio_net-fix-adding-vids-on-big-endian.patch
Linux 4.9.167
[thirdparty/kernel/stable-queue.git] / releases / 4.14.38 / virtio_net-fix-adding-vids-on-big-endian.patch
CommitLineData
ea254054
GKH
1From foo@baz Thu Apr 26 20:47:12 CEST 2018
2From: "Michael S. Tsirkin" <mst@redhat.com>
3Date: Thu, 19 Apr 2018 08:30:49 +0300
4Subject: virtio_net: fix adding vids on big-endian
5
6From: "Michael S. Tsirkin" <mst@redhat.com>
7
8
9[ Upstream commit d7fad4c840f33a6bd333dd7fbb3006edbcf0017a ]
10
11Programming vids (adding or removing them) still passes
12guest-endian values in the DMA buffer. That's wrong
13if guest is big-endian and when virtio 1 is enabled.
14
15Note: this is on top of a previous patch:
16 virtio_net: split out ctrl buffer
17
18Fixes: 9465a7a6f ("virtio_net: enable v1.0 support")
19Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
20Acked-by: Jason Wang <jasowang@redhat.com>
21Signed-off-by: David S. Miller <davem@davemloft.net>
22Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23---
24 drivers/net/virtio_net.c | 6 +++---
25 1 file changed, 3 insertions(+), 3 deletions(-)
26
27--- a/drivers/net/virtio_net.c
28+++ b/drivers/net/virtio_net.c
29@@ -123,7 +123,7 @@ struct control_buf {
30 struct virtio_net_ctrl_mq mq;
31 u8 promisc;
32 u8 allmulti;
33- u16 vid;
34+ __virtio16 vid;
35 u64 offloads;
36 };
37
38@@ -1602,7 +1602,7 @@ static int virtnet_vlan_rx_add_vid(struc
39 struct virtnet_info *vi = netdev_priv(dev);
40 struct scatterlist sg;
41
42- vi->ctrl->vid = vid;
43+ vi->ctrl->vid = cpu_to_virtio16(vi->vdev, vid);
44 sg_init_one(&sg, &vi->ctrl->vid, sizeof(vi->ctrl->vid));
45
46 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN,
47@@ -1617,7 +1617,7 @@ static int virtnet_vlan_rx_kill_vid(stru
48 struct virtnet_info *vi = netdev_priv(dev);
49 struct scatterlist sg;
50
51- vi->ctrl->vid = vid;
52+ vi->ctrl->vid = cpu_to_virtio16(vi->vdev, vid);
53 sg_init_one(&sg, &vi->ctrl->vid, sizeof(vi->ctrl->vid));
54
55 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN,