mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@amd64.org>
To: Andrew Lutomirski <luto@mit.edu>
Cc: Borislav Petkov <bp@alien8.de>, "x86@kernel.org" <x86@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@elte.hu>, John Stultz <johnstul@us.ibm.com>,
	Borislav Petkov <bp@amd64.org>
Subject: Re: [PATCH v2 1/8] x86-64: Improve vsyscall emulation CS and RIP handling
Date: Tue, 12 Jul 2011 15:24:49 +0200	[thread overview]
Message-ID: <20110712132449.GB11336@aftab> (raw)
In-Reply-To: <CAObL_7F5KQA+GaSsU5nD+7gAY2JFv+XE0BRu+sRg0Mv24dBzaA@mail.gmail.com>

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@alien8.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

  reply	other threads:[~2011-07-12 13:25 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-10  3:22 [PATCH v2 0/8] x86-64 vDSO changes for 3.1 Andy Lutomirski
2011-07-10  3:22 ` [PATCH v2 1/8] x86-64: Improve vsyscall emulation CS and RIP handling Andy Lutomirski
2011-07-11 22:14   ` Borislav Petkov
2011-07-11 22:20     ` Andrew Lutomirski
2011-07-12  7:18       ` Borislav Petkov
2011-07-12 12:58         ` Andrew Lutomirski
2011-07-12 13:24           ` Borislav Petkov [this message]
2011-07-13  4:33           ` H. Peter Anvin
2011-07-13 13:17             ` Andrew Lutomirski
2011-07-10  3:22 ` [PATCH v2 2/8] x86: Make alternative instruction pointers relative Andy Lutomirski
2011-07-10  3:22 ` [PATCH v2 3/8] x86-64: Allow alternative patching in the vDSO Andy Lutomirski
2011-07-11 10:41   ` Rakib Mullick
2011-07-11 14:21     ` Andrew Lutomirski
2011-07-10  3:22 ` [PATCH v2 4/8] x86-64: Add --no-undefined to vDSO build Andy Lutomirski
2011-07-10  3:22 ` [PATCH v2 5/8] clocksource: Replace vread with generic arch data Andy Lutomirski
2011-07-10  3:22 ` [PATCH v2 6/8] x86-64: Move vread_tsc and vread_hpet into the vDSO Andy Lutomirski
2011-07-10  3:22 ` [PATCH v2 7/8] ia64: Replace clocksource.fsys_mmio with generic arch data Andy Lutomirski
2011-07-10  3:22 ` [PATCH v2 8/8] Document the vDSO and add a reference parser Andy Lutomirski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110712132449.GB11336@aftab \
    --to=bp@amd64.org \
    --cc=bp@alien8.de \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@mit.edu \
    --cc=mingo@elte.hu \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®