Patch "tracing: Fix potential null-pointer-access of entry in list 'tr->err_log'" has been added to the 6.0-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    tracing: Fix potential null-pointer-access of entry in list 'tr->err_log'

to the 6.0-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     tracing-fix-potential-null-pointer-access-of-entry-i.patch
and it can be found in the queue-6.0 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit b679f6ae7c244262ea01122ef5549c8d6859feeb
Author: Zheng Yejian <zhengyejian1@xxxxxxxxxx>
Date:   Mon Nov 14 18:46:32 2022 +0800

    tracing: Fix potential null-pointer-access of entry in list 'tr->err_log'
    
    [ Upstream commit 067df9e0ad48a97382ab2179bbe773a13a846028 ]
    
    Entries in list 'tr->err_log' will be reused after entry number
    exceed TRACING_LOG_ERRS_MAX.
    
    The cmd string of the to be reused entry will be freed first then
    allocated a new one. If the allocation failed, then the entry will
    still be in list 'tr->err_log' but its 'cmd' field is set to be NULL,
    later access of 'cmd' is risky.
    
    Currently above problem can cause the loss of 'cmd' information of first
    entry in 'tr->err_log'. When execute `cat /sys/kernel/tracing/error_log`,
    reproduce logs like:
      [   37.495100] trace_kprobe: error: Maxactive is not for kprobe(null) ^
      [   38.412517] trace_kprobe: error: Maxactive is not for kprobe
        Command: p4:myprobe2 do_sys_openat2
                ^
    
    Link: https://lore.kernel.org/linux-trace-kernel/20221114104632.3547266-1-zhengyejian1@xxxxxxxxxx
    
    Fixes: 1581a884b7ca ("tracing: Remove size restriction on tracing_log_err cmd strings")
    Signed-off-by: Zheng Yejian <zhengyejian1@xxxxxxxxxx>
    Acked-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
    Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 87d2f04152f9..7132e21e90d6 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -7803,6 +7803,7 @@ static struct tracing_log_err *get_tracing_log_err(struct trace_array *tr,
 						   int len)
 {
 	struct tracing_log_err *err;
+	char *cmd;
 
 	if (tr->n_err_log_entries < TRACING_LOG_ERRS_MAX) {
 		err = alloc_tracing_log_err(len);
@@ -7811,12 +7812,12 @@ static struct tracing_log_err *get_tracing_log_err(struct trace_array *tr,
 
 		return err;
 	}
-
+	cmd = kzalloc(len, GFP_KERNEL);
+	if (!cmd)
+		return ERR_PTR(-ENOMEM);
 	err = list_first_entry(&tr->err_log, struct tracing_log_err, list);
 	kfree(err->cmd);
-	err->cmd = kzalloc(len, GFP_KERNEL);
-	if (!err->cmd)
-		return ERR_PTR(-ENOMEM);
+	err->cmd = cmd;
 	list_del(&err->list);
 
 	return err;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux