Linux virtualization list
 help / color / mirror / Atom feed
From: "Adalbert Lazăr" <alazar@bitdefender.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org,
	netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>,
	Stefano Garzarella <sgarzare@redhat.com>
Subject: Re: [PATCH] vsock/virtio: fix kernel panic from virtio_transport_reset_no_sock
Date: Wed, 06 Mar 2019 19:25:19 +0200	[thread overview]
Message-ID: <150.538089086183$1555717317@news.gmane.org> (raw)
In-Reply-To: <20190306170216.GC29057@stefanha-x1.localdomain>

On Wed, 6 Mar 2019 17:02:16 +0000, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> On Wed, Mar 06, 2019 at 11:10:41AM +0200, Adalbert Lazăr wrote:
> > On Wed, 6 Mar 2019 08:41:04 +0000, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> > > On Tue, Mar 05, 2019 at 08:01:45PM +0200, Adalbert Lazăr wrote:
> > > The pkt argument is the received packet that we must reply to.
> > > The reply packet is allocated just before line 680 and must be free
> > > explicitly for return -ENOTCONN.
> > > 
> > > You can avoid the leak and make the code easier to read like this:
> > > 
> > >   struct virtio_vsock_pkt *reply;
> > > 
> > >   ...
> > > 
> > >      ------ avoid reusing 'pkt'
> > >     v
> > >   reply = virtio_transport_alloc_pkt(&info, 0, ...);
> > >   if (!reply)
> > >       return -ENOMEM;
> > > 
> > >   t = virtio_transport_get_ops();
> > >   if (!t) {
> > >       virtio_transport_free_pkt(reply); <-- prevent memory leak
> > >       return -ENOTCONN;
> > >   }
> > >   return t->send_pkt(reply);
> > 
> > What do you think about Stefano's suggestion, to move the check above
> > the line were the reply is allocated?
> 
> That's fine too.
> 
> However a follow up patch to eliminate the confusing way that 'pkt' is
> reused is still warranted.  If you are busy I'd be happy to send that
> cleanup.
> 
> Stefan

I've got it, a couple of minutes after I've replied :)
The second version[1] should be in your mailbox.

Thank you,
Adalbert

[1]: https://patchwork.kernel.org/patch/10840787/
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  parent reply	other threads:[~2019-03-06 17:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190305180145.27161-1-alazar@bitdefender.com>
2019-03-06  8:12 ` [PATCH] vsock/virtio: fix kernel panic from virtio_transport_reset_no_sock Stefano Garzarella
2019-03-06  8:41 ` Stefan Hajnoczi
     [not found] ` <20190306081236.mcd4o27yw67euzgv@steredhat.homenet.telecomitalia.it>
2019-03-06  8:53   ` Adalbert Lazăr
     [not found] ` <20190306084104.GA22159@stefanha-x1.localdomain>
2019-03-06  9:10   ` Adalbert Lazăr
     [not found]   ` <1551863441.5559.19509.@c1753101230bd75c4bdbfe8f0947046bcaf69c6c>
2019-03-06 17:02     ` Stefan Hajnoczi
     [not found]     ` <20190306170216.GC29057@stefanha-x1.localdomain>
2019-03-06 17:25       ` Adalbert Lazăr [this message]
2019-03-05 18:01 Adalbert Lazăr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='150.538089086183$1555717317@news.gmane.org' \
    --to=alazar@bitdefender.com \
    --cc=davem@davemloft.net \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox