Re: [PATCH v2 1/8] x86-64: Improve vsyscall emulation CS and RIPhandling
From: Borislav Petkov
Date: Tue Jul 12 2011 - 03:18:40 EST
On Mon, Jul 11, 2011 at 06:20:50PM -0400, Andrew Lutomirski wrote:
> > I'm wondering: why don't you make this function return negative value on
> > error, i.e. -EINVAL and the vsyscall number on success so that you can
> > get rid of returning it through the arg pointer?
> >
> > Then at the callsite you can do:
> >
> > Â Â Â Âvsyscall_nr = addr_to_vsyscall_nr(addr);
> > Â Â Â Âif (vsyscall_nr < 0)
> > Â Â Â Â Â Â Â Âwarn_bad_vsyscall(...)
>
> Because I don't want a warning about ret being used without being initialized.
not if you preinit it...
> With the code in this patch, the compiler is smart enough to figure
> out that either vsyscall_nr is 0, 1, or 2 or that the EINVAL branch is
> taken. I'll see if it works the other way.
here's what i mean, I changed your patch a bit:
--