]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
skbuff: Fix a potential race while recycling page_pool packets
authorIlias Apalodimas <ilias.apalodimas@linaro.org>
Fri, 16 Jul 2021 07:02:18 +0000 (10:02 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 16 Jul 2021 18:37:00 +0000 (11:37 -0700)
commit2cc3aeb5ecccec0d266813172fcd82b4b5fa5803
tree2f8486b71126e60458c257fd72c0561a8e68b8e6
parent20192d9c9f6ae447c461285c915502ffbddf5696
skbuff: Fix a potential race while recycling page_pool packets

As Alexander points out, when we are trying to recycle a cloned/expanded
SKB we might trigger a race.  The recycling code relies on the
pp_recycle bit to trigger,  which we carry over to cloned SKBs.
If that cloned SKB gets expanded or if we get references to the frags,
call skb_release_data() and overwrite skb->head, we are creating separate
instances accessing the same page frags.  Since the skb_release_data()
will first try to recycle the frags,  there's a potential race between
the original and cloned SKB, since both will have the pp_recycle bit set.

Fix this by explicitly those SKBs not recyclable.
The atomic_sub_return effectively limits us to a single release case,
and when we are calling skb_release_data we are also releasing the
option to perform the recycling, or releasing the pages from the page pool.

Fixes: 6a5bcd84e886 ("page_pool: Allow drivers to hint on SKB recycling")
Reported-by: Alexander Duyck <alexanderduyck@fb.com>
Suggested-by: Alexander Duyck <alexanderduyck@fb.com>
Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/skbuff.c