提交 b1bdcb59 编写于 作者: F Florian Westphal 提交者: Steffen Klassert

xfrm: don't call xfrm_policy_cache_flush while holding spinlock

xfrm_policy_cache_flush can sleep, so it cannot be called while holding
a spinlock.  We could release the lock first, but I don't see why we need
to invoke this function here in first place, the packet path won't reuse
an xdst entry unless its still valid.

While at it, add an annotation to xfrm_policy_cache_flush, it would
have probably caught this bug sooner.

Fixes: ec30d78c ("xfrm: add xdst pcpu cache")
Reported-by: syzbot+e149f7d1328c26f9c12f@syzkaller.appspotmail.com
Signed-off-by: NFlorian Westphal <fw@strlen.de>
Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
上级 bcfd09f7
...@@ -975,8 +975,6 @@ int xfrm_policy_flush(struct net *net, u8 type, bool task_valid) ...@@ -975,8 +975,6 @@ int xfrm_policy_flush(struct net *net, u8 type, bool task_valid)
} }
if (!cnt) if (!cnt)
err = -ESRCH; err = -ESRCH;
else
xfrm_policy_cache_flush();
out: out:
spin_unlock_bh(&net->xfrm.xfrm_policy_lock); spin_unlock_bh(&net->xfrm.xfrm_policy_lock);
return err; return err;
...@@ -1744,6 +1742,8 @@ void xfrm_policy_cache_flush(void) ...@@ -1744,6 +1742,8 @@ void xfrm_policy_cache_flush(void)
bool found = 0; bool found = 0;
int cpu; int cpu;
might_sleep();
local_bh_disable(); local_bh_disable();
rcu_read_lock(); rcu_read_lock();
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册