act_ife: load meta modules before tcf_idr_check_alloc()
authorCong Wang <xiyou.wangcong@gmail.com>
Fri, 4 Sep 2020 02:10:11 +0000 (19:10 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Sep 2020 16:05:21 +0000 (18:05 +0200)
commit946fc6d847682b6feb2f7100079b1ddcd5fd52f7
tree0aacd085e9d25aea91701effdb4e0f33e737c538
parent9215385638b70b5d4b050a42933cbaf884f8a6f3
act_ife: load meta modules before tcf_idr_check_alloc()

[ Upstream commit cc8e58f8325cdf14b9516b61c384cdfd02a4f408 ]

The following deadlock scenario is triggered by syzbot:

Thread A: Thread B:
tcf_idr_check_alloc()
...
populate_metalist()
  rtnl_unlock()
rtnl_lock()
...
  request_module() tcf_idr_check_alloc()
  rtnl_lock()

At this point, thread A is waiting for thread B to release RTNL
lock, while thread B is waiting for thread A to commit the IDR
change with tcf_idr_insert() later.

Break this deadlock situation by preloading ife modules earlier,
before tcf_idr_check_alloc(), this is fine because we only need
to load modules we need potentially.

Reported-and-tested-by: syzbot+80e32b5d1f9923f8ace6@syzkaller.appspotmail.com
Fixes: 0190c1d452a9 ("net: sched: atomically check-allocate action")
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Vlad Buslov <vladbu@mellanox.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/sched/act_ife.c