lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221123111001.34855-1-jiasheng@iscas.ac.cn>
Date:   Wed, 23 Nov 2022 19:10:01 +0800
From:   Jiasheng Jiang <jiasheng@...as.ac.cn>
To:     rostedt@...dmis.org, mhiramat@...nel.org, vbabka@...e.cz,
        42.hyeyoo@...il.com, vasily.averin@...ux.dev,
        akpm@...ux-foundation.org, shakeelb@...gle.com,
        vvghjk1234@...il.com
Cc:     linux-kernel@...r.kernel.org, Jiasheng Jiang <jiasheng@...as.ac.cn>
Subject: [PATCH] mm/tracing: Add check for kmem_cache

In __kmem_cache_alloc_lru() of mm/slab.c, cachep may be NULL when error
occurs in slab_alloc().
However, trace_kmem_cache_alloc() will still use it as the parameter,
which may cause NULL poineter dereference.
Therefore, it should be better to add the check and handle the error
in the trace_kmem_cache_alloc().

Fixes: 36555751c675 ("kmemtrace: SLAB hooks.")
Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
---
 include/trace/events/kmem.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
index 243073cfc29d..d99507d32ef5 100644
--- a/include/trace/events/kmem.h
+++ b/include/trace/events/kmem.h
@@ -32,8 +32,8 @@ TRACE_EVENT(kmem_cache_alloc,
 	TP_fast_assign(
 		__entry->call_site	= call_site;
 		__entry->ptr		= ptr;
-		__entry->bytes_req	= s->object_size;
-		__entry->bytes_alloc	= s->size;
+		__entry->bytes_req	= s ? s->object_size : 0;
+		__entry->bytes_alloc	= s ? s->size : 0;
 		__entry->gfp_flags	= (__force unsigned long)gfp_flags;
 		__entry->node		= node;
 		__entry->accounted	= IS_ENABLED(CONFIG_MEMCG_KMEM) ?
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ