Skip to contentSkip to conversation

tracing: Two minor fixes for 6.13

PATCH New Steven Rostedt 1 participant 3 messages Dec 25, 2024

Subsystems (2)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

cover tracing: Two minor fixes for 6.13

Two minor tracing fixes for 6.13:

- Add "const" to "char *" in event structure field that gets assigned literals.

- Check size of input passed into the tracing cpumask file.

If a too large of an input gets passed into the cpumask file, it could trigger a warning in the bitmask parsing code.

git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
trace/fixes

Head SHA1: 98feccbf32cfdde8c722bc4587aaa60ee5ac33f0

Christian Göttsche (1):
tracing: Constify string literal data member in struct trace_event_call

Lizhi Xu (1):
tracing: Prevent bad count for tracing_cpumask_write

----

 include/linux/trace_events.h | 2 +-
 kernel/trace/trace.c         | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
author maintainer
#1 lore raw

PATCH 1/2 tracing: Constify string literal data member in struct trace_event_call

From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <[email protected]>

The name member of the struct trace_event_call is assigned with generated string literals; declare them pointer to read-only.

Reported by clang:

    security/landlock/syscalls.c:179:1: warning: initializing 'char *' with an expression of type 'const char[34]' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
      179 | SYSCALL_DEFINE3(landlock_create_ruleset,
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      180 |                 const struct landlock_ruleset_attr __user *const, attr,
          |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      181 |                 const size_t, size, const __u32, flags)
          |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ./include/linux/syscalls.h:226:36: note: expanded from macro 'SYSCALL_DEFINE3'
      226 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
          |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ./include/linux/syscalls.h:234:2: note: expanded from macro 'SYSCALL_DEFINEx'
      234 |         SYSCALL_METADATA(sname, x, __VA_ARGS__)                 \
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ./include/linux/syscalls.h:184:2: note: expanded from macro 'SYSCALL_METADATA'
      184 |         SYSCALL_TRACE_ENTER_EVENT(sname);                       \
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ./include/linux/syscalls.h:151:30: note: expanded from macro 'SYSCALL_TRACE_ENTER_EVENT'
      151 |                         .name                   = "sys_enter"#sname,    \
          |                                                   ^~~~~~~~~~~~~~~~~
Cc Masami Hiramatsu <[email protected]>
Cc Mathieu Desnoyers <[email protected]>
Cc Mickaël Salaün <[email protected]>
Cc Günther Noack <[email protected]>
Cc Nathan Chancellor <[email protected]>
Cc Nick Desaulniers <[email protected]>
Cc Bill Wendling <[email protected]>
Cc Justin Stitt <[email protected]>
Fixes b77e38aa240c3 ("tracing: add event trace infrastructure")
---
 include/linux/trace_events.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/trace_events.h +1 -1
index 91b8ffbdfa8c..58ad4ead33fc 100644
@@ -364,7 +364,7 @@ struct trace_event_call {
 	struct list_head	list;
 	struct trace_event_class *class;
 	union {
-		char			*name;
+		const char		*name;
 		/* Set TRACE_EVENT_FL_TRACEPOINT flag when using "tp" */
 		struct tracepoint	*tp;
 	};
Signature · 1 line
2.45.2
author maintainer
#2 lore raw

PATCH 2/2 tracing: Prevent bad count for tracing_cpumask_write

In reply to Steven Rostedt

From: Lizhi Xu <[email protected]>

If a large count is provided, it will trigger a warning in bitmap_parse_user. Also check zero for it.

---
 kernel/trace/trace.c | 3 +++
 1 file changed, 3 insertions(+)
kernel/trace/trace.c +3 -0
index 957f941a08e7..f8aebcb01e62 100644
@@ -5087,6 +5087,9 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
 	cpumask_var_t tracing_cpumask_new;
 	int err;
 
+	if (count == 0 || count > KMALLOC_MAX_SIZE)
+		return -EINVAL;
+
 	if (!zalloc_cpumask_var(&tracing_cpumask_new, GFP_KERNEL))
 		return -ENOMEM;
 
Signature · 1 line
2.45.2