From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rusty Russell Subject: Re: [PATCH v3 9/9] virtio: console: prevent use-after-free of port name in port unplug Date: Mon, 29 Jul 2013 14:26:09 +0930 Message-ID: <871u6i6k2e.fsf@rustcorp.com.au> References: <83c058bc32c4e377a75235120885aec7dfd223c7.1374759439.git.amit.shah@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <83c058bc32c4e377a75235120885aec7dfd223c7.1374759439.git.amit.shah@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: virtualization-bounces@lists.linux-foundation.org Errors-To: virtualization-bounces@lists.linux-foundation.org To: Virtualization List Cc: Amit Shah List-Id: virtualization@lists.linuxfoundation.org Amit Shah writes: > Remove the debugfs path before freeing port->name, to prevent a possible > use-after-free. > > Reported-by: Jason Wang > Signed-off-by: Amit Shah Applied, Rusty. > --- > drivers/char/virtio_console.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c > index 4e380c1..e910bec 100644 > --- a/drivers/char/virtio_console.c > +++ b/drivers/char/virtio_console.c > @@ -1574,9 +1574,8 @@ static void unplug_port(struct port *port) > device_destroy(pdrvdata.class, port->dev->devt); > cdev_del(port->cdev); > > - kfree(port->name); > - > debugfs_remove(port->debugfs_file); > + kfree(port->name); > > /* > * Locks around here are not necessary - a port can't be > -- > 1.8.1.4