<div class="socmaildefaultfont" dir="ltr" style="font-family:Arial, Helvetica, sans-serif;font-size:10.5pt" ><div dir="ltr" >Hi,</div>
<div dir="ltr" >yes, it's the same issue. Tested on s390x with kernel 4.20. Connecting to a VSOCK with<br>CID 0xfff000: always works<br>CID 0xfff001: always fails with: no such device</div>
<div dir="ltr" > </div>
<div dir="ltr" >Same kernel but with the change from the patch below and all CID work again.</div>
<div dir="ltr" >Thanks.</div>
<div dir="ltr" >peter
<div><div class="socmaildefaultfont" dir="ltr" style="font-family:Arial, Helvetica, sans-serif;font-size:10.5pt" ><div class="socmaildefaultfont" dir="ltr" style="font-family:Arial, Helvetica, sans-serif;font-size:10.5pt" ><div dir="ltr" >--<br>peter.morjan@de.ibm.com</div>
<div dir="ltr" >Vorsitzender des Aufsichtsrats: Matthias Hartmann Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294</div></div></div></div>
<div> </div>
<div> </div>
<blockquote data-history-content-modified="1" style="border-left:solid #aaaaaa 2px; margin-left:5px; padding-left:5px; direction:ltr; margin-right:0px" >----- Original message -----<br>From: borntrae@linux.ibm.com<br>To: "Zha Bin" <zhabin@linux.alibaba.com>, stefanha@redhat.com<br>Cc: mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, gerry@linux.alibaba.com, kata-dev@lists.katacontainers.io, Peter Morjan/Germany/IBM@IBMDE<br>Subject: Re: [PATCH] vhost/vsock: fix vhost vsock cid hashing inconsistent<br>Date: Wed, Jan 9, 2019 9:21 AM<br>
<div><font size="2" face="Default Monospace,Courier New,Courier,monospace" >Adding Peter,<br><br>is this the same problem that you reported me today?<br>Can you test Zha Bins patch?<br><br>Christian<br><br>On 08.01.2019 09:07, Zha Bin wrote:<br>> The vsock core only supports 32bit CID, but the Virtio-vsock spec define<br>> CID (dst_cid and src_cid) as u64 and the upper 32bits is reserved as<br>> zero. This inconsistency causes one bug in vhost vsock driver. The<br>> scenarios is:<br>><br>> 0. A hash table (vhost_vsock_hash) is used to map an CID to a vsock<br>> object. And hash_min() is used to compute the hash key. hash_min() is<br>> defined as:<br>> (sizeof(val) <= 4 ? hash_32(val, bits) : hash_long(val, bits)).<br>> That means the hash algorithm has dependency on the size of macro<br>> argument 'val'.<br>> 0. In function vhost_vsock_set_cid(), a 64bit CID is passed to<br>> hash_min() to compute the hash key when inserting a vsock object into<br>> the hash table.<br>> 0. In function vhost_vsock_get(), a 32bit CID is passed to hash_min()<br>> to compute the hash key when looking up a vsock for an CID.<br>><br>> Because the different size of the CID, hash_min() returns different hash<br>> key, thus fails to look up the vsock object for an CID.<br>><br>> To fix this bug, we keep CID as u64 in the IOCTLs and virtio message<br>> headers, but explicitly convert u64 to u32 when deal with the hash table<br>> and vsock core.<br>><br>> Fixes: 834e772c8db0 ("vhost/vsock: fix use-after-free in network stack callers")<br>> Link: <a href="https://github.com/stefanha/virtio/blob/vsock/trunk/content.tex" target="_blank" >https://github.com/stefanha/virtio/blob/vsock/trunk/content.tex</a><br>> Signed-off-by: Zha Bin <zhabin@linux.alibaba.com><br>> Reviewed-by: Liu Jiang <gerry@linux.alibaba.com><br>> ---<br>> drivers/vhost/vsock.c | 2 +-<br>> 1 file changed, 1 insertion(+), 1 deletion(-)<br>><br>> diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c<br>> index bc42d38ae031..3fbc068eaa9b 100644<br>> --- a/drivers/vhost/vsock.c<br>> +++ b/drivers/vhost/vsock.c<br>> @@ -642,7 +642,7 @@ static int vhost_vsock_set_cid(struct vhost_vsock *vsock, u64 guest_cid)<br>> hash_del_rcu(&vsock->hash);<br>> <br>> vsock->guest_cid = guest_cid;<br>> - hash_add_rcu(vhost_vsock_hash, &vsock->hash, guest_cid);<br>> + hash_add_rcu(vhost_vsock_hash, &vsock->hash, vsock->guest_cid);<br>> mutex_unlock(&vhost_vsock_mutex);<br>> <br>> return 0;<br>> </font></div></blockquote>
<div> </div></div></div><BR>