Re: [PATCH 2/5] selftests/x86: fix vDSO selftest segfault for vsyscall=none

From: Dominik Brodowski
Date: Sun Feb 11 2018 - 08:01:06 EST


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@xxxxxxxxxxxxxxxxxxxx> 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)) {

Thanks,
Dominik