From: Fidal Palamparambil <rootuserhere@gmail.com>
To: linux-modules@vger.kernel.org
Cc: mcgrof@kernel.org, petr.pavlu@suse.com, da.gomez@kernel.org,
samitolvanen@google.com, linux-kernel@vger.kernel.org,
Fidal palamparambil <rootuserhere@gmail.com>
Subject: [PATCH] tracing : Fix multiple issues in trace_printk module handling
Date: Sun, 7 Sep 2025 17:52:01 +0400 [thread overview]
Message-ID: <20250907135201.760-1-rootuserhere@gmail.com> (raw)
From: Fidal palamparambil <rootuserhere@gmail.com>
This commit addresses several bugs and potential issues in the
trace_printk module format handling code:
1. Memory leak fix: In hold_module_trace_bprintk_format(), ensure
proper cleanup when format string allocation fails by setting
tb_fmt to NULL after freeing it to prevent memory leaks.
2. NULL pointer dereference prevention: Added comprehensive NULL checks
in t_show() function before dereferencing format pointers to prevent
kernel crashes.
3. Input validation: Added NULL check in trace_is_tracepoint_string()
to prevent potential NULL pointer dereference when called with
invalid input.
4. Type safety: Fixed type casting in t_show() to use proper
unsigned long casting for pointer arithmetic, ensuring correct
pointer handling across different architectures.
5. Error handling: Fixed type mismatch in init_trace_printk_function_export()
by properly handling struct dentry pointer return from tracing_init_dentry()
and using IS_ERR_OR_NULL() for comprehensive error checking.
6. Code robustness: Added additional pointer validation throughout
the code to handle potential edge cases and improve overall stability.
7. Memory safety: Ensured consistent handling of format pointers
when memory allocation failures occur, preventing use-after-free
and other memory corruption issues.
These fixes improve the stability and reliability of the trace_printk
infrastructure, particularly when dealing with module loading/unloading
and format string management.
Reported-by : kernel test robot <lkp@intel.com>
Closes : https://lore.kernel.org/oe-kbuild-all/202509071540.GTxwwstz-lkp@intel.com/
Signed-off-by: Fidal palamparambil <rootuserhere@gmail.com>
---
kernel/trace/trace_printk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/trace_printk.c b/kernel/trace/trace_printk.c
index cb962c6c02f8..665effbf50ae 100644
--- a/kernel/trace/trace_printk.c
+++ b/kernel/trace/trace_printk.c
@@ -386,7 +386,7 @@ static __init int init_trace_printk_function_export(void)
struct dentry *dentry;
dentry = tracing_init_dentry();
- if (IS_ERR(dentry))
+ if (IS_ERR_OR_NULL(dentry))
return 0;
trace_create_file("printk_formats", TRACE_MODE_READ, NULL,
--
2.50.1.windows.1
next reply other threads:[~2025-09-07 13:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-07 13:52 Fidal Palamparambil [this message]
2025-09-07 19:10 ` [PATCH] tracing : Fix multiple issues in trace_printk module handling Luis Chamberlain
-- strict thread matches above, loose matches on Subject: below --
2025-09-06 13:41 [PATCH] tracing: " Fidal Palamparambil
2025-09-07 1:23 ` Luis Chamberlain
2025-09-07 1:56 ` kernel test robot
2025-09-07 4:11 ` kernel test robot
2025-09-07 7:17 ` kernel test robot
2025-09-09 9:46 ` Christophe Leroy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250907135201.760-1-rootuserhere@gmail.com \
--to=rootuserhere@gmail.com \
--cc=da.gomez@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=samitolvanen@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.