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

Alexander Usyskin posted 1 patch 1 month ago
There is a newer version of this series
drivers/misc/mei/mei-trace.h | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
[char-misc v2] mei: trace: treat reg parameter as string
Posted by Alexander Usyskin 1 month ago
Use the string wrapper to check sanity of the reg parameters,
store it value independently and prevent internal kernel data leaks.
Trace subsystem refuses to emit event with plain char*,
without the wrapper.

Cc: stable@vger.kernel.org
Fixes: a0a927d06d79 ("mei: me: add io register tracing")
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
---

V2: reword commit message
    add Fixes and stable

 drivers/misc/mei/mei-trace.h | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/misc/mei/mei-trace.h b/drivers/misc/mei/mei-trace.h
index 5312edbf5190..24fa321d88bd 100644
--- a/drivers/misc/mei/mei-trace.h
+++ b/drivers/misc/mei/mei-trace.h
@@ -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_ */
-- 
2.43.0
Re: [char-misc v2] mei: trace: treat reg parameter as string
Posted by Greg Kroah-Hartman 1 month ago
On Thu, Jan 08, 2026 at 08:57:02AM +0200, Alexander Usyskin wrote:
> Use the string wrapper to check sanity of the reg parameters,
> store it value independently and prevent internal kernel data leaks.
> Trace subsystem refuses to emit event with plain char*,
> without the wrapper.
> 
> Cc: stable@vger.kernel.org

Does this really fix a bug?  If not, there's no need for cc: stable or:

> Fixes: a0a927d06d79 ("mei: me: add io register tracing")

That line as well.

thanks,

greg k-h
RE: [char-misc v2] mei: trace: treat reg parameter as string
Posted by Usyskin, Alexander 1 month ago
> Subject: Re: [char-misc v2] mei: trace: treat reg parameter as string
> 
> On Thu, Jan 08, 2026 at 08:57:02AM +0200, Alexander Usyskin wrote:
> > Use the string wrapper to check sanity of the reg parameters,
> > store it value independently and prevent internal kernel data leaks.
> > Trace subsystem refuses to emit event with plain char*,
> > without the wrapper.
> >
> > Cc: stable@vger.kernel.org
> 
> Does this really fix a bug?  If not, there's no need for cc: stable or:
> 
> > Fixes: a0a927d06d79 ("mei: me: add io register tracing")
> 
> That line as well.
> 
> thanks,
> 
> greg k-h

Without this patch the events are not emitted at all, they are dropped
by trace security checker.

- - 
Thanks,
Sasha


Re: [char-misc v2] mei: trace: treat reg parameter as string
Posted by Greg Kroah-Hartman 1 month ago
On Thu, Jan 08, 2026 at 07:42:22AM +0000, Usyskin, Alexander wrote:
> > Subject: Re: [char-misc v2] mei: trace: treat reg parameter as string
> > 
> > On Thu, Jan 08, 2026 at 08:57:02AM +0200, Alexander Usyskin wrote:
> > > Use the string wrapper to check sanity of the reg parameters,
> > > store it value independently and prevent internal kernel data leaks.
> > > Trace subsystem refuses to emit event with plain char*,
> > > without the wrapper.
> > >
> > > Cc: stable@vger.kernel.org
> > 
> > Does this really fix a bug?  If not, there's no need for cc: stable or:
> > 
> > > Fixes: a0a927d06d79 ("mei: me: add io register tracing")
> > 
> > That line as well.
> > 
> > thanks,
> > 
> > greg k-h
> 
> Without this patch the events are not emitted at all, they are dropped
> by trace security checker.

Ah, again, that was not obvious at all from the changelog.  Perhaps
reword it a bit?  How has this ever worked?

thanks,

greg k-h
RE: [char-misc v2] mei: trace: treat reg parameter as string
Posted by Usyskin, Alexander 1 month ago
> Subject: Re: [char-misc v2] mei: trace: treat reg parameter as string
> 
> On Thu, Jan 08, 2026 at 07:42:22AM +0000, Usyskin, Alexander wrote:
> > > Subject: Re: [char-misc v2] mei: trace: treat reg parameter as string
> > >
> > > On Thu, Jan 08, 2026 at 08:57:02AM +0200, Alexander Usyskin wrote:
> > > > Use the string wrapper to check sanity of the reg parameters,
> > > > store it value independently and prevent internal kernel data leaks.
> > > > Trace subsystem refuses to emit event with plain char*,
> > > > without the wrapper.
> > > >
> > > > Cc: stable@vger.kernel.org
> > >
> > > Does this really fix a bug?  If not, there's no need for cc: stable or:
> > >
> > > > Fixes: a0a927d06d79 ("mei: me: add io register tracing")
> > >
> > > That line as well.
> > >
> > > thanks,
> > >
> > > greg k-h
> >
> > Without this patch the events are not emitted at all, they are dropped
> > by trace security checker.
> 
> Ah, again, that was not obvious at all from the changelog.  Perhaps
> reword it a bit?  How has this ever worked?
> 

This security hardening was introduced way after the initial commit
and the breakage went unnoticed for some time, unfortunately.
 
- - 
Thanks,
Sasha


Re: [char-misc v2] mei: trace: treat reg parameter as string
Posted by Greg Kroah-Hartman 1 month ago
On Thu, Jan 08, 2026 at 07:59:08AM +0000, Usyskin, Alexander wrote:
> > Subject: Re: [char-misc v2] mei: trace: treat reg parameter as string
> > 
> > On Thu, Jan 08, 2026 at 07:42:22AM +0000, Usyskin, Alexander wrote:
> > > > Subject: Re: [char-misc v2] mei: trace: treat reg parameter as string
> > > >
> > > > On Thu, Jan 08, 2026 at 08:57:02AM +0200, Alexander Usyskin wrote:
> > > > > Use the string wrapper to check sanity of the reg parameters,
> > > > > store it value independently and prevent internal kernel data leaks.
> > > > > Trace subsystem refuses to emit event with plain char*,
> > > > > without the wrapper.
> > > > >
> > > > > Cc: stable@vger.kernel.org
> > > >
> > > > Does this really fix a bug?  If not, there's no need for cc: stable or:
> > > >
> > > > > Fixes: a0a927d06d79 ("mei: me: add io register tracing")
> > > >
> > > > That line as well.
> > > >
> > > > thanks,
> > > >
> > > > greg k-h
> > >
> > > Without this patch the events are not emitted at all, they are dropped
> > > by trace security checker.
> > 
> > Ah, again, that was not obvious at all from the changelog.  Perhaps
> > reword it a bit?  How has this ever worked?
> > 
> 
> This security hardening was introduced way after the initial commit
> and the breakage went unnoticed for some time, unfortunately.

So then the "Fixes:" tag is not correct :(
Re: [char-misc v2] mei: trace: treat reg parameter as string
Posted by Greg Kroah-Hartman 1 month ago
On Thu, Jan 08, 2026 at 09:17:12AM +0100, Greg Kroah-Hartman wrote:
> On Thu, Jan 08, 2026 at 07:59:08AM +0000, Usyskin, Alexander wrote:
> > > Subject: Re: [char-misc v2] mei: trace: treat reg parameter as string
> > > 
> > > On Thu, Jan 08, 2026 at 07:42:22AM +0000, Usyskin, Alexander wrote:
> > > > > Subject: Re: [char-misc v2] mei: trace: treat reg parameter as string
> > > > >
> > > > > On Thu, Jan 08, 2026 at 08:57:02AM +0200, Alexander Usyskin wrote:
> > > > > > Use the string wrapper to check sanity of the reg parameters,
> > > > > > store it value independently and prevent internal kernel data leaks.
> > > > > > Trace subsystem refuses to emit event with plain char*,
> > > > > > without the wrapper.
> > > > > >
> > > > > > Cc: stable@vger.kernel.org
> > > > >
> > > > > Does this really fix a bug?  If not, there's no need for cc: stable or:
> > > > >
> > > > > > Fixes: a0a927d06d79 ("mei: me: add io register tracing")
> > > > >
> > > > > That line as well.
> > > > >
> > > > > thanks,
> > > > >
> > > > > greg k-h
> > > >
> > > > Without this patch the events are not emitted at all, they are dropped
> > > > by trace security checker.
> > > 
> > > Ah, again, that was not obvious at all from the changelog.  Perhaps
> > > reword it a bit?  How has this ever worked?
> > > 
> > 
> > This security hardening was introduced way after the initial commit
> > and the breakage went unnoticed for some time, unfortunately.
> 
> So then the "Fixes:" tag is not correct :(

Wait, no, it is, but you need to say why this is now needed, and was not
a problem back then.  And is this really ok to backport all the way to
that commit id, or should it just be relegated to the one where the
"hardening" feature was added?

thanks,
greg k-h
RE: [char-misc v2] mei: trace: treat reg parameter as string
Posted by Usyskin, Alexander 1 month ago
> Subject: Re: [char-misc v2] mei: trace: treat reg parameter as string
> 
> On Thu, Jan 08, 2026 at 09:17:12AM +0100, Greg Kroah-Hartman wrote:
> > On Thu, Jan 08, 2026 at 07:59:08AM +0000, Usyskin, Alexander wrote:
> > > > Subject: Re: [char-misc v2] mei: trace: treat reg parameter as string
> > > >
> > > > On Thu, Jan 08, 2026 at 07:42:22AM +0000, Usyskin, Alexander wrote:
> > > > > > Subject: Re: [char-misc v2] mei: trace: treat reg parameter as string
> > > > > >
> > > > > > On Thu, Jan 08, 2026 at 08:57:02AM +0200, Alexander Usyskin wrote:
> > > > > > > Use the string wrapper to check sanity of the reg parameters,
> > > > > > > store it value independently and prevent internal kernel data leaks.
> > > > > > > Trace subsystem refuses to emit event with plain char*,
> > > > > > > without the wrapper.
> > > > > > >
> > > > > > > Cc: stable@vger.kernel.org
> > > > > >
> > > > > > Does this really fix a bug?  If not, there's no need for cc: stable or:
> > > > > >
> > > > > > > Fixes: a0a927d06d79 ("mei: me: add io register tracing")
> > > > > >
> > > > > > That line as well.
> > > > > >
> > > > > > thanks,
> > > > > >
> > > > > > greg k-h
> > > > >
> > > > > Without this patch the events are not emitted at all, they are dropped
> > > > > by trace security checker.
> > > >
> > > > Ah, again, that was not obvious at all from the changelog.  Perhaps
> > > > reword it a bit?  How has this ever worked?
> > > >
> > >
> > > This security hardening was introduced way after the initial commit
> > > and the breakage went unnoticed for some time, unfortunately.
> >
> > So then the "Fixes:" tag is not correct :(
> 
> Wait, no, it is, but you need to say why this is now needed, and was not
> a problem back then.  And is this really ok to backport all the way to
> that commit id, or should it just be relegated to the one where the
> "hardening" feature was added?
> 

Sure, will add this info to the commit message.

The __string accessors and friends were available when original commit was merged.
Original commit uses such functions for another field.
Thus, I suppose, it is ok to backport all the way to that commit id.

- - 
Thanks,
Sasha