]> git.baikalelectronics.ru Git - kernel.git/commit
xdp: fix potential deadlock on socket mutex
authorIlya Maximets <i.maximets@samsung.com>
Mon, 8 Jul 2019 11:03:44 +0000 (14:03 +0300)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 12 Jul 2019 13:02:21 +0000 (15:02 +0200)
commit34d63e37aedb59870ab9b5e96e2eed34d2f468a3
treeb7d54d9aef6b6e95b7db08ad745aa5345b4a856f
parent1a7f7fab1a80ffc310d897edf755126ae5716e06
xdp: fix potential deadlock on socket mutex

There are 2 call chains:

  a) xsk_bind --> xdp_umem_assign_dev
  b) unregister_netdevice_queue --> xsk_notifier

with the following locking order:

  a) xs->mutex --> rtnl_lock
  b) rtnl_lock --> xdp.lock --> xs->mutex

Different order of taking 'xs->mutex' and 'rtnl_lock' could produce a
deadlock here. Fix that by moving the 'rtnl_lock' before 'xs->lock' in
the bind call chain (a).

Reported-by: syzbot+bf64ec93de836d7f4c2c@syzkaller.appspotmail.com
Fixes: a14c3cb3adf6 ("xdp: fix hang while unregistering device bound to xdp socket")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Jonathan Lemon <jonathan.lemon@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
net/xdp/xdp_umem.c
net/xdp/xsk.c