lkml.org 
[lkml]   [2018]   [Mar]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v3] vsprintf: Prevent crash when dereferencing invalid pointers
From
Date
On Thu, 2018-03-15 at 16:58 +0900, Sergey Senozhatsky wrote:
> On (03/14/18 15:09), Petr Mladek wrote:
>


> > char *pointer(const char *fmt, char *buf, char *end, void *ptr,
> > struct printf_spec spec)
> > {
> > + static const char data_access_fmt[] =
> > "RrhbMmIiEUVNadCDgGO";
> > const int default_width = 2 * sizeof(void *);
> > + const char *err_msg = NULL;
> > +
> > + /* Prevent silent crash when this is called under
> > logbuf_lock. */
> > + if (*fmt && strchr(data_access_fmt, *fmt) != NULL)
> > + err_msg = check_pointer_access(ptr);
>
> Agree with Rasmus, I think switch() is easier.
>

One more to the same.

Though need to add that we also have to append / update some comment to
keep these lists synchronized (in Documentation, around pointer() and
here)

--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

\
 
 \ /
  Last update: 2018-03-15 14:08    [W:0.265 / U:1.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site