stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Patch "tun: fix rcu_read_lock imbalance in tun_build_skb" has been added to the 4.14-stable tree
@ 2017-12-14 10:48 gregkh
  0 siblings, 0 replies; only message in thread
From: gregkh @ 2017-12-14 10:48 UTC (permalink / raw)
  To: lucien.xin, davem, gregkh; +Cc: stable, stable-commits


This is a note to let you know that I've just added the patch titled

    tun: fix rcu_read_lock imbalance in tun_build_skb

to the 4.14-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:
     tun-fix-rcu_read_lock-imbalance-in-tun_build_skb.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From foo@baz Thu Dec 14 11:45:40 CET 2017
From: Xin Long <lucien.xin@gmail.com>
Date: Sun, 19 Nov 2017 19:31:04 +0800
Subject: tun: fix rcu_read_lock imbalance in tun_build_skb

From: Xin Long <lucien.xin@gmail.com>


[ Upstream commit 654d573845f35017dc397840fa03610fef3d08b0 ]

rcu_read_lock in tun_build_skb is used to rcu_dereference tun->xdp_prog
safely, rcu_read_unlock should be done in every return path.

Now I could see one place missing it, where it returns NULL in switch-case
XDP_REDIRECT,  another palce using rcu_read_lock wrongly, where it returns
NULL in if (xdp_xmit) chunk.

So fix both in this patch.

Fixes: 761876c857cb ("tap: XDP support")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/tun.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1326,6 +1326,7 @@ static struct sk_buff *tun_build_skb(str
 			err = xdp_do_redirect(tun->dev, &xdp, xdp_prog);
 			if (err)
 				goto err_redirect;
+			rcu_read_unlock();
 			return NULL;
 		case XDP_TX:
 			xdp_xmit = true;
@@ -1358,7 +1359,7 @@ static struct sk_buff *tun_build_skb(str
 	if (xdp_xmit) {
 		skb->dev = tun->dev;
 		generic_xdp_tx(skb, xdp_prog);
-		rcu_read_lock();
+		rcu_read_unlock();
 		return NULL;
 	}
 


Patches currently in stable-queue which might be from lucien.xin@gmail.com are

queue-4.14/sctp-use-right-member-as-the-param-of-list_for_each_entry.patch
queue-4.14/tun-fix-rcu_read_lock-imbalance-in-tun_build_skb.patch

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-12-14 10:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-14 10:48 Patch "tun: fix rcu_read_lock imbalance in tun_build_skb" has been added to the 4.14-stable tree gregkh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).