Skip to content

Commit 4eff63d

Browse files
committed
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> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
1 parent 273018b commit 4eff63d

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/compat/Kbuild.include

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ ifeq ($(wildcard $(srctree)/include/linux/ptr_ring.h),)
1212
ccflags-y += -I$(kbuild-dir)/compat/ptr_ring/include
1313
endif
1414

15+
ifeq ($(wildcard $(srctree)/include/linux/skb_array.h),)
16+
ccflags-y += -I$(kbuild-dir)/compat/skb_array/include
17+
endif
18+
1519
ifeq ($(wildcard $(srctree)/include/linux/siphash.h),)
1620
ccflags-y += -I$(kbuild-dir)/compat/siphash/include
1721
wireguard-y += compat/siphash/siphash.o
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#ifndef _WG_SKB_ARRAY_H
2+
#define _WG_SKB_ARRAY_H
3+
4+
#include <linux/skbuff.h>
5+
6+
static void __skb_array_destroy_skb(void *ptr)
7+
{
8+
kfree_skb(ptr);
9+
}
10+
11+
#endif

src/queueing.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
#include "queueing.h"
7+
#include <linux/skb_array.h>
78

89
struct multicore_worker __percpu *
910
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)
4243
{
4344
free_percpu(queue->worker);
4445
WARN_ON(!purge && !__ptr_ring_empty(&queue->ring));
45-
ptr_ring_cleanup(&queue->ring, purge ? (void(*)(void*))kfree_skb : NULL);
46+
ptr_ring_cleanup(&queue->ring, purge ? __skb_array_destroy_skb : NULL);
4647
}
4748

4849
#define NEXT(skb) ((skb)->prev)

0 commit comments

Comments
 (0)