Re: suspicious compiler warning in vdso2c.h

From: Andy Lutomirski
Date: Tue Sep 16 2014 - 17:16:34 EST


On Sep 16, 2014 2:53 AM, "Jan Beulich" <JBeulich@xxxxxxxx> wrote:
>
> Andy
>
> following e6577a7ce9 ("x86, vdso: Move the vvar area before the
> vdso text") gcc 4.3.4 tells me
>
> .../arch/x86/vdso/vdso2c.c: In function âmainâ:
> .../arch/x86/vdso/vdso2c.h:118: warning: assuming signed overflow does not occur when assuming that (X + c) < X is
> always false
> .../arch/x86/vdso/vdso2c.h:118: warning: assuming signed overflow does not occur when assuming that (X + c) < X is
> always false

Yes. There's a more or less equivalent fix sitting in -mm.

--Andy

>
> apparently because it unrolls the containing loop and finds i ==
> sym_vvar_start on the first iteration. I think there was a hidden
> dependency before your change on required_syms[] first two
> entries matching up with special_pages[]. If that's correct, all
> syms[i] within said loop would seem to need replacing by
> syms[special_pages[i]] (similarly for required_syms[i] afaict, see
> below draft patch), which also is in line with the loop iterating
> over the array elements of special_pages[].
>
> Question then of course is - are there any further hidden
> dependencies that already got or may eventually get broken?
>
> Jan
>
> --- a/arch/x86/vdso/vdso2c.h
> +++ b/arch/x86/vdso/vdso2c.h
> @@ -109,18 +109,18 @@ static void BITSFUNC(go)(void *raw_addr,
>
> /* Validate mapping addresses. */
> for (i = 0; i < sizeof(special_pages) / sizeof(special_pages[0]); i++) {
> - if (!syms[i])
> + if (!syms[special_pages[i]])
> continue; /* The mapping isn't used; ignore it. */
>
> - if (syms[i] % 4096)
> + if (syms[special_pages[i]] % 4096)
> fail("%s must be a multiple of 4096\n",
> - required_syms[i].name);
> - if (syms[sym_vvar_start] > syms[i] + 4096)
> + required_syms[special_pages[i]].name);
> + if (syms[sym_vvar_start] > syms[special_pages[i]] + 4096)
> fail("%s underruns begin_vvar\n",
> - required_syms[i].name);
> - if (syms[i] + 4096 > 0)
> + required_syms[special_pages[i]].name);
> + if (syms[special_pages[i]] + 4096 > 0)
> fail("%s is on the wrong side of the vdso text\n",
> - required_syms[i].name);
> + required_syms[special_pages[i]].name);
> }
> if (syms[sym_vvar_start] % 4096)
> fail("vvar_begin must be a multiple of 4096\n");
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/