kasan: call kasan_malloc() from __kmalloc_*track_caller()
Subsystems (3)
PATCH 1/1 kasan: call kasan_malloc() from __kmalloc_*track_caller()
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.
---
The same problem is being fixed upstream in:
https://lore.kernel.org/all/[email protected]/
as part of a larger patch series, but this more targeted fix seems more suitable for the stable kernel. Hyeonggon, maybe you can add this patch to the start of your series and it can be picked up by the stable maintainers.
mm/slub.c | 4 ++++ 1 file changed, 4 insertions(+)
mm/slub.c +4 -0
@@ -4926,6 +4926,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, s, size, s->size, gfpflags); + ret =kasan_kmalloc (s, ret, size, gfpflags); +return ret; }EXPORT_SYMBOL (__kmalloc_track_caller);
@@ -4957,6 +4959,8 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,/* Honor the call site pointer we received. */ trace_kmalloc_node (caller, ret, s, size, s->size, gfpflags, node); + ret =kasan_kmalloc (s, ret, size, gfpflags); +return ret; }EXPORT_SYMBOL (__kmalloc_node_track_caller);
Signature · 1 line
2.37.2.789.g6183377224-goog
Quoted 43 lines · Peter Collingbourne
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 <[email protected]>Cc <[email protected]> # 5.15---
The same problem is being fixed upstream in:
https://lore.kernel.org/all/[email protected]/
as part of a larger patch series, but this more targeted fix seems more suitable for the stable kernel. Hyeonggon, maybe you can add this patch to the start of your series and it can be picked up by the stable maintainers.mm/slub.c | 4 ++++ 1 file changed, 4 insertions(+)mm/slub.c +4
-0@@ -4926,6 +4926,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, s, size, s->size, gfpflags); + ret =kasan_kmalloc (s, ret, size, gfpflags); +return ret; }EXPORT_SYMBOL (__kmalloc_track_caller);@@ -4957,6 +4959,8 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,/* Honor the call site pointer we received. */ trace_kmalloc_node (caller, ret, s, size, s->size, gfpflags, node); + ret =kasan_kmalloc (s, ret, size, gfpflags); +return ret; }EXPORT_SYMBOL (__kmalloc_node_track_caller);Signature · 1 line
2.37.2.789.g6183377224-goog
Ah, I should have sent it to stable team ;)
I think "Option 3" in Documentation/process/stable-kernel-rules.rst will be appropriate, So will resend this after the series goes to Linus's tree.
Thank you Peter!
Signature · 2 lines
Thanks, Hyeonggon
On 9/14/22 08:52, Hyeonggon Yoo wrote:
Thanks for the Cc.
Quoted 10 lines · Peter Collingbourne
Quoted 9 lines
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 <[email protected]>Cc <[email protected]> # 5.15---
The same problem is being fixed upstream in:
The "upstream" here is now only in -next, not mainline yet, so we still have more options at this point.
Quoted 5 lines
Quoted 5 lines
https://lore.kernel.org/all/[email protected]/
as part of a larger patch series, but this more targeted fix seems more suitable for the stable kernel. Hyeonggon, maybe you can add this patch to the start of your series and it can be picked up by the stable maintainers.
...
Quoted 5 lines
Ah, I should have sent it to stable team ;)
I think "Option 3" in
Documentation/process/stable-kernel-rules.rstwill be appropriate, So will resend this after the series goes to Linus's tree.
I'll pick this for sending to Linus after rc6, which means the series in slab.git / -next will afterwards cause a trivial conflict to resolve when merging. AFAIK Linus prefers that over late rebasing. It will also make it simple for stable.
Quoted 2 lines
Thank you Peter!
Quoted 27 lines · Vlastimil Babka
On 9/14/22 08:52, Hyeonggon Yoo wrote:
Thanks for the Cc.
Quoted 10 lines · Peter Collingbourne
Quoted 9 lines
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 <[email protected]>Cc <[email protected]> # 5.15---
The same problem is being fixed upstream in:The "upstream" here is now only in -next, not mainline yet, so we still have more options at this point.
Quoted 5 lines
Quoted 5 lines
https://lore.kernel.org/all/[email protected]/
as part of a larger patch series, but this more targeted fix seems more suitable for the stable kernel. Hyeonggon, maybe you can add this patch to the start of your series and it can be picked up by the stable maintainers....
Quoted 3 lines
Ah, I should have sent it to stable team ;)
Quoted 7 lines
Quoted 2 lines
I think "Option 3" in
Documentation/process/stable-kernel-rules.rstwill be appropriate, So will resend this after the series goes to Linus's tree.I'll pick this for sending to Linus after rc6, which means the series in slab.git / -next will afterwards cause a trivial conflict to resolve when merging. AFAIK Linus prefers that over late rebasing. It will also make it simple for stable.
I think that is better option, thanks!
Quoted 4 lines
Quoted 3 lines
Thank you Peter!
Signature · 2 lines
Thanks, Hyeonggon