]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
llc: use refcount_inc_not_zero() for llc_sap_find()
authorCong Wang <xiyou.wangcong@gmail.com>
Tue, 7 Aug 2018 19:41:38 +0000 (12:41 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Aug 2018 05:44:51 +0000 (07:44 +0200)
commit7f7649aa028d1fd05628930459a904a505010bd9
tree3f5e2adbfdd36f587ebcd47d4396b0c49473ac0d
parent1bc83bf2342f247af788b807d7039b02231297a5
llc: use refcount_inc_not_zero() for llc_sap_find()

[ Upstream commit 0dcb82254d65f72333aa50ad626d1e9665ad093b ]

llc_sap_put() decreases the refcnt before deleting sap
from the global list. Therefore, there is a chance
llc_sap_find() could find a sap with zero refcnt
in this global list.

Close this race condition by checking if refcnt is zero
or not in llc_sap_find(), if it is zero then it is being
removed so we can just treat it as gone.

Reported-by: <syzbot+278893f3f7803871f7ce@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>
include/net/llc.h
net/llc/llc_core.c