Patch "tap: double-free in error path in tap_open()" has been added to the 4.13-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
tap: double-free in error path in tap_open()
to the 4.13-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
tap-double-free-in-error-path-in-tap_open.patch
and it can be found in the queue-4.13 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Wed Nov 15 17:25:34 CET 2017
From: Girish Moodalbail <[email protected]>
Date: Wed, 25 Oct 2017 00:23:04 -0700
Subject: tap: double-free in error path in tap_open()
From: Girish Moodalbail <[email protected]>
[ Upstream commit 78e0ea6791d7baafb8a0ca82b1bd0c7b3453c919 ]
Double free of skb_array in tap module is causing kernel panic. When tap_set_queue() fails we free skb_array right away by calling skb_array_cleanup(). However, later on skb_array_cleanup() is called again by tap_sock_destruct through sock_put(). This patch fixes that issue.
--- drivers/net/tap.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/tap.c +9 -9
@@ -517,6 +517,10 @@ static int tap_open(struct inode *inode, &tap_proto, 0);if (!q) goto err; +if (skb_array_init (&q->skb_array, tap->dev->tx_queue_len,GFP_KERNEL )) { +sk_free (&q->sk); + goto err; + }RCU_INIT_POINTER (q->sock.wq, &q->wq);init_waitqueue_head (&q->wq.wait);
@@ -540,22 +544,18 @@ static int tap_open(struct inode *inode,if ((tap->dev->features &NETIF_F_HIGHDMA ) && (tap->dev->features &NETIF_F_SG ))sock_set_flag (&q->sk,SOCK_ZEROCOPY ); - err = -ENOMEM ; -if (skb_array_init (&q->skb_array, tap->dev->tx_queue_len,GFP_KERNEL )) - goto err_array; - err =tap_set_queue (tap, file, q); -if (err) - goto err_queue; +if (err) { +/* tap_sock_destruct() will take care of freeing skb_array */ + goto err_put; + }dev_put (tap->dev);rtnl_unlock ();return err; -err_queue: -skb_array_cleanup (&q->skb_array); -err_array: +err_put:sock_put (&q->sk); err:if (tap)
Patches currently in stable-queue which might be from [email protected] are
queue-4.13/tap-reference-to-kva-of-an-unloaded-module-causes-kernel-panic.patch queue-4.13/tap-double-free-in-error-path-in-tap_open.patch