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)
283283
284284#if defined(CONFIG_KASAN ) && defined(CONFIG_KASAN_STACK )
285285void kasan_unpoison_task_stack (struct task_struct * task );
286+ asmlinkage void kasan_unpoison_task_stack_below (const void * watermark );
286287#else
287288static inline void kasan_unpoison_task_stack (struct task_struct * task ) {}
289+ static inline void kasan_unpoison_task_stack_below (const void * watermark ) {}
288290#endif
289291
290292#ifdef CONFIG_KASAN_GENERIC
Original file line number Diff line number Diff line change 2222#include <linux/security.h>
2323#include <linux/btf_ids.h>
2424#include <linux/bpf_mem_alloc.h>
25+ #include <linux/kasan.h>
2526
2627#include "../../lib/kstrtox.h"
2728
@@ -2463,6 +2464,11 @@ __bpf_kfunc void bpf_throw(u64 cookie)
24632464 WARN_ON_ONCE (!ctx .aux -> exception_boundary );
24642465 WARN_ON_ONCE (!ctx .bp );
24652466 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 );
24662472 ctx .aux -> bpf_exception_cb (cookie , ctx .sp , ctx .bp );
24672473}
24682474
You can’t perform that action at this time.
0 commit comments