lkml.org 
[lkml]   [2010]   [Jan]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/5] tracing: Prevent kernel oops with corrupted buffer
From
Date
On Tue, 2010-01-26 at 23:39 +0100, Frederic Weisbecker wrote:
> On Tue, Jan 26, 2010 at 02:32:23PM -0800, Andrew Morton wrote:
> > > + if (WARN_ON_ONCE(pid < 0)) {
> > > + strcpy(comm, "<XXX>");
> > > + return;
> > > + }
> > > +
> > > if (pid > PID_MAX_DEFAULT) {
> > > strcpy(comm, "<...>");
> > > return;
> >
> > But why is it WARN_ON_ONCE()? That will only fix the problem a single
> > time. On the second occurrence, it will oops again.
>
>
>
> The warning will be produced only once, but after that,
> the condition is still checked like a simple if:
>
> #define WARN_ON_ONCE(condition) ({ \
> static bool __warned; \
> int __ret_warn_once = !!(condition); \
> \
> if (unlikely(__ret_warn_once)) \
> if (WARN_ON(!__warned)) \
> __warned = true; \
> unlikely(__ret_warn_once); \
> })
>
>
> And since this function can be called anytime we have a trace
> to print to the user, we don't want to encumber with thousands
> of warnings.

Exactly!

-- Steve




\
 
 \ /
  Last update: 2010-01-27 00:23    [W:0.069 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site