[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <A5ED84D3BB3A384992CBB9C77DEDA4D443EA18A6@USINDEM103.corp.hds.com>
Date: Fri, 6 Sep 2013 16:53:03 +0000
From: Seiji Aguchi <seiji.aguchi@....com>
To: Steven Rostedt <rostedt@...dmis.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"x86@...nel.org" <x86@...nel.org>, "hpa@...or.com" <hpa@...or.com>,
"mingo@...e.hu" <mingo@...e.hu>, "bp@...en8.de" <bp@...en8.de>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"fdeslaur@...il.com" <fdeslaur@...il.com>,
"raphael.beamonte@...il.com" <raphael.beamonte@...il.com>,
"dle-develop@...ts.sourceforge.net"
<dle-develop@...ts.sourceforge.net>,
Tomoki Sekiyama <tomoki.sekiyama@....com>
Subject: RE: [PATCH v2] Introduce page fault tracepoint
> -----Original Message-----
> From: Steven Rostedt [mailto:rostedt@...dmis.org]
> Sent: Friday, September 06, 2013 12:50 PM
> To: Seiji Aguchi
> Cc: linux-kernel@...r.kernel.org; x86@...nel.org; hpa@...or.com; mingo@...e.hu; bp@...en8.de; tglx@...utronix.de;
> fdeslaur@...il.com; raphael.beamonte@...il.com; dle-develop@...ts.sourceforge.net; Tomoki Sekiyama
> Subject: Re: [PATCH v2] Introduce page fault tracepoint
>
> On Fri, 23 Aug 2013 11:37:43 -0400
> Seiji Aguchi <seiji.aguchi@....com> wrote:
>
>
> > +#if !defined(_TRACE_PAGE_FAULT_H) || defined(TRACE_HEADER_MULTI_READ)
> > +#define _TRACE_PAGE_FAULT_H
> > +
> > +#include <linux/tracepoint.h>
> > +
> > +extern void trace_irq_vector_regfunc(void);
> > +extern void trace_irq_vector_unregfunc(void);
> > +
> > +DECLARE_EVENT_CLASS(x86_exceptions,
> > +
> > + TP_PROTO(unsigned long address, struct pt_regs *regs,
> > + unsigned long error_code),
> > +
> > + TP_ARGS(address, regs, error_code),
> > +
> > + TP_STRUCT__entry(
> > + __field( unsigned long, address )
> > + __field( struct pt_regs *, regs )
> > + __field( unsigned long, error_code )
> > + ),
> > +
> > + TP_fast_assign(
> > + __entry->address = address;
> > + __entry->regs = regs;
> > + __entry->error_code = error_code;
> > + ),
> > +
> > + TP_printk("address=0x%lx ip=0x%lx error_code=0x%lx",
> > + __entry->address, __entry->regs->ip, __entry->error_code) );
>
> This is sure to crash the kernel.
>
> You just saved the address of a pointer to some task's stack in the
> ring buffer. And then on output (which can happen a long time from when
> it was recorded), you are dereferencing that same address!
>
> That __entry->regs->ip *will* crash the kernel!
>
> What you want is to save ip in the fast_assign:
>
> __entry->ip = regs->ip
>
> And then print that. Never dereference a pointer directly from the ring
> buffer unless it's a constant value (like a global string).
I see..
Thank you for reviewing.
I will fix it.
Seiji
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists