]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
wireguard: queueing: use CFI-safe ptr_ring cleanup function
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 30 Mar 2022 01:31:24 +0000 (21:31 -0400)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 27 Apr 2022 09:58:45 +0000 (11:58 +0200)
BugLink: https://bugs.launchpad.net/bugs/1969110
commit ec59f128a9bd4255798abb1e06ac3b442f46ef68 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 6a7245252fdc63f8f651f26d6ee80aed37f0869b)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/net/wireguard/queueing.c

index 1de413b19e3424a2ace2edcbcf0d0d49c4be6167..8084e7408c0ae9065f57bc463921cb985fd68c5e 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include "queueing.h"
+#include <linux/skb_array.h>
 
 struct multicore_worker __percpu *
 wg_packet_percpu_multicore_worker_alloc(work_func_t function, void *ptr)
@@ -42,7 +43,7 @@ void wg_packet_queue_free(struct crypt_queue *queue, bool purge)
 {
        free_percpu(queue->worker);
        WARN_ON(!purge && !__ptr_ring_empty(&queue->ring));
-       ptr_ring_cleanup(&queue->ring, purge ? (void(*)(void*))kfree_skb : NULL);
+       ptr_ring_cleanup(&queue->ring, purge ? __skb_array_destroy_skb : NULL);
 }
 
 #define NEXT(skb) ((skb)->prev)