From 332e0440a51ccc71356cd82b0908dee5f46ba155 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 17 Apr 2018 08:50:28 -0700 Subject: vhost: show vhost-user may crash [VPP-1242] show vhost-user may cause a crash if interface is semi-bogus. Semi-bogus means it is a known vpp interface which has a hw_if_index, but it is bogus because it is not a vhost-user interface. The fix is to add a check to reject non vhost-user interface for the command. Change-Id: I63f1e8bfbf46f5ec4c30f9fb3546982b63cd7cc5 Signed-off-by: Steven (cherry picked from commit 583f158b44d9644855441280e09afbf85a4557df) --- src/vnet/devices/virtio/vhost-user.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/vnet/devices/virtio/vhost-user.c b/src/vnet/devices/virtio/vhost-user.c index 5460f10b74e..c1fca441fa5 100644 --- a/src/vnet/devices/virtio/vhost-user.c +++ b/src/vnet/devices/virtio/vhost-user.c @@ -3253,6 +3253,13 @@ show_vhost_user_command_fn (vlib_main_t * vm, if (unformat (input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index)) { + hi = vnet_get_hw_interface (vnm, hw_if_index); + if (vhost_user_dev_class.index != hi->dev_class_index) + { + error = clib_error_return (0, "unknown input `%U'", + format_unformat_error, input); + goto done; + } vec_add1 (hw_if_indices, hw_if_index); } else if (unformat (input, "descriptors") || unformat (input, "desc")) -- cgit 1.2.3-korg