lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110712132449.GB11336@aftab>
Date:	Tue, 12 Jul 2011 15:24:49 +0200
From:	Borislav Petkov <bp@...64.org>
To:	Andrew Lutomirski <luto@....edu>
Cc:	Borislav Petkov <bp@...en8.de>, "x86@...nel.org" <x86@...nel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Ingo Molnar <mingo@...e.hu>, John Stultz <johnstul@...ibm.com>,
	Borislav Petkov <bp@...64.org>
Subject: Re: [PATCH v2 1/8] x86-64: Improve vsyscall emulation CS and RIP
 handling

On Tue, Jul 12, 2011 at 08:58:58AM -0400, Andrew Lutomirski wrote:
> On Tue, Jul 12, 2011 at 3:18 AM, Borislav Petkov <bp@...en8.de> wrote:
> > 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...
> 
> I kind of like that warning as a sanity check, and preiniting it
> grates against my irrational desire to over-optimize :)

:-)

> >
> >> 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:
> 
> How about this:
> 
> static int addr_to_vsyscall_nr(unsigned long addr)
> {
> 	int nr;
> 
> 	if ((addr & ~0xC00UL) != VSYSCALL_START)
> 		return -EINVAL;
> 
> 	nr = (addr & 0xC00UL) >> 10;
> 	if (nr >= 3)
> 		return -EINVAL;
> 
> 	return nr;
> }
> 
> ...
> 
> 	int vsyscall_nr;
> 
> ...
> 
> 	vsyscall_nr = addr_to_vsyscall_nr(regs->ip - 2);
> 	if (vsyscall_nr < 0) {
> 		warn_bad_vsyscall(KERN_WARNING, regs,
> 				  "illegal int 0xcc (exploit attempt?)");
> 		goto sigsegv;
> 	}
> 
> gcc 4.6 at least does not warn.

Yep, looks good.

> Also, IRQ disabling was still mismatched in the sigsegv path.  I'll
> fix that as well.

oh yeah.

Thanks.

-- 
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ