* Re: [PATCH net] virtio/vsock: fix sock refcnt bug on owner set failure
2023-06-01 7:58 ` Stefano Garzarella
@ 2023-05-31 3:35 ` Bobby Eshleman
2023-06-05 8:23 ` Stefano Garzarella
0 siblings, 1 reply; 4+ messages in thread
From: Bobby Eshleman @ 2023-05-31 3:35 UTC (permalink / raw)
To: Stefano Garzarella
Cc: Bobby Eshleman, kvm, netdev, linux-kernel, virtualization,
Eric Dumazet, Stefan Hajnoczi, Jakub Kicinski, Paolo Abeni,
David S. Miller
On Thu, Jun 01, 2023 at 09:58:47AM +0200, Stefano Garzarella wrote:
> On Wed, May 31, 2023 at 07:47:32PM +0000, Bobby Eshleman wrote:
> > Previous to setting the owner the socket is found via
> > vsock_find_connected_socket(), which returns sk after a call to
> > sock_hold().
> >
> > If setting the owner fails, then sock_put() needs to be called.
> >
> > Fixes: f9d2b1e146e0 ("virtio/vsock: fix leaks due to missing skb owner")
> > Signed-off-by: Bobby Eshleman <bobby.eshleman@bytedance.com>
> > ---
> > net/vmw_vsock/virtio_transport_common.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
> > index b769fc258931..f01cd6adc5cb 100644
> > --- a/net/vmw_vsock/virtio_transport_common.c
> > +++ b/net/vmw_vsock/virtio_transport_common.c
> > @@ -1343,6 +1343,7 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
> >
> > if (!skb_set_owner_sk_safe(skb, sk)) {
> > WARN_ONCE(1, "receiving vsock socket has sk_refcnt == 0\n");
> > + sock_put(sk);
>
> Did you have any warning, issue here?
>
> IIUC skb_set_owner_sk_safe() can return false only if the ref counter
> is 0, so calling a sock_put() on it should have no effect except to
> produce a warning.
>
Oh yeah, you're totally right. I did not recall how
skb_set_owner_sk_safe() worked internally and thought I'd introduced an
uneven hold/put count with that prior patch when reading through the
code again. I haven't seen any live issue, just misread the code.
Sorry about that, feel free to ignore this patch.
Best,
Bobby
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net] virtio/vsock: fix sock refcnt bug on owner set failure
@ 2023-05-31 19:47 Bobby Eshleman
2023-06-01 7:58 ` Stefano Garzarella
0 siblings, 1 reply; 4+ messages in thread
From: Bobby Eshleman @ 2023-05-31 19:47 UTC (permalink / raw)
To: Stefan Hajnoczi, Stefano Garzarella, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: kvm, virtualization, netdev, linux-kernel, Bobby Eshleman
Previous to setting the owner the socket is found via
vsock_find_connected_socket(), which returns sk after a call to
sock_hold().
If setting the owner fails, then sock_put() needs to be called.
Fixes: f9d2b1e146e0 ("virtio/vsock: fix leaks due to missing skb owner")
Signed-off-by: Bobby Eshleman <bobby.eshleman@bytedance.com>
---
net/vmw_vsock/virtio_transport_common.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index b769fc258931..f01cd6adc5cb 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -1343,6 +1343,7 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
if (!skb_set_owner_sk_safe(skb, sk)) {
WARN_ONCE(1, "receiving vsock socket has sk_refcnt == 0\n");
+ sock_put(sk);
goto free_pkt;
}
---
base-commit: 60cbd38bb0ad9e4395fba9c6994f258f1d6cad51
change-id: 20230531-b4-vsock-fix-refcnt-b7b1558c0820
Best regards,
--
Bobby Eshleman <bobby.eshleman@bytedance.com>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] virtio/vsock: fix sock refcnt bug on owner set failure
2023-05-31 19:47 [PATCH net] virtio/vsock: fix sock refcnt bug on owner set failure Bobby Eshleman
@ 2023-06-01 7:58 ` Stefano Garzarella
2023-05-31 3:35 ` Bobby Eshleman
0 siblings, 1 reply; 4+ messages in thread
From: Stefano Garzarella @ 2023-06-01 7:58 UTC (permalink / raw)
To: Bobby Eshleman
Cc: Stefan Hajnoczi, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, kvm, virtualization, netdev, linux-kernel
On Wed, May 31, 2023 at 07:47:32PM +0000, Bobby Eshleman wrote:
>Previous to setting the owner the socket is found via
>vsock_find_connected_socket(), which returns sk after a call to
>sock_hold().
>
>If setting the owner fails, then sock_put() needs to be called.
>
>Fixes: f9d2b1e146e0 ("virtio/vsock: fix leaks due to missing skb owner")
>Signed-off-by: Bobby Eshleman <bobby.eshleman@bytedance.com>
>---
> net/vmw_vsock/virtio_transport_common.c | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
>index b769fc258931..f01cd6adc5cb 100644
>--- a/net/vmw_vsock/virtio_transport_common.c
>+++ b/net/vmw_vsock/virtio_transport_common.c
>@@ -1343,6 +1343,7 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
>
> if (!skb_set_owner_sk_safe(skb, sk)) {
> WARN_ONCE(1, "receiving vsock socket has sk_refcnt == 0\n");
>+ sock_put(sk);
Did you have any warning, issue here?
IIUC skb_set_owner_sk_safe() can return false only if the ref counter
is 0, so calling a sock_put() on it should have no effect except to
produce a warning.
Thanks,
Stefano
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] virtio/vsock: fix sock refcnt bug on owner set failure
2023-05-31 3:35 ` Bobby Eshleman
@ 2023-06-05 8:23 ` Stefano Garzarella
0 siblings, 0 replies; 4+ messages in thread
From: Stefano Garzarella @ 2023-06-05 8:23 UTC (permalink / raw)
To: Bobby Eshleman
Cc: Bobby Eshleman, kvm, netdev, linux-kernel, virtualization,
Eric Dumazet, Stefan Hajnoczi, Jakub Kicinski, Paolo Abeni,
David S. Miller
On Wed, May 31, 2023 at 03:35:30AM +0000, Bobby Eshleman wrote:
>On Thu, Jun 01, 2023 at 09:58:47AM +0200, Stefano Garzarella wrote:
>> On Wed, May 31, 2023 at 07:47:32PM +0000, Bobby Eshleman wrote:
>> > Previous to setting the owner the socket is found via
>> > vsock_find_connected_socket(), which returns sk after a call to
>> > sock_hold().
>> >
>> > If setting the owner fails, then sock_put() needs to be called.
>> >
>> > Fixes: f9d2b1e146e0 ("virtio/vsock: fix leaks due to missing skb owner")
>> > Signed-off-by: Bobby Eshleman <bobby.eshleman@bytedance.com>
>> > ---
>> > net/vmw_vsock/virtio_transport_common.c | 1 +
>> > 1 file changed, 1 insertion(+)
>> >
>> > diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
>> > index b769fc258931..f01cd6adc5cb 100644
>> > --- a/net/vmw_vsock/virtio_transport_common.c
>> > +++ b/net/vmw_vsock/virtio_transport_common.c
>> > @@ -1343,6 +1343,7 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
>> >
>> > if (!skb_set_owner_sk_safe(skb, sk)) {
>> > WARN_ONCE(1, "receiving vsock socket has sk_refcnt == 0\n");
>> > + sock_put(sk);
>>
>> Did you have any warning, issue here?
>>
>> IIUC skb_set_owner_sk_safe() can return false only if the ref counter
>> is 0, so calling a sock_put() on it should have no effect except to
>> produce a warning.
>>
>
>Oh yeah, you're totally right. I did not recall how
>skb_set_owner_sk_safe() worked internally and thought I'd introduced an
>uneven hold/put count with that prior patch when reading through the
>code again. I haven't seen any live issue, just misread the code.
>
>Sorry about that, feel free to ignore this patch.
No problem ;-)
Maybe we should add a comment on it.
Thanks,
Stefano
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-05 8:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-31 19:47 [PATCH net] virtio/vsock: fix sock refcnt bug on owner set failure Bobby Eshleman
2023-06-01 7:58 ` Stefano Garzarella
2023-05-31 3:35 ` Bobby Eshleman
2023-06-05 8:23 ` Stefano Garzarella
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox