Skip to content

Commit

Permalink
kasan: call kasan_malloc() from __kmalloc_*track_caller()
Browse files Browse the repository at this point in the history
commit 5373b8a upstream.

We were failing to call kasan_malloc() from __kmalloc_*track_caller()
which was causing us to sometimes fail to produce KASAN error reports
for allocations made using e.g. devm_kcalloc(), as the KASAN poison was
not being initialized. Fix it.

Signed-off-by: Peter Collingbourne <pcc@google.com>
Cc: <stable@vger.kernel.org> # 5.15
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
pcc authored and gregkh committed Sep 28, 2022
1 parent dc8864f commit b6c2ad6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -4950,6 +4950,8 @@ void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, unsigned long caller)
/* Honor the call site pointer we received. */
trace_kmalloc(caller, ret, size, s->size, gfpflags);

ret = kasan_kmalloc(s, ret, size, gfpflags);

return ret;
}
EXPORT_SYMBOL(__kmalloc_track_caller);
Expand Down Expand Up @@ -4981,6 +4983,8 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
/* Honor the call site pointer we received. */
trace_kmalloc_node(caller, ret, size, s->size, gfpflags, node);

ret = kasan_kmalloc(s, ret, size, gfpflags);

return ret;
}
EXPORT_SYMBOL(__kmalloc_node_track_caller);
Expand Down

0 comments on commit b6c2ad6

Please sign in to comment.