1
The following changes since commit 23895cbd82be95428e90168b12e925d0d3ca2f06:
1
The following changes since commit bdee969c0e65d4d509932b1d70e3a3b2ffbff6d5:
2
2
3
Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20201123.0' into staging (2020-11-23 18:51:13 +0000)
3
Merge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' into staging (2021-03-19 18:01:17 +0000)
4
4
5
are available in the git repository at:
5
are available in the git repository at:
6
6
7
https://github.com/jasowang/qemu.git tags/net-pull-request
7
https://github.com/jasowang/qemu.git tags/net-pull-request
8
8
9
for you to fetch changes up to 9925990d01a92564af55f6f69d0f5f59b47609b1:
9
for you to fetch changes up to c7274b5ef43614dd133daec1e2018f71d8744088:
10
10
11
net: Use correct default-path macro for downscript (2020-11-24 10:40:17 +0800)
11
net/eth: Add an assert() and invert if() statement to simplify code (2021-03-22 17:34:31 +0800)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
14
15
----------------------------------------------------------------
15
----------------------------------------------------------------
16
Keqian Zhu (1):
16
Bin Meng (4):
17
net: Use correct default-path macro for downscript
17
net: eth: Add a helper to pad a short Ethernet frame
18
net: Add a 'do_not_pad" to NetClientState
19
net: Pad short frames to minimum size before sending from SLiRP/TAP
20
hw/net: virtio-net: Initialize nc->do_not_pad to true
18
21
19
Paolo Bonzini (1):
22
Lukas Straub (2):
20
net: do not exit on "netdev_add help" monitor command
23
net/colo-compare.c: Fix memory leak for non-tcp packet
24
net/colo-compare.c: Optimize removal of secondary packet
21
25
22
Prasad J Pandit (1):
26
Philippe Mathieu-Daudé (7):
23
hw/net/e1000e: advance desc_offset in case of null descriptor
27
net/eth: Use correct in6_address offset in _eth_get_rss_ex_dst_addr()
28
net/eth: Simplify _eth_get_rss_ex_dst_addr()
29
net/eth: Better describe _eth_get_rss_ex_dst_addr's offset argument
30
net/eth: Check size earlier in _eth_get_rss_ex_dst_addr()
31
net/eth: Check iovec has enough data earlier
32
net/eth: Read ip6_ext_hdr_routing buffer before accessing it
33
net/eth: Add an assert() and invert if() statement to simplify code
24
34
25
Yuri Benditovich (1):
35
MAINTAINERS | 1 +
26
net: purge queued rx packets on queue deletion
36
hw/net/virtio-net.c | 4 +++
27
37
include/net/eth.h | 17 ++++++++++++
28
yuanjungong (1):
38
include/net/net.h | 1 +
29
tap: fix a memory leak
39
net/colo-compare.c | 3 ++-
30
40
net/eth.c | 61 +++++++++++++++++++++++++++---------------
31
hw/net/e1000e_core.c | 8 +++---
41
net/slirp.c | 10 +++++++
32
include/net/net.h | 1 +
42
net/tap-win32.c | 10 +++++++
33
monitor/hmp-cmds.c | 6 ++++
43
net/tap.c | 10 +++++++
34
net/net.c | 80 +++++++++++++++++++++++++++-------------------------
44
tests/qtest/fuzz-e1000e-test.c | 53 ++++++++++++++++++++++++++++++++++++
35
net/tap.c | 5 +++-
45
tests/qtest/meson.build | 1 +
36
5 files changed, 57 insertions(+), 43 deletions(-)
46
11 files changed, 148 insertions(+), 23 deletions(-)
47
create mode 100644 tests/qtest/fuzz-e1000e-test.c
37
48
38
49
diff view generated by jsdifflib
New patch
1
From: Bin Meng <bmeng.cn@gmail.com>
1
2
3
Add a helper to pad a short Ethernet frame to the minimum required
4
length, which can be used by backends' code.
5
6
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Signed-off-by: Jason Wang <jasowang@redhat.com>
9
---
10
include/net/eth.h | 17 +++++++++++++++++
11
net/eth.c | 17 +++++++++++++++++
12
2 files changed, 34 insertions(+)
13
14
diff --git a/include/net/eth.h b/include/net/eth.h
15
index XXXXXXX..XXXXXXX 100644
16
--- a/include/net/eth.h
17
+++ b/include/net/eth.h
18
@@ -XXX,XX +XXX,XX @@
19
20
#define ETH_ALEN 6
21
#define ETH_HLEN 14
22
+#define ETH_ZLEN 60 /* Min. octets in frame without FCS */
23
24
struct eth_header {
25
uint8_t h_dest[ETH_ALEN]; /* destination eth addr */
26
@@ -XXX,XX +XXX,XX @@ bool
27
eth_parse_ipv6_hdr(const struct iovec *pkt, int pkt_frags,
28
size_t ip6hdr_off, eth_ip6_hdr_info *info);
29
30
+/**
31
+ * eth_pad_short_frame - pad a short frame to the minimum Ethernet frame length
32
+ *
33
+ * If the Ethernet frame size is shorter than 60 bytes, it will be padded to
34
+ * 60 bytes at the address @padded_pkt.
35
+ *
36
+ * @padded_pkt: buffer address to hold the padded frame
37
+ * @padded_buflen: pointer holding length of @padded_pkt. If the frame is
38
+ * padded, the length will be updated to the padded one.
39
+ * @pkt: address to hold the original Ethernet frame
40
+ * @pkt_size: size of the original Ethernet frame
41
+ * @return true if the frame is padded, otherwise false
42
+ */
43
+bool eth_pad_short_frame(uint8_t *padded_pkt, size_t *padded_buflen,
44
+ const void *pkt, size_t pkt_size);
45
+
46
#endif
47
diff --git a/net/eth.c b/net/eth.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/net/eth.c
50
+++ b/net/eth.c
51
@@ -XXX,XX +XXX,XX @@ bool eth_parse_ipv6_hdr(const struct iovec *pkt, int pkt_frags,
52
info->l4proto = ext_hdr.ip6r_nxt;
53
return true;
54
}
55
+
56
+bool eth_pad_short_frame(uint8_t *padded_pkt, size_t *padded_buflen,
57
+ const void *pkt, size_t pkt_size)
58
+{
59
+ assert(padded_buflen && *padded_buflen >= ETH_ZLEN);
60
+
61
+ if (pkt_size >= ETH_ZLEN) {
62
+ return false;
63
+ }
64
+
65
+ /* pad to minimum Ethernet frame length */
66
+ memcpy(padded_pkt, pkt, pkt_size);
67
+ memset(&padded_pkt[pkt_size], 0, ETH_ZLEN - pkt_size);
68
+ *padded_buflen = ETH_ZLEN;
69
+
70
+ return true;
71
+}
72
--
73
2.7.4
74
75
diff view generated by jsdifflib
1
From: Paolo Bonzini <pbonzini@redhat.com>
1
From: Bin Meng <bmeng.cn@gmail.com>
2
2
3
"netdev_add help" is causing QEMU to exit because the code that
3
This adds a flag in NetClientState, so that a net client can tell
4
invokes show_netdevs is shared between CLI and HMP processing.
4
its peer that the packets do not need to be padded to the minimum
5
Move the check to the callers so that exit(0) remains only
5
size of an Ethernet frame (60 bytes) before sending to it.
6
in the CLI flow.
7
6
8
"netdev_add help" is not fixed by this patch; that is left for
7
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
9
later work.
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
11
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
12
Signed-off-by: Jason Wang <jasowang@redhat.com>
9
Signed-off-by: Jason Wang <jasowang@redhat.com>
13
---
10
---
14
include/net/net.h | 1 +
11
include/net/net.h | 1 +
15
monitor/hmp-cmds.c | 6 +++++
12
1 file changed, 1 insertion(+)
16
net/net.c | 68 +++++++++++++++++++++++++++---------------------------
17
3 files changed, 41 insertions(+), 34 deletions(-)
18
13
19
diff --git a/include/net/net.h b/include/net/net.h
14
diff --git a/include/net/net.h b/include/net/net.h
20
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
21
--- a/include/net/net.h
16
--- a/include/net/net.h
22
+++ b/include/net/net.h
17
+++ b/include/net/net.h
23
@@ -XXX,XX +XXX,XX @@ extern const char *host_net_devices[];
18
@@ -XXX,XX +XXX,XX @@ struct NetClientState {
24
19
int vring_enable;
25
/* from net.c */
20
int vnet_hdr_len;
26
int net_client_parse(QemuOptsList *opts_list, const char *str);
21
bool is_netdev;
27
+void show_netdevs(void);
22
+ bool do_not_pad; /* do not pad to the minimum ethernet frame length */
28
int net_init_clients(Error **errp);
23
QTAILQ_HEAD(, NetFilterState) filters;
29
void net_check_clients(void);
24
};
30
void net_cleanup(void);
31
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/monitor/hmp-cmds.c
34
+++ b/monitor/hmp-cmds.c
35
@@ -XXX,XX +XXX,XX @@
36
#include "qemu/option.h"
37
#include "qemu/timer.h"
38
#include "qemu/sockets.h"
39
+#include "qemu/help_option.h"
40
#include "monitor/monitor-internal.h"
41
#include "qapi/error.h"
42
#include "qapi/clone-visitor.h"
43
@@ -XXX,XX +XXX,XX @@ void hmp_netdev_add(Monitor *mon, const QDict *qdict)
44
{
45
Error *err = NULL;
46
QemuOpts *opts;
47
+ const char *type = qdict_get_try_str(qdict, "type");
48
49
+ if (type && is_help_option(type)) {
50
+ show_netdevs();
51
+ return;
52
+ }
53
opts = qemu_opts_from_qdict(qemu_find_opts("netdev"), qdict, &err);
54
if (err) {
55
goto out;
56
diff --git a/net/net.c b/net/net.c
57
index XXXXXXX..XXXXXXX 100644
58
--- a/net/net.c
59
+++ b/net/net.c
60
@@ -XXX,XX +XXX,XX @@
61
#include "qemu/config-file.h"
62
#include "qemu/ctype.h"
63
#include "qemu/iov.h"
64
+#include "qemu/qemu-print.h"
65
#include "qemu/main-loop.h"
66
#include "qemu/option.h"
67
#include "qapi/error.h"
68
@@ -XXX,XX +XXX,XX @@ static int net_client_init1(const Netdev *netdev, bool is_netdev, Error **errp)
69
return 0;
70
}
71
72
-static void show_netdevs(void)
73
+void show_netdevs(void)
74
{
75
int idx;
76
const char *available_netdevs[] = {
77
@@ -XXX,XX +XXX,XX @@ static void show_netdevs(void)
78
#endif
79
};
80
81
- printf("Available netdev backend types:\n");
82
+ qemu_printf("Available netdev backend types:\n");
83
for (idx = 0; idx < ARRAY_SIZE(available_netdevs); idx++) {
84
- puts(available_netdevs[idx]);
85
+ qemu_printf("%s\n", available_netdevs[idx]);
86
}
87
}
88
89
@@ -XXX,XX +XXX,XX @@ static int net_client_init(QemuOpts *opts, bool is_netdev, Error **errp)
90
int ret = -1;
91
Visitor *v = opts_visitor_new(opts);
92
93
- const char *type = qemu_opt_get(opts, "type");
94
-
95
- if (is_netdev && type && is_help_option(type)) {
96
- show_netdevs();
97
- exit(0);
98
- } else {
99
- /* Parse convenience option format ip6-net=fec0::0[/64] */
100
- const char *ip6_net = qemu_opt_get(opts, "ipv6-net");
101
+ /* Parse convenience option format ip6-net=fec0::0[/64] */
102
+ const char *ip6_net = qemu_opt_get(opts, "ipv6-net");
103
104
- if (ip6_net) {
105
- char *prefix_addr;
106
- unsigned long prefix_len = 64; /* Default 64bit prefix length. */
107
+ if (ip6_net) {
108
+ char *prefix_addr;
109
+ unsigned long prefix_len = 64; /* Default 64bit prefix length. */
110
111
- substrings = g_strsplit(ip6_net, "/", 2);
112
- if (!substrings || !substrings[0]) {
113
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "ipv6-net",
114
- "a valid IPv6 prefix");
115
- goto out;
116
- }
117
+ substrings = g_strsplit(ip6_net, "/", 2);
118
+ if (!substrings || !substrings[0]) {
119
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "ipv6-net",
120
+ "a valid IPv6 prefix");
121
+ goto out;
122
+ }
123
124
- prefix_addr = substrings[0];
125
+ prefix_addr = substrings[0];
126
127
- /* Handle user-specified prefix length. */
128
- if (substrings[1] &&
129
- qemu_strtoul(substrings[1], NULL, 10, &prefix_len))
130
- {
131
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
132
- "ipv6-prefixlen", "a number");
133
- goto out;
134
- }
135
-
136
- qemu_opt_set(opts, "ipv6-prefix", prefix_addr, &error_abort);
137
- qemu_opt_set_number(opts, "ipv6-prefixlen", prefix_len,
138
- &error_abort);
139
- qemu_opt_unset(opts, "ipv6-net");
140
+ /* Handle user-specified prefix length. */
141
+ if (substrings[1] &&
142
+ qemu_strtoul(substrings[1], NULL, 10, &prefix_len))
143
+ {
144
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
145
+ "ipv6-prefixlen", "a number");
146
+ goto out;
147
}
148
+
149
+ qemu_opt_set(opts, "ipv6-prefix", prefix_addr, &error_abort);
150
+ qemu_opt_set_number(opts, "ipv6-prefixlen", prefix_len,
151
+ &error_abort);
152
+ qemu_opt_unset(opts, "ipv6-net");
153
}
154
155
/* Create an ID for -net if the user did not specify one */
156
@@ -XXX,XX +XXX,XX @@ static int net_init_client(void *dummy, QemuOpts *opts, Error **errp)
157
158
static int net_init_netdev(void *dummy, QemuOpts *opts, Error **errp)
159
{
160
+ const char *type = qemu_opt_get(opts, "type");
161
+
162
+ if (type && is_help_option(type)) {
163
+ show_netdevs();
164
+ exit(0);
165
+ }
166
return net_client_init(opts, true, errp);
167
}
168
25
169
--
26
--
170
2.7.4
27
2.7.4
171
28
172
29
diff view generated by jsdifflib
1
From: yuanjungong <ruc_gongyuanjun@163.com>
1
From: Bin Meng <bmeng.cn@gmail.com>
2
2
3
Close fd before returning.
3
The minimum Ethernet frame length is 60 bytes. For short frames with
4
smaller length like ARP packets (only 42 bytes), on a real world NIC
5
it can choose either padding its length to the minimum required 60
6
bytes, or sending it out directly to the wire. Such behavior can be
7
hardcoded or controled by a register bit. Similarly on the receive
8
path, NICs can choose either dropping such short frames directly or
9
handing them over to software to handle.
4
10
5
Buglink: https://bugs.launchpad.net/qemu/+bug/1904486
11
On the other hand, for the network backends like SLiRP/TAP, they
12
don't expose a way to control the short frame behavior. As of today
13
they just send/receive data from/to the other end connected to them,
14
which means any sized packet is acceptable. So they can send and
15
receive short frames without any problem. It is observed that ARP
16
packets sent from SLiRP/TAP are 42 bytes, and SLiRP/TAP just send
17
these ARP packets to the other end which might be a NIC model that
18
does not allow short frames to pass through.
6
19
7
Signed-off-by: yuanjungong <ruc_gongyuanjun@163.com>
20
To provide better compatibility, for packets sent from QEMU network
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
21
backends like SLiRP/TAP, we change to pad short frames before sending
22
it out to the other end, if the other end does not forbid it via the
23
nc->do_not_pad flag. This ensures a backend as an Ethernet sender
24
does not violate the spec. But with this change, the behavior of
25
dropping short frames from SLiRP/TAP interfaces in the NIC model
26
cannot be emulated because it always receives a packet that is spec
27
complaint. The capability of sending short frames from NIC models is
28
still supported and short frames can still pass through SLiRP/TAP.
29
30
This commit should be able to fix the issue as reported with some
31
NIC models before, that ARP requests get dropped, preventing the
32
guest from becoming visible on the network. It was workarounded in
33
these NIC models on the receive path, that when a short frame is
34
received, it is padded up to 60 bytes.
35
36
The following 2 commits seem to be the one to workaround this issue
37
in e1000 and vmxenet3 before, and should probably be reverted.
38
39
commit 78aeb23eded2 ("e1000: Pad short frames to minimum size (60 bytes)")
40
commit 40a87c6c9b11 ("vmxnet3: Pad short frames to minimum size (60 bytes)")
41
42
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
43
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Signed-off-by: Jason Wang <jasowang@redhat.com>
44
Signed-off-by: Jason Wang <jasowang@redhat.com>
10
---
45
---
11
net/tap.c | 2 ++
46
net/slirp.c | 10 ++++++++++
12
1 file changed, 2 insertions(+)
47
net/tap-win32.c | 10 ++++++++++
48
net/tap.c | 10 ++++++++++
49
3 files changed, 30 insertions(+)
13
50
51
diff --git a/net/slirp.c b/net/slirp.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/net/slirp.c
54
+++ b/net/slirp.c
55
@@ -XXX,XX +XXX,XX @@
56
#include <pwd.h>
57
#include <sys/wait.h>
58
#endif
59
+#include "net/eth.h"
60
#include "net/net.h"
61
#include "clients.h"
62
#include "hub.h"
63
@@ -XXX,XX +XXX,XX @@ static ssize_t net_slirp_send_packet(const void *pkt, size_t pkt_len,
64
void *opaque)
65
{
66
SlirpState *s = opaque;
67
+ uint8_t min_pkt[ETH_ZLEN];
68
+ size_t min_pktsz = sizeof(min_pkt);
69
+
70
+ if (!s->nc.peer->do_not_pad) {
71
+ if (eth_pad_short_frame(min_pkt, &min_pktsz, pkt, pkt_len)) {
72
+ pkt = min_pkt;
73
+ pkt_len = min_pktsz;
74
+ }
75
+ }
76
77
return qemu_send_packet(&s->nc, pkt, pkt_len);
78
}
79
diff --git a/net/tap-win32.c b/net/tap-win32.c
80
index XXXXXXX..XXXXXXX 100644
81
--- a/net/tap-win32.c
82
+++ b/net/tap-win32.c
83
@@ -XXX,XX +XXX,XX @@
84
85
#include "qemu-common.h"
86
#include "clients.h" /* net_init_tap */
87
+#include "net/eth.h"
88
#include "net/net.h"
89
#include "net/tap.h" /* tap_has_ufo, ... */
90
#include "qemu/error-report.h"
91
@@ -XXX,XX +XXX,XX @@ static void tap_win32_send(void *opaque)
92
uint8_t *buf;
93
int max_size = 4096;
94
int size;
95
+ uint8_t min_pkt[ETH_ZLEN];
96
+ size_t min_pktsz = sizeof(min_pkt);
97
98
size = tap_win32_read(s->handle, &buf, max_size);
99
if (size > 0) {
100
+ if (!s->nc.peer->do_not_pad) {
101
+ if (eth_pad_short_frame(min_pkt, &min_pktsz, buf, size)) {
102
+ buf = min_pkt;
103
+ size = min_pktsz;
104
+ }
105
+ }
106
+
107
qemu_send_packet(&s->nc, buf, size);
108
tap_win32_free_buffer(s->handle, buf);
109
}
14
diff --git a/net/tap.c b/net/tap.c
110
diff --git a/net/tap.c b/net/tap.c
15
index XXXXXXX..XXXXXXX 100644
111
index XXXXXXX..XXXXXXX 100644
16
--- a/net/tap.c
112
--- a/net/tap.c
17
+++ b/net/tap.c
113
+++ b/net/tap.c
18
@@ -XXX,XX +XXX,XX @@ int net_init_tap(const Netdev *netdev, const char *name,
114
@@ -XXX,XX +XXX,XX @@
19
if (ret < 0) {
115
#include <sys/socket.h>
20
error_setg_errno(errp, -ret, "%s: Can't use file descriptor %d",
116
#include <net/if.h>
21
name, fd);
117
22
+ close(fd);
118
+#include "net/eth.h"
23
return -1;
119
#include "net/net.h"
120
#include "clients.h"
121
#include "monitor/monitor.h"
122
@@ -XXX,XX +XXX,XX @@ static void tap_send(void *opaque)
123
124
while (true) {
125
uint8_t *buf = s->buf;
126
+ uint8_t min_pkt[ETH_ZLEN];
127
+ size_t min_pktsz = sizeof(min_pkt);
128
129
size = tap_read_packet(s->fd, s->buf, sizeof(s->buf));
130
if (size <= 0) {
131
@@ -XXX,XX +XXX,XX @@ static void tap_send(void *opaque)
132
size -= s->host_vnet_hdr_len;
24
}
133
}
25
134
26
@@ -XXX,XX +XXX,XX @@ int net_init_tap(const Netdev *netdev, const char *name,
135
+ if (!s->nc.peer->do_not_pad) {
27
vhostfdname, vnet_hdr, fd, &err);
136
+ if (eth_pad_short_frame(min_pkt, &min_pktsz, buf, size)) {
28
if (err) {
137
+ buf = min_pkt;
29
error_propagate(errp, err);
138
+ size = min_pktsz;
30
+ close(fd);
139
+ }
31
return -1;
140
+ }
32
}
141
+
33
} else if (tap->has_fds) {
142
size = qemu_send_packet_async(&s->nc, buf, size, tap_send_completed);
143
if (size == 0) {
144
tap_read_poll(s, false);
34
--
145
--
35
2.7.4
146
2.7.4
36
147
37
148
diff view generated by jsdifflib
New patch
1
From: Bin Meng <bmeng.cn@gmail.com>
1
2
3
For virtio-net, there is no need to pad the Ethernet frame size to
4
60 bytes before sending to it.
5
6
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
7
Signed-off-by: Jason Wang <jasowang@redhat.com>
8
---
9
hw/net/virtio-net.c | 4 ++++
10
1 file changed, 4 insertions(+)
11
12
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/net/virtio-net.c
15
+++ b/hw/net/virtio-net.c
16
@@ -XXX,XX +XXX,XX @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
17
object_get_typename(OBJECT(dev)), dev->id, n);
18
}
19
20
+ for (i = 0; i < n->max_queues; i++) {
21
+ n->nic->ncs[i].do_not_pad = true;
22
+ }
23
+
24
peer_test_vnet_hdr(n);
25
if (peer_has_vnet_hdr(n)) {
26
for (i = 0; i < n->max_queues; i++) {
27
--
28
2.7.4
29
30
diff view generated by jsdifflib
New patch
1
From: Lukas Straub <lukasstraub2@web.de>
1
2
3
Additional to removing the packet from the secondary queue,
4
we also need to free it.
5
6
Signed-off-by: Lukas Straub <lukasstraub2@web.de>
7
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
8
Reviewed-by: Zhang Chen <chen.zhang@intel.com>
9
Signed-off-by: Jason Wang <jasowang@redhat.com>
10
---
11
net/colo-compare.c | 1 +
12
1 file changed, 1 insertion(+)
13
14
diff --git a/net/colo-compare.c b/net/colo-compare.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/net/colo-compare.c
17
+++ b/net/colo-compare.c
18
@@ -XXX,XX +XXX,XX @@ static void colo_compare_packet(CompareState *s, Connection *conn,
19
20
if (result) {
21
colo_release_primary_pkt(s, pkt);
22
+ packet_destroy(result->data, NULL);
23
g_queue_remove(&conn->secondary_list, result->data);
24
} else {
25
/*
26
--
27
2.7.4
28
29
diff view generated by jsdifflib
New patch
1
From: Lukas Straub <lukasstraub2@web.de>
1
2
3
g_queue_remove needs to look up the list entry first, but we
4
already have it as result and can remove it directly with
5
g_queue_delete_link.
6
7
Signed-off-by: Lukas Straub <lukasstraub2@web.de>
8
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
9
Reviewed-by: Zhang Chen <chen.zhang@intel.com>
10
Signed-off-by: Jason Wang <jasowang@redhat.com>
11
---
12
net/colo-compare.c | 2 +-
13
1 file changed, 1 insertion(+), 1 deletion(-)
14
15
diff --git a/net/colo-compare.c b/net/colo-compare.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/net/colo-compare.c
18
+++ b/net/colo-compare.c
19
@@ -XXX,XX +XXX,XX @@ static void colo_compare_packet(CompareState *s, Connection *conn,
20
if (result) {
21
colo_release_primary_pkt(s, pkt);
22
packet_destroy(result->data, NULL);
23
- g_queue_remove(&conn->secondary_list, result->data);
24
+ g_queue_delete_link(&conn->secondary_list, result);
25
} else {
26
/*
27
* If one packet arrive late, the secondary_list or
28
--
29
2.7.4
30
31
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
The in6_address comes after the ip6_ext_hdr_routing header,
4
not after the ip6_ext_hdr one. Fix the offset.
5
6
Cc: qemu-stable@nongnu.org
7
Reported-by: Stefano Garzarella <sgarzare@redhat.com>
8
Fixes: eb700029c78 ("net_pkt: Extend packet abstraction as required by e1000e functionality")
9
Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com>
10
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
11
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Signed-off-by: Jason Wang <jasowang@redhat.com>
13
---
14
net/eth.c | 2 +-
15
1 file changed, 1 insertion(+), 1 deletion(-)
16
17
diff --git a/net/eth.c b/net/eth.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/net/eth.c
20
+++ b/net/eth.c
21
@@ -XXX,XX +XXX,XX @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int pkt_frags,
22
}
23
24
bytes_read = iov_to_buf(pkt, pkt_frags,
25
- rthdr_offset + sizeof(*ext_hdr),
26
+ rthdr_offset + sizeof(*rthdr),
27
dst_addr, sizeof(*dst_addr));
28
29
return bytes_read == sizeof(*dst_addr);
30
--
31
2.7.4
32
33
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
The length field is already contained in the ip6_ext_hdr structure.
4
Check it direcly in eth_parse_ipv6_hdr() before calling
5
_eth_get_rss_ex_dst_addr(), which gets a bit simplified.
6
7
Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com>
8
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
10
Signed-off-by: Jason Wang <jasowang@redhat.com>
11
---
12
net/eth.c | 14 +++++++-------
13
1 file changed, 7 insertions(+), 7 deletions(-)
14
15
diff --git a/net/eth.c b/net/eth.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/net/eth.c
18
+++ b/net/eth.c
19
@@ -XXX,XX +XXX,XX @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int pkt_frags,
20
{
21
struct ip6_ext_hdr_routing *rthdr = (struct ip6_ext_hdr_routing *) ext_hdr;
22
23
- if ((rthdr->rtype == 2) &&
24
- (rthdr->len == sizeof(struct in6_address) / 8) &&
25
- (rthdr->segleft == 1)) {
26
+ if ((rthdr->rtype == 2) && (rthdr->segleft == 1)) {
27
28
size_t input_size = iov_size(pkt, pkt_frags);
29
size_t bytes_read;
30
@@ -XXX,XX +XXX,XX @@ bool eth_parse_ipv6_hdr(const struct iovec *pkt, int pkt_frags,
31
}
32
33
if (curr_ext_hdr_type == IP6_ROUTING) {
34
- info->rss_ex_dst_valid =
35
- _eth_get_rss_ex_dst_addr(pkt, pkt_frags,
36
- ip6hdr_off + info->full_hdr_len,
37
- &ext_hdr, &info->rss_ex_dst);
38
+ if (ext_hdr.ip6r_len == sizeof(struct in6_address) / 8) {
39
+ info->rss_ex_dst_valid =
40
+ _eth_get_rss_ex_dst_addr(pkt, pkt_frags,
41
+ ip6hdr_off + info->full_hdr_len,
42
+ &ext_hdr, &info->rss_ex_dst);
43
+ }
44
} else if (curr_ext_hdr_type == IP6_DESTINATON) {
45
info->rss_ex_src_valid =
46
_eth_get_rss_ex_src_addr(pkt, pkt_frags,
47
--
48
2.7.4
49
50
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
The 'offset' argument represents the offset to the ip6_ext_hdr
4
header, rename it as 'ext_hdr_offset'.
5
6
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
7
Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com>
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Signed-off-by: Jason Wang <jasowang@redhat.com>
10
---
11
net/eth.c | 6 +++---
12
1 file changed, 3 insertions(+), 3 deletions(-)
13
14
diff --git a/net/eth.c b/net/eth.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/net/eth.c
17
+++ b/net/eth.c
18
@@ -XXX,XX +XXX,XX @@ eth_is_ip6_extension_header_type(uint8_t hdr_type)
19
20
static bool
21
_eth_get_rss_ex_dst_addr(const struct iovec *pkt, int pkt_frags,
22
- size_t rthdr_offset,
23
+ size_t ext_hdr_offset,
24
struct ip6_ext_hdr *ext_hdr,
25
struct in6_address *dst_addr)
26
{
27
@@ -XXX,XX +XXX,XX @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int pkt_frags,
28
size_t input_size = iov_size(pkt, pkt_frags);
29
size_t bytes_read;
30
31
- if (input_size < rthdr_offset + sizeof(*ext_hdr)) {
32
+ if (input_size < ext_hdr_offset + sizeof(*ext_hdr)) {
33
return false;
34
}
35
36
bytes_read = iov_to_buf(pkt, pkt_frags,
37
- rthdr_offset + sizeof(*rthdr),
38
+ ext_hdr_offset + sizeof(*rthdr),
39
dst_addr, sizeof(*dst_addr));
40
41
return bytes_read == sizeof(*dst_addr);
42
--
43
2.7.4
44
45
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
2
3
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
4
Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com>
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Signed-off-by: Jason Wang <jasowang@redhat.com>
7
---
8
net/eth.c | 14 ++++++--------
9
1 file changed, 6 insertions(+), 8 deletions(-)
10
11
diff --git a/net/eth.c b/net/eth.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/net/eth.c
14
+++ b/net/eth.c
15
@@ -XXX,XX +XXX,XX @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int pkt_frags,
16
struct in6_address *dst_addr)
17
{
18
struct ip6_ext_hdr_routing *rthdr = (struct ip6_ext_hdr_routing *) ext_hdr;
19
+ size_t input_size = iov_size(pkt, pkt_frags);
20
+ size_t bytes_read;
21
22
- if ((rthdr->rtype == 2) && (rthdr->segleft == 1)) {
23
-
24
- size_t input_size = iov_size(pkt, pkt_frags);
25
- size_t bytes_read;
26
-
27
- if (input_size < ext_hdr_offset + sizeof(*ext_hdr)) {
28
- return false;
29
- }
30
+ if (input_size < ext_hdr_offset + sizeof(*ext_hdr)) {
31
+ return false;
32
+ }
33
34
+ if ((rthdr->rtype == 2) && (rthdr->segleft == 1)) {
35
bytes_read = iov_to_buf(pkt, pkt_frags,
36
ext_hdr_offset + sizeof(*rthdr),
37
dst_addr, sizeof(*dst_addr));
38
--
39
2.7.4
40
41
diff view generated by jsdifflib
1
From: Yuri Benditovich <yuri.benditovich@daynix.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
https://bugzilla.redhat.com/show_bug.cgi?id=1829272
3
We want to check fields from ip6_ext_hdr_routing structure
4
When deleting queue pair, purge pending RX packets if any.
4
and if correct read the full in6_address. Let's directly check
5
Example of problematic flow:
5
if our iovec contains enough data for everything, else return
6
1. Bring up q35 VM with tap (vhost off) and virtio-net or e1000e
6
early.
7
2. Run ping flood to the VM NIC ( 1 ms interval)
8
3. Hot unplug the NIC device (device_del)
9
During unplug process one or more packets come, the NIC
10
can't receive, tap disables read_poll
11
4. Hot plug the device (device_add) with the same netdev
12
The tap stays with read_poll disabled and does not receive
13
any packets anymore (tap_send never triggered)
14
7
15
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
8
Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
9
Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com>
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
16
Signed-off-by: Jason Wang <jasowang@redhat.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
17
---
12
---
18
net/net.c | 12 ++++++++----
13
net/eth.c | 2 +-
19
1 file changed, 8 insertions(+), 4 deletions(-)
14
1 file changed, 1 insertion(+), 1 deletion(-)
20
15
21
diff --git a/net/net.c b/net/net.c
16
diff --git a/net/eth.c b/net/eth.c
22
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
23
--- a/net/net.c
18
--- a/net/eth.c
24
+++ b/net/net.c
19
+++ b/net/eth.c
25
@@ -XXX,XX +XXX,XX @@ void qemu_del_nic(NICState *nic)
20
@@ -XXX,XX +XXX,XX @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int pkt_frags,
26
21
size_t input_size = iov_size(pkt, pkt_frags);
27
qemu_macaddr_set_free(&nic->conf->macaddr);
22
size_t bytes_read;
28
23
29
- /* If this is a peer NIC and peer has already been deleted, free it now. */
24
- if (input_size < ext_hdr_offset + sizeof(*ext_hdr)) {
30
- if (nic->peer_deleted) {
25
+ if (input_size < ext_hdr_offset + sizeof(*rthdr) + sizeof(*dst_addr)) {
31
- for (i = 0; i < queues; i++) {
26
return false;
32
- qemu_free_net_client(qemu_get_subqueue(nic, i)->peer);
33
+ for (i = 0; i < queues; i++) {
34
+ NetClientState *nc = qemu_get_subqueue(nic, i);
35
+ /* If this is a peer NIC and peer has already been deleted, free it now. */
36
+ if (nic->peer_deleted) {
37
+ qemu_free_net_client(nc->peer);
38
+ } else if (nc->peer) {
39
+ /* if there are RX packets pending, complete them */
40
+ qemu_purge_queued_packets(nc->peer);
41
}
42
}
27
}
43
28
44
--
29
--
45
2.7.4
30
2.7.4
46
31
47
32
diff view generated by jsdifflib
1
From: Keqian Zhu <zhukeqian1@huawei.com>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
Fixes: 63c4db4c2e6d (net: relocate paths to helpers and scripts)
3
We can't know the caller read enough data in the memory pointed
4
Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
4
by ext_hdr to cast it as a ip6_ext_hdr_routing.
5
Declare rt_hdr on the stack and fill it again from the iovec.
6
7
Since we already checked there is enough data in the iovec buffer,
8
simply add an assert() call to consume the bytes_read variable.
9
10
This fix a 2 bytes buffer overrun in eth_parse_ipv6_hdr() reported
11
by QEMU fuzzer:
12
13
$ cat << EOF | ./qemu-system-i386 -M pc-q35-5.0 \
14
-accel qtest -monitor none \
15
-serial none -nographic -qtest stdio
16
outl 0xcf8 0x80001010
17
outl 0xcfc 0xe1020000
18
outl 0xcf8 0x80001004
19
outw 0xcfc 0x7
20
write 0x25 0x1 0x86
21
write 0x26 0x1 0xdd
22
write 0x4f 0x1 0x2b
23
write 0xe1020030 0x4 0x190002e1
24
write 0xe102003a 0x2 0x0807
25
write 0xe1020048 0x4 0x12077cdd
26
write 0xe1020400 0x4 0xba077cdd
27
write 0xe1020420 0x4 0x190002e1
28
write 0xe1020428 0x4 0x3509d807
29
write 0xe1020438 0x1 0xe2
30
EOF
31
=================================================================
32
==2859770==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffdef904902 at pc 0x561ceefa78de bp 0x7ffdef904820 sp 0x7ffdef904818
33
READ of size 1 at 0x7ffdef904902 thread T0
34
#0 0x561ceefa78dd in _eth_get_rss_ex_dst_addr net/eth.c:410:17
35
#1 0x561ceefa41fb in eth_parse_ipv6_hdr net/eth.c:532:17
36
#2 0x561cef7de639 in net_tx_pkt_parse_headers hw/net/net_tx_pkt.c:228:14
37
#3 0x561cef7dbef4 in net_tx_pkt_parse hw/net/net_tx_pkt.c:273:9
38
#4 0x561ceec29f22 in e1000e_process_tx_desc hw/net/e1000e_core.c:730:29
39
#5 0x561ceec28eac in e1000e_start_xmit hw/net/e1000e_core.c:927:9
40
#6 0x561ceec1baab in e1000e_set_tdt hw/net/e1000e_core.c:2444:9
41
#7 0x561ceebf300e in e1000e_core_write hw/net/e1000e_core.c:3256:9
42
#8 0x561cef3cd4cd in e1000e_mmio_write hw/net/e1000e.c:110:5
43
44
Address 0x7ffdef904902 is located in stack of thread T0 at offset 34 in frame
45
#0 0x561ceefa320f in eth_parse_ipv6_hdr net/eth.c:486
46
47
This frame has 1 object(s):
48
[32, 34) 'ext_hdr' (line 487) <== Memory access at offset 34 overflows this variable
49
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
50
(longjmp and C++ exceptions *are* supported)
51
SUMMARY: AddressSanitizer: stack-buffer-overflow net/eth.c:410:17 in _eth_get_rss_ex_dst_addr
52
Shadow bytes around the buggy address:
53
0x10003df188d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
54
0x10003df188e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
55
0x10003df188f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
56
0x10003df18900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
57
0x10003df18910: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
58
=>0x10003df18920:[02]f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
59
0x10003df18930: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
60
0x10003df18940: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
61
0x10003df18950: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
62
0x10003df18960: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
63
0x10003df18970: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
64
Shadow byte legend (one shadow byte represents 8 application bytes):
65
Addressable: 00
66
Partially addressable: 01 02 03 04 05 06 07
67
Stack left redzone: f1
68
Stack right redzone: f3
69
==2859770==ABORTING
70
71
Add the corresponding qtest case with the fuzzer reproducer.
72
73
FWIW GCC 11 similarly reported:
74
75
net/eth.c: In function 'eth_parse_ipv6_hdr':
76
net/eth.c:410:15: error: array subscript 'struct ip6_ext_hdr_routing[0]' is partly outside array bounds of 'struct ip6_ext_hdr[1]' [-Werror=array-bounds]
77
410 | if ((rthdr->rtype == 2) && (rthdr->segleft == 1)) {
78
| ~~~~~^~~~~~~
79
net/eth.c:485:24: note: while referencing 'ext_hdr'
80
485 | struct ip6_ext_hdr ext_hdr;
81
| ^~~~~~~
82
net/eth.c:410:38: error: array subscript 'struct ip6_ext_hdr_routing[0]' is partly outside array bounds of 'struct ip6_ext_hdr[1]' [-Werror=array-bounds]
83
410 | if ((rthdr->rtype == 2) && (rthdr->segleft == 1)) {
84
| ~~~~~^~~~~~~~~
85
net/eth.c:485:24: note: while referencing 'ext_hdr'
86
485 | struct ip6_ext_hdr ext_hdr;
87
| ^~~~~~~
88
89
Cc: qemu-stable@nongnu.org
90
Buglink: https://bugs.launchpad.net/qemu/+bug/1879531
91
Reported-by: Alexander Bulekov <alxndr@bu.edu>
92
Reported-by: Miroslav Rezanina <mrezanin@redhat.com>
93
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
94
Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com>
95
Fixes: eb700029c78 ("net_pkt: Extend packet abstraction as required by e1000e functionality")
96
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Signed-off-by: Jason Wang <jasowang@redhat.com>
97
Signed-off-by: Jason Wang <jasowang@redhat.com>
6
---
98
---
7
net/tap.c | 3 ++-
99
MAINTAINERS | 1 +
8
1 file changed, 2 insertions(+), 1 deletion(-)
100
net/eth.c | 13 +++++++----
9
101
tests/qtest/fuzz-e1000e-test.c | 53 ++++++++++++++++++++++++++++++++++++++++++
10
diff --git a/net/tap.c b/net/tap.c
102
tests/qtest/meson.build | 1 +
103
4 files changed, 63 insertions(+), 5 deletions(-)
104
create mode 100644 tests/qtest/fuzz-e1000e-test.c
105
106
diff --git a/MAINTAINERS b/MAINTAINERS
11
index XXXXXXX..XXXXXXX 100644
107
index XXXXXXX..XXXXXXX 100644
12
--- a/net/tap.c
108
--- a/MAINTAINERS
13
+++ b/net/tap.c
109
+++ b/MAINTAINERS
14
@@ -XXX,XX +XXX,XX @@ free_fail:
110
@@ -XXX,XX +XXX,XX @@ e1000e
15
script = default_script = get_relocated_path(DEFAULT_NETWORK_SCRIPT);
111
M: Dmitry Fleytman <dmitry.fleytman@gmail.com>
16
}
112
S: Maintained
17
if (!downscript) {
113
F: hw/net/e1000e*
18
- downscript = default_downscript = get_relocated_path(DEFAULT_NETWORK_SCRIPT);
114
+F: tests/qtest/fuzz-e1000e-test.c
19
+ downscript = default_downscript =
115
20
+ get_relocated_path(DEFAULT_NETWORK_DOWN_SCRIPT);
116
eepro100
21
}
117
M: Stefan Weil <sw@weilnetz.de>
22
118
diff --git a/net/eth.c b/net/eth.c
23
if (tap->has_ifname) {
119
index XXXXXXX..XXXXXXX 100644
120
--- a/net/eth.c
121
+++ b/net/eth.c
122
@@ -XXX,XX +XXX,XX @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int pkt_frags,
123
struct ip6_ext_hdr *ext_hdr,
124
struct in6_address *dst_addr)
125
{
126
- struct ip6_ext_hdr_routing *rthdr = (struct ip6_ext_hdr_routing *) ext_hdr;
127
+ struct ip6_ext_hdr_routing rt_hdr;
128
size_t input_size = iov_size(pkt, pkt_frags);
129
size_t bytes_read;
130
131
- if (input_size < ext_hdr_offset + sizeof(*rthdr) + sizeof(*dst_addr)) {
132
+ if (input_size < ext_hdr_offset + sizeof(rt_hdr) + sizeof(*dst_addr)) {
133
return false;
134
}
135
136
- if ((rthdr->rtype == 2) && (rthdr->segleft == 1)) {
137
- bytes_read = iov_to_buf(pkt, pkt_frags,
138
- ext_hdr_offset + sizeof(*rthdr),
139
+ bytes_read = iov_to_buf(pkt, pkt_frags, ext_hdr_offset,
140
+ &rt_hdr, sizeof(rt_hdr));
141
+ assert(bytes_read == sizeof(rt_hdr));
142
+
143
+ if ((rt_hdr.rtype == 2) && (rt_hdr.segleft == 1)) {
144
+ bytes_read = iov_to_buf(pkt, pkt_frags, ext_hdr_offset + sizeof(rt_hdr),
145
dst_addr, sizeof(*dst_addr));
146
147
return bytes_read == sizeof(*dst_addr);
148
diff --git a/tests/qtest/fuzz-e1000e-test.c b/tests/qtest/fuzz-e1000e-test.c
149
new file mode 100644
150
index XXXXXXX..XXXXXXX
151
--- /dev/null
152
+++ b/tests/qtest/fuzz-e1000e-test.c
153
@@ -XXX,XX +XXX,XX @@
154
+/*
155
+ * QTest testcase for e1000e device generated by fuzzer
156
+ *
157
+ * Copyright (c) 2021 Red Hat, Inc.
158
+ *
159
+ * SPDX-License-Identifier: GPL-2.0-or-later
160
+ */
161
+
162
+#include "qemu/osdep.h"
163
+
164
+#include "libqos/libqtest.h"
165
+
166
+/*
167
+ * https://bugs.launchpad.net/qemu/+bug/1879531
168
+ */
169
+static void test_lp1879531_eth_get_rss_ex_dst_addr(void)
170
+{
171
+ QTestState *s;
172
+
173
+ s = qtest_init("-nographic -monitor none -serial none -M pc-q35-5.0");
174
+
175
+ qtest_outl(s, 0xcf8, 0x80001010);
176
+ qtest_outl(s, 0xcfc, 0xe1020000);
177
+ qtest_outl(s, 0xcf8, 0x80001004);
178
+ qtest_outw(s, 0xcfc, 0x7);
179
+ qtest_writeb(s, 0x25, 0x86);
180
+ qtest_writeb(s, 0x26, 0xdd);
181
+ qtest_writeb(s, 0x4f, 0x2b);
182
+
183
+ qtest_writel(s, 0xe1020030, 0x190002e1);
184
+ qtest_writew(s, 0xe102003a, 0x0807);
185
+ qtest_writel(s, 0xe1020048, 0x12077cdd);
186
+ qtest_writel(s, 0xe1020400, 0xba077cdd);
187
+ qtest_writel(s, 0xe1020420, 0x190002e1);
188
+ qtest_writel(s, 0xe1020428, 0x3509d807);
189
+ qtest_writeb(s, 0xe1020438, 0xe2);
190
+ qtest_writeb(s, 0x4f, 0x2b);
191
+ qtest_quit(s);
192
+}
193
+
194
+int main(int argc, char **argv)
195
+{
196
+ const char *arch = qtest_get_arch();
197
+
198
+ g_test_init(&argc, &argv, NULL);
199
+
200
+ if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
201
+ qtest_add_func("fuzz/test_lp1879531_eth_get_rss_ex_dst_addr",
202
+ test_lp1879531_eth_get_rss_ex_dst_addr);
203
+ }
204
+
205
+ return g_test_run();
206
+}
207
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
208
index XXXXXXX..XXXXXXX 100644
209
--- a/tests/qtest/meson.build
210
+++ b/tests/qtest/meson.build
211
@@ -XXX,XX +XXX,XX @@ qtests_i386 = \
212
(config_all_devices.has_key('CONFIG_TPM_TIS_ISA') ? ['tpm-tis-test'] : []) + \
213
(config_all_devices.has_key('CONFIG_TPM_TIS_ISA') ? ['tpm-tis-swtpm-test'] : []) + \
214
(config_all_devices.has_key('CONFIG_RTL8139_PCI') ? ['rtl8139-test'] : []) + \
215
+ (config_all_devices.has_key('CONFIG_E1000E_PCI_EXPRESS') ? ['fuzz-e1000e-test'] : []) + \
216
qtests_pci + \
217
['fdc-test',
218
'ide-test',
24
--
219
--
25
2.7.4
220
2.7.4
26
221
27
222
diff view generated by jsdifflib
1
From: Prasad J Pandit <pjp@fedoraproject.org>
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
2
3
While receiving packets via e1000e_write_packet_to_guest() routine,
3
To simplify the function body, invert the if() statement, returning
4
'desc_offset' is advanced only when RX descriptor is processed. And
4
earlier.
5
RX descriptor is not processed if it has NULL buffer address.
5
Since we already checked there is enough data in the iovec buffer,
6
This may lead to an infinite loop condition. Increament 'desc_offset'
6
simply add an assert() call to consume the bytes_read variable.
7
to process next descriptor in the ring to avoid infinite loop.
8
7
9
Reported-by: Cheol-woo Myung <330cjfdn@gmail.com>
8
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
10
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
9
Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com>
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
11
Signed-off-by: Jason Wang <jasowang@redhat.com>
12
---
12
---
13
hw/net/e1000e_core.c | 8 ++++----
13
net/eth.c | 13 ++++++-------
14
1 file changed, 4 insertions(+), 4 deletions(-)
14
1 file changed, 6 insertions(+), 7 deletions(-)
15
15
16
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
16
diff --git a/net/eth.c b/net/eth.c
17
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/net/e1000e_core.c
18
--- a/net/eth.c
19
+++ b/hw/net/e1000e_core.c
19
+++ b/net/eth.c
20
@@ -XXX,XX +XXX,XX @@ e1000e_write_packet_to_guest(E1000ECore *core, struct NetRxPkt *pkt,
20
@@ -XXX,XX +XXX,XX @@ _eth_get_rss_ex_dst_addr(const struct iovec *pkt, int pkt_frags,
21
(const char *) &fcs_pad, e1000x_fcs_len(core->mac));
21
bytes_read = iov_to_buf(pkt, pkt_frags, ext_hdr_offset,
22
}
22
&rt_hdr, sizeof(rt_hdr));
23
}
23
assert(bytes_read == sizeof(rt_hdr));
24
- desc_offset += desc_size;
24
-
25
- if (desc_offset >= total_size) {
25
- if ((rt_hdr.rtype == 2) && (rt_hdr.segleft == 1)) {
26
- is_last = true;
26
- bytes_read = iov_to_buf(pkt, pkt_frags, ext_hdr_offset + sizeof(rt_hdr),
27
- }
27
- dst_addr, sizeof(*dst_addr));
28
} else { /* as per intel docs; skip descriptors with null buf addr */
28
-
29
trace_e1000e_rx_null_descriptor();
29
- return bytes_read == sizeof(*dst_addr);
30
}
30
+ if ((rt_hdr.rtype != 2) || (rt_hdr.segleft != 1)) {
31
+ desc_offset += desc_size;
31
+ return false;
32
+ if (desc_offset >= total_size) {
32
}
33
+ is_last = true;
33
+ bytes_read = iov_to_buf(pkt, pkt_frags, ext_hdr_offset + sizeof(rt_hdr),
34
+ }
34
+ dst_addr, sizeof(*dst_addr));
35
35
+ assert(bytes_read == sizeof(*dst_addr));
36
e1000e_write_rx_descr(core, desc, is_last ? core->rx_pkt : NULL,
36
37
rss_info, do_ps ? ps_hdr_len : 0, &bastate.written);
37
- return false;
38
+ return true;
39
}
40
41
static bool
38
--
42
--
39
2.7.4
43
2.7.4
40
44
41
45
diff view generated by jsdifflib