Patch "net: llc: add lock_sock in llc_ui_bind to avoid a race condition" has been added to the 4.9-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
net: llc: add lock_sock in llc_ui_bind to avoid a race condition
to the 4.9-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:
net-llc-add-lock_sock-in-llc_ui_bind-to-avoid-a-race-condition.patch
and it can be found in the queue-4.9 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 Mon Apr 9 17:09:24 CEST 2018
From: linzhang <[email protected]>
Date: Thu, 25 May 2017 14:07:18 +0800
Subject: net: llc: add lock_sock in llc_ui_bind to avoid a race condition
From: linzhang <[email protected]>
[ Upstream commit 0908cf4dfef35fc6ac12329007052ebe93ff1081 ]
There is a race condition in llc_ui_bind if two or more processes/threads try to bind a same socket.
If more processes/threads bind a same socket success that will lead to two problems, one is this action is not what we expected, another is will lead to kernel in unstable status or oops(in my simple test case, cause llc2.ko can't unload).
The current code is test SOCK_ZAPPED bit to avoid a process to bind a same socket twice but that is can't avoid more processes/threads try to bind a same socket at the same time.
So, add lock_sock in llc_ui_bind like others, such as llc_ui_connect.
--- net/llc/af_llc.c | 3 +++ 1 file changed, 3 insertions(+)
net/llc/af_llc.c +3 -0
@@ -309,6 +309,8 @@ static int llc_ui_bind(struct socket *soint rc = -EINVAL ;dprintk ("%s: binding %02X\n" , __func__, addr->sllc_sap); + +lock_sock (sk);if (unlikely (!sock_flag (sk,SOCK_ZAPPED ) || addrlen !=sizeof (*addr))) goto out; rc = -EAFNOSUPPORT ;
@@ -380,6 +382,7 @@ static int llc_ui_bind(struct socket *so out_put:llc_sap_put (sap); out: +release_sock (sk);return rc; }
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/net-x25-fix-one-potential-use-after-free-issue.patch queue-4.9/net-llc-add-lock_sock-in-llc_ui_bind-to-avoid-a-race-condition.patch queue-4.9/net-ieee802154-fix-net_device-reference-release-too-early.patch