]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: cpumap fix potential lost wake-up problem
authorJesper Dangaard Brouer <brouer@redhat.com>
Mon, 23 Oct 2017 17:39:28 +0000 (19:39 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 24 Oct 2017 09:40:22 +0000 (18:40 +0900)
commit98e3ac82cfea9f43d551f7d5e52b59429fdb07da
tree33d083824b454cd344121d6ef8ed2ac1d37afeb4
parentd2b1521f183020dadafb6a3375c93f67e5c2b414
bpf: cpumap fix potential lost wake-up problem

As pointed out by Michael, commit bd6f29b9a9f6 ("bpf: cpumap xdp_buff
to skb conversion and allocation") contains a classical example of the
potential lost wake-up problem.

We need to recheck the condition __ptr_ring_empty() after changing
current->state to TASK_INTERRUPTIBLE, this avoids a race between
wake_up_process() and schedule(). After this, a race with
wake_up_process() will simply change the state to TASK_RUNNING, and
the schedule() call not really put us to sleep.

Fixes: bd6f29b9a9f6 ("bpf: cpumap xdp_buff to skb conversion and allocation")
Reported-by: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
kernel/bpf/cpumap.c