File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -283,8 +283,10 @@ static inline bool kasan_check_byte(const void *address)
283
283
284
284
#if defined(CONFIG_KASAN ) && defined(CONFIG_KASAN_STACK )
285
285
void kasan_unpoison_task_stack (struct task_struct * task );
286
+ asmlinkage void kasan_unpoison_task_stack_below (const void * watermark );
286
287
#else
287
288
static inline void kasan_unpoison_task_stack (struct task_struct * task ) {}
289
+ static inline void kasan_unpoison_task_stack_below (const void * watermark ) {}
288
290
#endif
289
291
290
292
#ifdef CONFIG_KASAN_GENERIC
Original file line number Diff line number Diff line change 22
22
#include <linux/security.h>
23
23
#include <linux/btf_ids.h>
24
24
#include <linux/bpf_mem_alloc.h>
25
+ #include <linux/kasan.h>
25
26
26
27
#include "../../lib/kstrtox.h"
27
28
@@ -2463,6 +2464,11 @@ __bpf_kfunc void bpf_throw(u64 cookie)
2463
2464
WARN_ON_ONCE (!ctx .aux -> exception_boundary );
2464
2465
WARN_ON_ONCE (!ctx .bp );
2465
2466
WARN_ON_ONCE (!ctx .cnt );
2467
+ /* Prevent KASAN false positives for CONFIG_KASAN_STACK by unpoisoning
2468
+ * deeper stack depths than ctx.sp as we do not return from bpf_throw,
2469
+ * which skips compiler generated instrumentation to do the same.
2470
+ */
2471
+ kasan_unpoison_task_stack_below ((void * )ctx .sp );
2466
2472
ctx .aux -> bpf_exception_cb (cookie , ctx .sp , ctx .bp );
2467
2473
}
2468
2474
You can’t perform that action at this time.
0 commit comments