mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-03 00:54:09 +08:00
2933d3cd07
strlcpy() reads the entire source buffer first. This read may exceed the destination size limit. This is both inefficient and can lead to linear read overflows if a source string is not NUL-terminated [1]. In an effort to remove strlcpy() completely [2], replace strlcpy() here with strscpy(). No return values were used, so direct replacement is safe. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy [2] https://github.com/KSPP/linux/issues/89 Link: https://lore.kernel.org/linux-trace-kernel/20230831194212.1529941-1-azeemshaikh38@gmail.com Cc: Masami Hiramatsu <mhiramat@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Azeem Shaikh <azeemshaikh38@gmail.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
63 lines
1.5 KiB
C
63 lines
1.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#undef TRACE_SYSTEM
|
|
#define TRACE_SYSTEM task
|
|
|
|
#if !defined(_TRACE_TASK_H) || defined(TRACE_HEADER_MULTI_READ)
|
|
#define _TRACE_TASK_H
|
|
#include <linux/tracepoint.h>
|
|
|
|
TRACE_EVENT(task_newtask,
|
|
|
|
TP_PROTO(struct task_struct *task, unsigned long clone_flags),
|
|
|
|
TP_ARGS(task, clone_flags),
|
|
|
|
TP_STRUCT__entry(
|
|
__field( pid_t, pid)
|
|
__array( char, comm, TASK_COMM_LEN)
|
|
__field( unsigned long, clone_flags)
|
|
__field( short, oom_score_adj)
|
|
),
|
|
|
|
TP_fast_assign(
|
|
__entry->pid = task->pid;
|
|
memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
|
|
__entry->clone_flags = clone_flags;
|
|
__entry->oom_score_adj = task->signal->oom_score_adj;
|
|
),
|
|
|
|
TP_printk("pid=%d comm=%s clone_flags=%lx oom_score_adj=%hd",
|
|
__entry->pid, __entry->comm,
|
|
__entry->clone_flags, __entry->oom_score_adj)
|
|
);
|
|
|
|
TRACE_EVENT(task_rename,
|
|
|
|
TP_PROTO(struct task_struct *task, const char *comm),
|
|
|
|
TP_ARGS(task, comm),
|
|
|
|
TP_STRUCT__entry(
|
|
__field( pid_t, pid)
|
|
__array( char, oldcomm, TASK_COMM_LEN)
|
|
__array( char, newcomm, TASK_COMM_LEN)
|
|
__field( short, oom_score_adj)
|
|
),
|
|
|
|
TP_fast_assign(
|
|
__entry->pid = task->pid;
|
|
memcpy(entry->oldcomm, task->comm, TASK_COMM_LEN);
|
|
strscpy(entry->newcomm, comm, TASK_COMM_LEN);
|
|
__entry->oom_score_adj = task->signal->oom_score_adj;
|
|
),
|
|
|
|
TP_printk("pid=%d oldcomm=%s newcomm=%s oom_score_adj=%hd",
|
|
__entry->pid, __entry->oldcomm,
|
|
__entry->newcomm, __entry->oom_score_adj)
|
|
);
|
|
|
|
#endif
|
|
|
|
/* This part must be outside protection */
|
|
#include <trace/define_trace.h>
|