xsk: Fix crash in poll when device does not support ndo_xsk_wakeup
authorMagnus Karlsson <magnus.karlsson@intel.com>
Wed, 2 Oct 2019 06:31:59 +0000 (08:31 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 3 Oct 2019 14:34:27 +0000 (16:34 +0200)
commitdf551058f7a303bd3a17a4cef001349974962ce8
tree360e624c558bbb4f5a8c419c410d6aff8e61c557
parente55190f26f92927e95aba22b069679311d5379ea
xsk: Fix crash in poll when device does not support ndo_xsk_wakeup

Fixes a crash in poll() when an AF_XDP socket is opened in copy mode
and the bound device does not have ndo_xsk_wakeup defined. Avoid
trying to call the non-existing ndo and instead call the internal xsk
sendmsg function to send packets in the same way (from the
application's point of view) as calling sendmsg() in any mode or
poll() in zero-copy mode would have done. The application should
behave in the same way independent on if zero-copy mode or copy mode
is used.

Fixes: 77cd0d7b3f25 ("xsk: add support for need_wakeup flag in AF_XDP rings")
Reported-by: syzbot+a5765ed8cdb1cca4d249@syzkaller.appspotmail.com
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/1569997919-11541-1-git-send-email-magnus.karlsson@intel.com
net/xdp/xsk.c