OSDN Git Service

act_ife: fix a potential deadlock
authorCong Wang <xiyou.wangcong@gmail.com>
Sun, 19 Aug 2018 19:22:13 +0000 (12:22 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 21 Aug 2018 19:45:45 +0000 (12:45 -0700)
commit5ffe57da29b3802baeddaa40909682bbb4cb4d48
tree445afddd040006b43d6d2ad85118b558ded5ca6c
parent4e407ff5cd67ec76eeeea1deec227b7982dc7f66
act_ife: fix a potential deadlock

use_all_metadata() acquires read_lock(&ife_mod_lock), then calls
add_metainfo() which calls find_ife_oplist() which acquires the same
lock again. Deadlock!

Introduce __add_metainfo() which accepts struct tcf_meta_ops *ops
as an additional parameter and let its callers to decide how
to find it. For use_all_metadata(), it already has ops, no
need to find it again, just call __add_metainfo() directly.

And, as ife_mod_lock is only needed for find_ife_oplist(),
this means we can make non-atomic allocation for populate_metalist()
now.

Fixes: 817e9f2c5c26 ("act_ife: acquire ife_mod_lock before reading ifeoplist")
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/act_ife.c