summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Wang <jasowang@redhat.com>2013-06-04 13:18:17 +0800
committerMichael Roth <mdroth@linux.vnet.ibm.com>2013-06-17 16:35:39 -0500
commit5a893b0d37795f1f1d89caa2e36d9ff311cd2dc9 (patch)
tree15b74e3e51f027b4fe5b2c8d6be9941a59a04d1e
parent0817fa97673acc71994a65e73449b632c069c22b (diff)
downloadqemu-5a893b0d37795f1f1d89caa2e36d9ff311cd2dc9.tar.gz
tap: fix NULL dereference when passing invalid parameters to tap
This patch forbid the following invalid parameters to tap: 1) fd and vhostfds were specified but vhostfd were not specified 2) vhostfds were specified but fds were not specified 3) fds and vhostfd were specified For 1 and 2, net_init_tap_one() will still pass NULL as vhostfdname to monitor_handle_fd_param(), which may crash the qemu. Also remove the unnecessary has_fd check. Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Stefan Hajnoczi <shajnocz@redhat.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: qemu-stable@nongnu.org Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> (cherry picked from commit c87826a878be05208c3906eb9d5e1f37cff5e98e) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r--net/tap.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/net/tap.c b/net/tap.c
index e0b7a2a5a0..39c1cda3e4 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -698,9 +698,10 @@ int net_init_tap(const NetClientOptions *opts, const char *name,
if (tap->has_fd) {
if (tap->has_ifname || tap->has_script || tap->has_downscript ||
tap->has_vnet_hdr || tap->has_helper || tap->has_queues ||
- tap->has_fds) {
+ tap->has_fds || tap->has_vhostfds) {
error_report("ifname=, script=, downscript=, vnet_hdr=, "
- "helper=, queues=, and fds= are invalid with fd=");
+ "helper=, queues=, fds=, and vhostfds= "
+ "are invalid with fd=");
return -1;
}
@@ -725,9 +726,10 @@ int net_init_tap(const NetClientOptions *opts, const char *name,
if (tap->has_ifname || tap->has_script || tap->has_downscript ||
tap->has_vnet_hdr || tap->has_helper || tap->has_queues ||
- tap->has_fd) {
+ tap->has_vhostfd) {
error_report("ifname=, script=, downscript=, vnet_hdr=, "
- "helper=, queues=, and fd= are invalid with fds=");
+ "helper=, queues=, and vhostfd= "
+ "are invalid with fds=");
return -1;
}
@@ -765,9 +767,9 @@ int net_init_tap(const NetClientOptions *opts, const char *name,
}
} else if (tap->has_helper) {
if (tap->has_ifname || tap->has_script || tap->has_downscript ||
- tap->has_vnet_hdr || tap->has_queues || tap->has_fds) {
+ tap->has_vnet_hdr || tap->has_queues || tap->has_vhostfds) {
error_report("ifname=, script=, downscript=, and vnet_hdr= "
- "queues=, and fds= are invalid with helper=");
+ "queues=, and vhostfds= are invalid with helper=");
return -1;
}
@@ -785,6 +787,10 @@ int net_init_tap(const NetClientOptions *opts, const char *name,
return -1;
}
} else {
+ if (tap->has_vhostfds) {
+ error_report("vhostfds= is invalid if fds= wasn't specified");
+ return -1;
+ }
script = tap->has_script ? tap->script : DEFAULT_NETWORK_SCRIPT;
downscript = tap->has_downscript ? tap->downscript :
DEFAULT_NETWORK_DOWN_SCRIPT;