vhost-user: return if no net clients found
PATCH 1/1 vhost-user: return if no net clients found
From: Chen Hanxiao <[email protected]>
If we can't find a suitable net client, return directly. Or we will got a segmentation fault.
--- net/vhost-user.c | 3 +++ 1 file changed, 3 insertions(+)
net/vhost-user.c +3 -0
@@ -210,6 +210,9 @@ static void net_vhost_user_event(void *opaque, int event) MAX_QUEUE_NUM);assert (queues <MAX_QUEUE_NUM ); +if (queues <1 ) +return ; + s =DO_UPCAST (VhostUserState, nc, ncs[0 ]);trace_vhost_user_event (s->chr->label, event);switch (event) {
Signature · 1 line
1.8.3.1
Your series seems to have some coding style problems. See output below for more information:
Hi,
Your series seems to have some coding style problems. See output below for more information:
Subject: [Qemu-devel] [PATCH] vhost-user: return if no net clients found
Type: series
Message-id: [email protected]
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
# Useful git options
git config --local diff.renamelimit 0
git config --local diff.renames True
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git show --no-patch --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
9e2b365 vhost-user: return if no net clients found
=== OUTPUT BEGIN ===
Checking PATCH 1/1: vhost-user: return if no net clients found...
ERROR: braces {} are necessary for all arms of this statement #20: FILE: net/vhost-user.c:213:
+ if (queues < 1)
[...]
total: 1 errors, 0 warnings, 9 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]
Hi
Quoted 15 lines · Chen Hanxiao
From: Chen Hanxiao <[email protected]>
If we can't find a suitable net client, return directly. Or we will got a segmentation fault.
Signed-off-by Chen Hanxiao <[email protected]>--- net/vhost-user.c | 3 +++ 1 file changed, 3 insertions(+)net/vhost-user.c +0
-0
net/vhost-user.c static void net_vhost_user_event(void *opaque, int · line 217
Quoted 8 lines
net/vhost-user.c +3
-0@@ -210,6 +210,9 @@ static void net_vhost_user_event(void *opaque, int event) MAX_QUEUE_NUM);assert (queues <MAX_QUEUE_NUM ); +if (queues <1 ) +return ; +
qemu coding style has mandatory {} braces.
I don't understand what this patch fixes. even if queues == 0, there is not reason I can think of it would crash. Could you provide a backtrace?
A qemu-only reproducer would be really useful.
s = DO_UPCAST(VhostUserState, nc, ncs[0]);
Quoted 8 lines
net/vhost-user.c +0
-0trace_vhost_user_event (s->chr->label, event);switch (event) {--
1.8.3.1--
Marc-André Lureau
在 2016-09-01 19:43:31,"Marc-André Lureau" <[email protected]> 写道:
Hi
On Thu, Sep 1, 2016 at 2:15 PM Chen Hanxiao <[email protected]> wrote:
From: Chen Hanxiao <[email protected]>
If we can't find a suitable net client, return directly. Or we will got a segmentation fault.
--- net/vhost-user.c | 3 +++ 1 file changed, 3 insertions(+)
net/vhost-user.c +3 -0
@@ -210,6 +210,9 @@ static void net_vhost_user_event(void *opaque, int event) MAX_QUEUE_NUM);assert (queues <MAX_QUEUE_NUM ); +if (queues <1 ) +return ; +
qemu coding style has mandatory {} braces.
I don't understand what this patch fixes. even if queues == 0, there is not reason I can think of it would crash. Could you provide a backtrace?
A qemu-only reproducer would be really useful.
Hi, here is the backtrace:
#0 net_vhost_user_event (opaque=0x7fc2f6893be0, event=5) at net/vhost-user.c:196 #1 0x00007fc2f4ebfb2b in tcp_chr_disconnect (chr=0x7fc2f68cc400) at qemu-char.c:2837 #2 0x00007fc2f4ebfba9 in tcp_chr_sync_read (chr=0x7fc2f68cc400, buf=<optimized out>, len=<optimized out>) at qemu-char.c:2888 #3 0x00007fc2f4ec106d in qemu_chr_fe_read_all (s=0x7fc2f68cc400, buf=buf@entry=0x7fff5fda25b7 "", len=len@entry=1) at qemu-char.c:264 #4 0x00007fc2f4f9a43a in net_vhost_user_watch (chan=<optimized out>, cond=<optimized out>, opaque=<optimized out>) at net/vhost-user.c:190 #5 0x00007fc2f321999a in g_main_context_dispatch () from /lib64/libglib-2.0.so.0 #6 0x00007fc2f4fd8fe8 in glib_pollfds_poll () at main-loop.c:209 #7 os_host_main_loop_wait (timeout=<optimized out>) at main-loop.c:254 #8 main_loop_wait (nonblocking=<optimized out>) at main-loop.c:503 #9 0x00007fc2f4dd7b1e in main_loop () at vl.c:1818
#10 main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4394
Program received signal SIGSEGV, Segmentation fault. net_vhost_user_event (opaque=0x7fc2f6893be0, event=5) at net/vhost-user.c:207
207 trace_vhost_user_event(s->chr->label, event);
Regards,
- Chen
Hi
Quoted 19 lines · Chen Hanxiao
Hi, here is the backtrace:
#0
net_vhost_user_event(opaque=0x7fc2f6893be0, event=5) atnet/vhost-user.c:196
#10x00007fc2f4ebfb2bintcp_chr_disconnect(chr=0x7fc2f68cc400) at qemu-char.c:2837
#20x00007fc2f4ebfba9intcp_chr_sync_read(chr=0x7fc2f68cc400, buf=<optimized out>, len=<optimized out>) at qemu-char.c:2888 #30x00007fc2f4ec106dinqemu_chr_fe_read_all(s=0x7fc2f68cc400, buf=buf@entry=0x7fff5fda25b7 "", len=len@entry=1) at qemu-char.c:264 #40x00007fc2f4f9a43ainnet_vhost_user_watch(chan=<optimized out>, cond=<optimized out>, opaque=<optimized out>) atnet/vhost-user.c:190#50x00007fc2f321999aing_main_context_dispatch() from/lib64/libglib-2.0.so.0#6 0x00007fc2f4fd8fe8 in glib_pollfds_poll () at main-loop.c:209 #7 os_host_main_loop_wait (timeout=<optimized out>) at main-loop.c:254 #8 main_loop_wait (nonblocking=<optimized out>) at main-loop.c:503 #9 0x00007fc2f4dd7b1e in main_loop () at vl.c:1818
Quoted 10 lines
#10 main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4394
Program received signal SIGSEGV, Segmentation fault.
net_vhost_user_event(opaque=0x7fc2f6893be0, event=5) atnet/vhost-user.c:207
207trace_vhost_user_event(s->chr->label, event);
thanks for the backtrace, that helps
However, I fail to understand how that can happen, as there has to be at least one net_client to start qemu with vhost-user and that callback must have at least the first netclient still around because the opaque pointer is shared with the netclient struct. So it looks like something destroyed the netclient before the callback, and in this case, the opaque pointer is invalid, and things are going all wrong. But it can't be host-net-remove, since the net-client is not on a registered hub.
Could you try to find a simple reproducer using qemu only?
thanks
Signature · 1 line
Marc-André Lureau
Quoted 35 lines · Marc-André Lureau
Hi
Quoted 19 lines · Chen Hanxiao
Hi, here is the backtrace:
#0
net_vhost_user_event(opaque=0x7fc2f6893be0, event=5) atnet/vhost-user.c:196
#10x00007fc2f4ebfb2bintcp_chr_disconnect(chr=0x7fc2f68cc400) at qemu-char.c:2837
#20x00007fc2f4ebfba9intcp_chr_sync_read(chr=0x7fc2f68cc400, buf=<optimized out>, len=<optimized out>) at qemu-char.c:2888 #30x00007fc2f4ec106dinqemu_chr_fe_read_all(s=0x7fc2f68cc400, buf=buf@entry=0x7fff5fda25b7 "", len=len@entry=1) at qemu-char.c:264 #40x00007fc2f4f9a43ainnet_vhost_user_watch(chan=<optimized out>, cond=<optimized out>, opaque=<optimized out>) atnet/vhost-user.c:190#50x00007fc2f321999aing_main_context_dispatch() from/lib64/libglib-2.0.so.0#6 0x00007fc2f4fd8fe8 in glib_pollfds_poll () at main-loop.c:209 #7 os_host_main_loop_wait (timeout=<optimized out>) at main-loop.c:254 #8 main_loop_wait (nonblocking=<optimized out>) at main-loop.c:503 #9 0x00007fc2f4dd7b1e in main_loop () at vl.c:1818Quoted 10 lines
#10 main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4394
Program received signal SIGSEGV, Segmentation fault.
net_vhost_user_event(opaque=0x7fc2f6893be0, event=5) atnet/vhost-user.c:207
207trace_vhost_user_event(s->chr->label, event);thanks for the backtrace, that helps
Quoted 7 lines
However, I fail to understand how that can happen, as there has to be at least one
net_clientto start qemu with vhost-user and that callback must have at least the first netclient still around because the opaque pointer is shared with the netclient struct. So it looks like something destroyed the netclient before the callback, and in this case, the opaque pointer is invalid, and things are going all wrong. But it can't be host-net-remove, since the net-client is not on a registered hub.
The call back give qemu_find_net_clients_except id == 'filename'. But could not find a netclient match.
Then ncs[i] did not get a valid net client, then we will get a seg fault.
Quoted 2 lines
Could you try to find a simple reproducer using qemu only?
I'll try.
Regards,
- Chen
Quoted 5 lines
thanks
Signature · 1 line
Marc-André Lureau