mm/slab_common: Restore passing "caller" for tracing

Message ID 20221105063529.never.818-kees@kernel.org
State New
Headers
Series mm/slab_common: Restore passing "caller" for tracing |

Commit Message

Kees Cook Nov. 5, 2022, 6:35 a.m. UTC
  The "caller" argument was accidentally being ignored in a few places
that were recently refactored. Restore these "caller" arguments, instead
of _RET_IP_.

Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: linux-mm@kvack.org
Fixes: 11e9734bcb6a ("mm/slab_common: unify NUMA and UMA version of tracepoints")
Cc: stable@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 mm/slab_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Hyeonggon Yoo Nov. 6, 2022, 10:46 a.m. UTC | #1
On Fri, Nov 04, 2022 at 11:35:34PM -0700, Kees Cook wrote:
> The "caller" argument was accidentally being ignored in a few places
> that were recently refactored. Restore these "caller" arguments, instead
> of _RET_IP_.
> 
> Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>

Acked-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>

> Cc: Vlastimil Babka <vbabka@suse.cz>
> Cc: Christoph Lameter <cl@linux.com>
> Cc: Pekka Enberg <penberg@kernel.org>
> Cc: David Rientjes <rientjes@google.com>
> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Roman Gushchin <roman.gushchin@linux.dev>
> Cc: linux-mm@kvack.org
> Fixes: 11e9734bcb6a ("mm/slab_common: unify NUMA and UMA version of tracepoints")
> Cc: stable@vger.kernel.org


BTW I think it can be just sent to next release candidate.
The referred commit was merged in this development cycle.

> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  mm/slab_common.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/slab_common.c b/mm/slab_common.c
> index 33b1886b06eb..0e614f9e7ed7 100644
> --- a/mm/slab_common.c
> +++ b/mm/slab_common.c
> @@ -941,7 +941,7 @@ void *__do_kmalloc_node(size_t size, gfp_t flags, int node, unsigned long caller
>  
>  	if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) {
>  		ret = __kmalloc_large_node(size, flags, node);
> -		trace_kmalloc(_RET_IP_, ret, size,
> +		trace_kmalloc(caller, ret, size,
>  			      PAGE_SIZE << get_order(size), flags, node);
>  		return ret;
>  	}
> @@ -953,7 +953,7 @@ void *__do_kmalloc_node(size_t size, gfp_t flags, int node, unsigned long caller
>  
>  	ret = __kmem_cache_alloc_node(s, flags, node, size, caller);
>  	ret = kasan_kmalloc(s, ret, size, flags);
> -	trace_kmalloc(_RET_IP_, ret, size, s->size, flags, node);
> +	trace_kmalloc(caller, ret, size, s->size, flags, node);
>  	return ret;
>  }
>  
> -- 
> 2.34.1


Thanks for catching this!
  
Vlastimil Babka Nov. 6, 2022, 8:23 p.m. UTC | #2
On 11/6/22 11:46, Hyeonggon Yoo wrote:
> On Fri, Nov 04, 2022 at 11:35:34PM -0700, Kees Cook wrote:
>> The "caller" argument was accidentally being ignored in a few places
>> that were recently refactored. Restore these "caller" arguments, instead
>> of _RET_IP_.
>> 
>> Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>
> 
> Acked-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
> 
>> Cc: Vlastimil Babka <vbabka@suse.cz>
>> Cc: Christoph Lameter <cl@linux.com>
>> Cc: Pekka Enberg <penberg@kernel.org>
>> Cc: David Rientjes <rientjes@google.com>
>> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: Roman Gushchin <roman.gushchin@linux.dev>
>> Cc: linux-mm@kvack.org
>> Fixes: 11e9734bcb6a ("mm/slab_common: unify NUMA and UMA version of tracepoints")
>> Cc: stable@vger.kernel.org
> 
> 
> BTW I think it can be just sent to next release candidate.
> The referred commit was merged in this development cycle.

Yep, dropped the Cc stable for that reason. Pushed to
slab/for-6.1-rc4/fixes and will send a PR to Linus in few days.
Thanks!

>> Signed-off-by: Kees Cook <keescook@chromium.org>
>> ---
>>  mm/slab_common.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/mm/slab_common.c b/mm/slab_common.c
>> index 33b1886b06eb..0e614f9e7ed7 100644
>> --- a/mm/slab_common.c
>> +++ b/mm/slab_common.c
>> @@ -941,7 +941,7 @@ void *__do_kmalloc_node(size_t size, gfp_t flags, int node, unsigned long caller
>>  
>>  	if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) {
>>  		ret = __kmalloc_large_node(size, flags, node);
>> -		trace_kmalloc(_RET_IP_, ret, size,
>> +		trace_kmalloc(caller, ret, size,
>>  			      PAGE_SIZE << get_order(size), flags, node);
>>  		return ret;
>>  	}
>> @@ -953,7 +953,7 @@ void *__do_kmalloc_node(size_t size, gfp_t flags, int node, unsigned long caller
>>  
>>  	ret = __kmem_cache_alloc_node(s, flags, node, size, caller);
>>  	ret = kasan_kmalloc(s, ret, size, flags);
>> -	trace_kmalloc(_RET_IP_, ret, size, s->size, flags, node);
>> +	trace_kmalloc(caller, ret, size, s->size, flags, node);
>>  	return ret;
>>  }
>>  
>> -- 
>> 2.34.1
> 
> 
> Thanks for catching this!
>
  

Patch

diff --git a/mm/slab_common.c b/mm/slab_common.c
index 33b1886b06eb..0e614f9e7ed7 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -941,7 +941,7 @@  void *__do_kmalloc_node(size_t size, gfp_t flags, int node, unsigned long caller
 
 	if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) {
 		ret = __kmalloc_large_node(size, flags, node);
-		trace_kmalloc(_RET_IP_, ret, size,
+		trace_kmalloc(caller, ret, size,
 			      PAGE_SIZE << get_order(size), flags, node);
 		return ret;
 	}
@@ -953,7 +953,7 @@  void *__do_kmalloc_node(size_t size, gfp_t flags, int node, unsigned long caller
 
 	ret = __kmem_cache_alloc_node(s, flags, node, size, caller);
 	ret = kasan_kmalloc(s, ret, size, flags);
-	trace_kmalloc(_RET_IP_, ret, size, s->size, flags, node);
+	trace_kmalloc(caller, ret, size, s->size, flags, node);
 	return ret;
 }