diff options
author | Cong Wang <xiyou.wangcong@gmail.com> | 2018-10-11 21:15:13 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-11-04 16:52:48 +0300 |
commit | 6bb1381cc8650c9b86e41ea639db4dfaed750ad4 (patch) | |
tree | 8613fa1508e3b28a2c8b67790c44fbed7471c6f6 /net/llc | |
parent | 1e42e97af9832848bbeba5c1f7f35dbcffec5642 (diff) | |
download | linux-6bb1381cc8650c9b86e41ea639db4dfaed750ad4.tar.xz |
llc: set SOCK_RCU_FREE in llc_sap_add_socket()
[ Upstream commit 5a8e7aea953bdb6d4da13aff6f1e7f9c62023499 ]
WHen an llc sock is added into the sk_laddr_hash of an llc_sap,
it is not marked with SOCK_RCU_FREE.
This causes that the sock could be freed while it is still being
read by __llc_lookup_established() with RCU read lock. sock is
refcounted, but with RCU read lock, nothing prevents the readers
getting a zero refcnt.
Fix it by setting SOCK_RCU_FREE in llc_sap_add_socket().
Reported-by: syzbot+11e05f04c15e03be5254@syzkaller.appspotmail.com
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/llc')
-rw-r--r-- | net/llc/llc_conn.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/net/llc/llc_conn.c b/net/llc/llc_conn.c index b084fd19ad32..56c3fb5cc805 100644 --- a/net/llc/llc_conn.c +++ b/net/llc/llc_conn.c @@ -734,6 +734,7 @@ void llc_sap_add_socket(struct llc_sap *sap, struct sock *sk) llc_sk(sk)->sap = sap; spin_lock_bh(&sap->sk_lock); + sock_set_flag(sk, SOCK_RCU_FREE); sap->sk_count++; sk_nulls_add_node_rcu(sk, laddr_hb); hlist_add_head(&llc->dev_hash_node, dev_hb); |