Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'slab-for-6.1-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab

Pull slab fixes from Vlastimil Babka:
"Most are small fixups as described below.

The !CONFIG_TRACING fix is a bit bigger and would normally be done in
the next merge window as part of upcoming hardening changes. But we
realized it can make the kmalloc waste tracking introduced in this
window inaccurate, so decided to go with it now.

Summary:

- Remove !CONFIG_TRACING kmalloc() wrappers intended to save a
function call, due to incompatilibity with recently introduced
wasted space tracking and planned hardening changes.

- A tracing parameter regression fix, by Kees Cook.

- Two kernel-doc warning fixups, by Lukas Bulwahn and myself

* tag 'slab-for-6.1-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab:
mm, slab: remove duplicate kernel-doc comment for ksize()
mm/slab_common: Restore passing "caller" for tracing
mm/slab: remove !CONFIG_TRACING variants of kmalloc_[node_]trace()
mm/slab_common: repair kernel-doc for __ksize()

+4 -43
-23
include/linux/slab.h
··· 470 470 void *kmem_cache_alloc_node(struct kmem_cache *s, gfp_t flags, int node) __assume_slab_alignment 471 471 __malloc; 472 472 473 - #ifdef CONFIG_TRACING 474 473 void *kmalloc_trace(struct kmem_cache *s, gfp_t flags, size_t size) 475 474 __assume_kmalloc_alignment __alloc_size(3); 476 475 477 476 void *kmalloc_node_trace(struct kmem_cache *s, gfp_t gfpflags, 478 477 int node, size_t size) __assume_kmalloc_alignment 479 478 __alloc_size(4); 480 - #else /* CONFIG_TRACING */ 481 - /* Save a function call when CONFIG_TRACING=n */ 482 - static __always_inline __alloc_size(3) 483 - void *kmalloc_trace(struct kmem_cache *s, gfp_t flags, size_t size) 484 - { 485 - void *ret = kmem_cache_alloc(s, flags); 486 - 487 - ret = kasan_kmalloc(s, ret, size, flags); 488 - return ret; 489 - } 490 - 491 - static __always_inline __alloc_size(4) 492 - void *kmalloc_node_trace(struct kmem_cache *s, gfp_t gfpflags, 493 - int node, size_t size) 494 - { 495 - void *ret = kmem_cache_alloc_node(s, gfpflags, node); 496 - 497 - ret = kasan_kmalloc(s, ret, size, gfpflags); 498 - return ret; 499 - } 500 - #endif /* CONFIG_TRACING */ 501 - 502 479 void *kmalloc_large(size_t size, gfp_t flags) __assume_page_alignment 503 480 __alloc_size(1); 504 481
+4 -20
mm/slab_common.c
··· 941 941 942 942 if (unlikely(size > KMALLOC_MAX_CACHE_SIZE)) { 943 943 ret = __kmalloc_large_node(size, flags, node); 944 - trace_kmalloc(_RET_IP_, ret, size, 944 + trace_kmalloc(caller, ret, size, 945 945 PAGE_SIZE << get_order(size), flags, node); 946 946 return ret; 947 947 } ··· 953 953 954 954 ret = __kmem_cache_alloc_node(s, flags, node, size, caller); 955 955 ret = kasan_kmalloc(s, ret, size, flags); 956 - trace_kmalloc(_RET_IP_, ret, size, s->size, flags, node); 956 + trace_kmalloc(caller, ret, size, s->size, flags, node); 957 957 return ret; 958 958 } 959 959 ··· 1010 1010 1011 1011 /** 1012 1012 * __ksize -- Report full size of underlying allocation 1013 - * @objp: pointer to the object 1013 + * @object: pointer to the object 1014 1014 * 1015 1015 * This should only be used internally to query the true size of allocations. 1016 1016 * It is not meant to be a way to discover the usable size of an allocation ··· 1018 1018 * the originally requested allocation size may trigger KASAN, UBSAN_BOUNDS, 1019 1019 * and/or FORTIFY_SOURCE. 1020 1020 * 1021 - * Return: size of the actual memory used by @objp in bytes 1021 + * Return: size of the actual memory used by @object in bytes 1022 1022 */ 1023 1023 size_t __ksize(const void *object) 1024 1024 { ··· 1040 1040 return slab_ksize(folio_slab(folio)->slab_cache); 1041 1041 } 1042 1042 1043 - #ifdef CONFIG_TRACING 1044 1043 void *kmalloc_trace(struct kmem_cache *s, gfp_t gfpflags, size_t size) 1045 1044 { 1046 1045 void *ret = __kmem_cache_alloc_node(s, gfpflags, NUMA_NO_NODE, ··· 1063 1064 return ret; 1064 1065 } 1065 1066 EXPORT_SYMBOL(kmalloc_node_trace); 1066 - #endif /* !CONFIG_TRACING */ 1067 1067 #endif /* !CONFIG_SLOB */ 1068 1068 1069 1069 gfp_t kmalloc_fix_flags(gfp_t flags) ··· 1409 1411 } 1410 1412 EXPORT_SYMBOL(kfree_sensitive); 1411 1413 1412 - /** 1413 - * ksize - get the actual amount of memory allocated for a given object 1414 - * @objp: Pointer to the object 1415 - * 1416 - * kmalloc may internally round up allocations and return more memory 1417 - * than requested. ksize() can be used to determine the actual amount of 1418 - * memory allocated. The caller may use this additional memory, even though 1419 - * a smaller amount of memory was initially specified with the kmalloc call. 1420 - * The caller must guarantee that objp points to a valid object previously 1421 - * allocated with either kmalloc() or kmem_cache_alloc(). The object 1422 - * must not be freed during the duration of the call. 1423 - * 1424 - * Return: size of the actual memory used by @objp in bytes 1425 - */ 1426 1414 size_t ksize(const void *objp) 1427 1415 { 1428 1416 size_t size;