mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Borislav Petkov <bp@amd64.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	LKML <linux-kernel@vger.kernel.org>,
	"Przywara, Andre" <Andre.Przywara@amd.com>,
	"Pohlack, Martin" <Martin.Pohlack@amd.com>
Subject: Re: [PATCH] x86, AMD: Correct F15h IC aliasing issue
Date: Sun, 24 Jul 2011 22:44:50 +0200	[thread overview]
Message-ID: <20110724204450.GB18546@elte.hu> (raw)
In-Reply-To: <20110724190752.GA13647@aftab>


* Borislav Petkov <bp@amd64.org> wrote:

> On Sun, Jul 24, 2011 at 02:30:46PM -0400, Ingo Molnar wrote:
> > > > So I really think that you might be *much* better off just changing
> > > > mmap_rnd(), and nothing else. Just make *that* mask off the three low
> > > > bits of the random address, ie something like
> > > > 
> > > >   diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
> > > >   index 1dab5194fd9d..6b62ab5a5ae1 100644
> > > >   --- a/arch/x86/mm/mmap.c
> > > >   +++ b/arch/x86/mm/mmap.c
> > > >   @@ -90,6 +90,9 @@ static unsigned long mmap_rnd(void)
> > > >                           rnd = (long)get_random_int() % (1<<8);
> > > >                   else
> > > >                           rnd = (long)(get_random_int() % (1<<28));
> > > >   +
> > > >   +               if (avoid_aliasing_in_bits_14_12)
> > > >   +                       rnd &= ~7;
> > > >           }
> > > >           return rnd << PAGE_SHIFT;
> > > >    }
> > > > 
> > > > would be fundamentally very safe - it would already take all our
> > > > current anti-randomization code into account.
> > > > 
> > > > No?
> > > 
> > > Hehe, we had that idea initially. However, the special 1% case I was
> > > hinting at is this:
> > > 
> > > process P0, mapping libraries A, B, C
> > > 
> > > and
> > > 
> > > process P1, mapping libraries A, C
> > > 
> > > Library C ends up possibly with aliasing VAs and there's the 
> > > problem again. [...]
> > 
> > Well, since all library positions are randomized, and the quirk masks 
> > out bits 12,13,14, all libraries that are not explicitly fix-mapped 
> > will end up on a 32K granular VA address.
> 
> Right, but IIUC, mmap_rnd() is used to determine mm->mmap_base so 
> the mmap starting address will have [14:12] cleared but the initial 
> address of library C's mapping in the example above will possibly 
> differ in those bits due to different linking order, right?

Indeed, because only the mmap base is randomized, not the individual 
vmas.

I'd still suggest to ignore this link order case first, and get the 
99% fix in place ... that one is also obviously backportable - the 
big patch not so much.

Then send in a patch on top of that that solves the remaining 1% also 
with numbers attached, so that we can see the speed/complexity 
tradeoff ...

> > Also, in practice on most distros most libraries will be 
> > prelinked to the same address in all processes.
> 
> I think at least on RHEL there's a daemon doing prelinking every 
> two weeks or so...

I'd suggest to run a script that extracts the actual mapped offsets 
from/proc/*/maps files and measures how much of an issue this all is 
in practice.

Thanks,

	Ingo

  reply	other threads:[~2011-07-24 20:45 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-22 13:15 Borislav Petkov
2011-07-24 11:13 ` Ingo Molnar
2011-07-24 13:40   ` Borislav Petkov
2011-07-24 13:47     ` Ingo Molnar
2011-07-24 16:16     ` Andrew Morton
2011-07-26 18:33     ` Borislav Petkov
2011-07-24 16:04 ` Linus Torvalds
2011-07-24 17:22   ` Borislav Petkov
2011-07-24 17:39     ` Linus Torvalds
2011-07-24 18:12       ` Ingo Molnar
2011-07-24 18:23       ` Borislav Petkov
2011-07-24 18:30         ` Ingo Molnar
2011-07-24 19:07           ` Borislav Petkov
2011-07-24 20:44             ` Ingo Molnar [this message]
2011-07-25 20:00               ` Borislav Petkov
2011-07-25 20:06                 ` Ingo Molnar
2011-07-25 21:53                   ` Borislav Petkov
2011-07-26  5:58                     ` Ray Lee
2011-07-26 17:28                       ` Borislav Petkov
2011-07-26 18:34                         ` Ingo Molnar
2011-07-26 18:39                           ` Borislav Petkov
2011-07-26 18:47                             ` Ingo Molnar
2011-07-26 19:33                               ` Borislav Petkov
2011-07-27 17:10       ` Borislav Petkov
2011-07-27 17:16         ` H. Peter Anvin
2011-07-28 13:44           ` Borislav Petkov
2011-07-28 14:02             ` H. Peter Anvin
2011-07-28 14:13               ` Borislav Petkov
2011-07-28 14:18                 ` H. Peter Anvin
2011-07-28 14:35                   ` Borislav Petkov
2011-07-26 17:59 ` Avi Kivity
2011-07-26 18:13   ` Borislav Petkov
2011-07-26 18:16     ` H. Peter Anvin
2011-07-26 18:37       ` Borislav Petkov
2011-07-26 18:38         ` H. Peter Anvin
2011-07-26 19:42           ` Andre Przywara
2011-07-26 22:34             ` H. Peter Anvin
2011-07-27  4:14             ` Avi Kivity
2011-07-27  6:21               ` Borislav Petkov
2011-07-27  6:59                 ` Ingo Molnar
2011-07-27  9:30                   ` Avi Kivity
2011-07-27 15:37                     ` Borislav Petkov
2011-07-27 15:45                       ` Avi Kivity
2011-07-27 15:49                         ` Borislav Petkov
2011-07-27 15:57                           ` Avi Kivity
2011-07-27 16:42                             ` Borislav Petkov

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=20110724204450.GB18546@elte.hu \
    --to=mingo@elte.hu \
    --cc=Andre.Przywara@amd.com \
    --cc=Martin.Pohlack@amd.com \
    --cc=bp@amd64.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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®