]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commit28cc946751c9d4130e1e773b5e8523aa53cb2a50
tree445afddd040006b43d6d2ad85118b558ded5ca6c
parentaee3dfbcae99e9c5eeca8f297374d112e18004d8
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: a32ef45b170a ("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