Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wireguard: queueing: use CFI-safe ptr_ring cleanup function

We make too nuanced use of ptr_ring to entirely move to the skb_array
wrappers, but we at least should avoid the naughty function pointer cast
when cleaning up skbs. Otherwise RAP/CFI will honk at us. This patch
uses the __skb_array_destroy_skb wrapper for the cleanup, rather than
directly providing kfree_skb, which is what other drivers in the same
situation do too.

Reported-by: PaX Team <pageexec@freemail.hu>
Fixes: 886fcee939ad ("wireguard: receive: use ring buffer for incoming handshakes")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Jason A. Donenfeld and committed by
Jakub Kicinski
ec59f128 c9ad266b

+2 -1
+2 -1
drivers/net/wireguard/queueing.c
··· 4 4 */ 5 5 6 6 #include "queueing.h" 7 + #include <linux/skb_array.h> 7 8 8 9 struct multicore_worker __percpu * 9 10 wg_packet_percpu_multicore_worker_alloc(work_func_t function, void *ptr) ··· 43 42 { 44 43 free_percpu(queue->worker); 45 44 WARN_ON(!purge && !__ptr_ring_empty(&queue->ring)); 46 - ptr_ring_cleanup(&queue->ring, purge ? (void(*)(void*))kfree_skb : NULL); 45 + ptr_ring_cleanup(&queue->ring, purge ? __skb_array_destroy_skb : NULL); 47 46 } 48 47 49 48 #define NEXT(skb) ((skb)->prev)