Skip to contentSkip to conversation

mei: trace: treat reg parameter as string

char-misc Alexander Usyskin 2 participants 4 messages Jan 4 – Jan 6

Subsystems (2)
lore
Share & tools
lore

Alexander Usyskin

author maintainer
#0 lore raw

Process the reg string parameter in secure way.

---
 drivers/misc/mei/mei-trace.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/misc/mei/mei-trace.h +9 -9
index 5312edbf5190..24fa321d88bd 100644
@@ -21,18 +21,18 @@ TRACE_EVENT(mei_reg_read,
 	TP_ARGS(dev, reg, offs, val),
 	TP_STRUCT__entry(
 		__string(dev, dev_name(dev))
-		__field(const char *, reg)
+		__string(reg, reg)
 		__field(u32, offs)
 		__field(u32, val)
 	),
 	TP_fast_assign(
 		__assign_str(dev);
-		__entry->reg  = reg;
+		__assign_str(reg);
 		__entry->offs = offs;
 		__entry->val = val;
 	),
 	TP_printk("[%s] read %s:[%#x] = %#x",
-		  __get_str(dev), __entry->reg, __entry->offs, __entry->val)
+		  __get_str(dev), __get_str(reg), __entry->offs, __entry->val)
 );
 
 TRACE_EVENT(mei_reg_write,
@@ -40,18 +40,18 @@ TRACE_EVENT(mei_reg_write,
 	TP_ARGS(dev, reg, offs, val),
 	TP_STRUCT__entry(
 		__string(dev, dev_name(dev))
-		__field(const char *, reg)
+		__string(reg, reg)
 		__field(u32, offs)
 		__field(u32, val)
 	),
 	TP_fast_assign(
 		__assign_str(dev);
-		__entry->reg = reg;
+		__assign_str(reg);
 		__entry->offs = offs;
 		__entry->val = val;
 	),
 	TP_printk("[%s] write %s[%#x] = %#x",
-		  __get_str(dev), __entry->reg,  __entry->offs, __entry->val)
+		  __get_str(dev), __get_str(reg),  __entry->offs, __entry->val)
 );
 
 TRACE_EVENT(mei_pci_cfg_read,
@@ -59,18 +59,18 @@ TRACE_EVENT(mei_pci_cfg_read,
 	TP_ARGS(dev, reg, offs, val),
 	TP_STRUCT__entry(
 		__string(dev, dev_name(dev))
-		__field(const char *, reg)
+		__string(reg, reg)
 		__field(u32, offs)
 		__field(u32, val)
 	),
 	TP_fast_assign(
 		__assign_str(dev);
-		__entry->reg  = reg;
+		__assign_str(reg);
 		__entry->offs = offs;
 		__entry->val = val;
 	),
 	TP_printk("[%s] pci cfg read %s:[%#x] = %#x",
-		  __get_str(dev), __entry->reg, __entry->offs, __entry->val)
+		  __get_str(dev), __get_str(reg), __entry->offs, __entry->val)
 );
 
 #endif /* _MEI_TRACE_H_ */
Signature · 1 line
2.43.0
#1 lore raw
Quoted 2 lines · Alexander Usyskin

Process the reg string parameter in secure way.

I'm sorry, but I don't understand this changelog text. What exactly is this doing? Why is a string "better" than a char *?

thanks,

greg k-h

author maintainer
#2 lore raw
Quoted 6 lines

Subject: Re: [char-misc] mei: trace: treat reg parameter as string

Quoted 2 lines · Alexander Usyskin

Process the reg string parameter in secure way.

Quoted 6 lines

I'm sorry, but I don't understand this changelog text. What exactly is this doing? Why is a string "better" than a char *?

thanks,

greg k-h

Sorry, I'm bad in changelogs, trying to improve...

The string wrapper checks sanity of parameters and prevents internal kernel data leaks. Newer kernels refuse to emit event with plain char*, without the wrapper. See https://elixir.bootlin.com/linux/v6.19-rc3/source/kernel/trace/trace.c#L3785

- -
Thanks,
Sasha

#3 lore raw
Quoted 6 lines · Alexander
Quoted 6 lines

Subject: Re: [char-misc] mei: trace: treat reg parameter as string

Quoted 2 lines · Alexander Usyskin

Process the reg string parameter in secure way.

Quoted 8 lines
Quoted 6 lines

I'm sorry, but I don't understand this changelog text. What exactly is this doing? Why is a string "better" than a char *?

thanks,

greg k-h

Sorry, I'm bad in changelogs, trying to improve...

It is usually the hardest part of making a code change.

Quoted 3 lines

The string wrapper checks sanity of parameters and prevents internal kernel data leaks. Newer kernels refuse to emit event with plain char*, without the wrapper. See https://elixir.bootlin.com/linux/v6.19-rc3/source/kernel/trace/trace.c#L3785

Great, please take this information and rewrite this to explain the need here and what this change is doing.

thanks,

greg k-h