lkml.org 
[lkml]   [2018]   [Feb]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/5] selftests/x86: fix vDSO selftest segfault for vsyscall=none

* Dominik Brodowski <linux@dominikbrodowski.net> wrote:

> On Sun, Feb 11, 2018 at 01:17:14PM +0100, Dominik Brodowski wrote:
> > On Sun, Feb 11, 2018 at 12:21:53PM +0100, Ingo Molnar wrote:
> > >
> > > * Dominik Brodowski <linux@dominikbrodowski.net> wrote:
> > >
> > > > + char name[128];
> > > > + if (sscanf(line, "%p-%p %c-%cp %*x %*x:%*x %*u %s",
> > > > + &start, &end, &r, &x, name) != 5)
> > >
> > > So that's a buffer overflow waiting to happen, if a line in 'maps' gets too large,
> > > right?
> >
> > ... as does tools/testing/selftests/x86/test_vsyscall.c already now, right?
> > Will fix both up with an additional patch.
>
> Maybe no fix is needed after all: The fgets() call a few lines above
> limits "line" to 127 chars max. So "name" can't even get close to 128
> chars, right?
>
> char line[128];
> ...
> while (fgets(line, sizeof(line), maps)) {

Yeah, probably - but still, this connection and the sscanf() guarantee is not
obvious at first sight, so please improve this to derive from the same value
(define a LINE_MAX size or such), plus maybe add a comment to the sscanf() line
that this is safe because strlen(name) >= strlen(line).

Thanks,

Ingo

\
 
 \ /
  Last update: 2018-02-11 19:25    [W:0.080 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site