mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.cz>
To: Venki Pallipadi <venki@google.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
	"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH resend] x86, PAT: honor CONFIG_STRICT_DEVMEM if pat is disabled
Date: Tue, 2 Aug 2011 19:02:56 +0200	[thread overview]
Message-ID: <20110802170256.GB23698@tiehlicka.suse.cz> (raw)
In-Reply-To: <CABeCy1aCA_iGOYw65UK3Nr2W7u5zEOK24N-n0iCY=aQZNVcUEQ@mail.gmail.com>

On Tue 02-08-11 09:33:28, Venki Pallipadi wrote:
> On Tue, Aug 2, 2011 at 1:03 AM, Michal Hocko <mhocko@suse.cz> wrote:
> > On Mon 01-08-11 16:33:18, Venki Pallipadi wrote:
> >> On Fri, Jul 22, 2011 at 2:01 AM, Michal Hocko <mhocko@suse.cz> wrote:
> >> >
> >> > since 0124cecf (x86, PAT: disable /dev/mem mmap RAM with PAT) we are
> >> > disabling access to the system RAM as if STRICT_DEVMEM was enabled by
> >> > default. If we, however, disable pat by nopat kernel parameter we can
> >> > access that memory without considering CONFIG_STRICT_DEVMEM.
> >>
> >> Looking at the code, I don't think this problem exists. Code in pat.c
> >> disables /dev/mem mmap only when !CONFIG_STRICT_DEVMEM.
> >
> > Ahh yes, you are right. I got confused by having two separate
> > range_is_allowed functions and didn't realize which one is called from
> > which context.
> >        mmap_mem
> >          -> range_is_allowed [drivers/char/mem.c]
> >               -EPERM
> >          -> phys_mem_access_prot_allowed
> >               -> range_is_allowed [arch/x86/mm/pat.c]
> >
> > So we really get stopped at the first check and do not get to the later
> > one.
> >
> > While we are at it. {read,write}_mem checks only range_is_allowed (mem.c
> > version) and it doesn't call phys_mem_access_prot_allowed so we do not
> > consider PAT. {read,write}_kmem doesn't check the range at all.
> > Is this correct?
> > Why do we care _only_ about mmap?
> >
> 
> Yes. The problem with PAT and /dev/mem mmap is with untracked mmaps in
> user address space. Once mapped the mappings can stay in user space
> and if there is a page attribute change for that physical address
> later kernel doesn't have handle on all such user space mappings that
> may exist.
> Read/Write on the other hand use direct mappings and will not cause
> this problem. I have generally been suggesting tools that want to
> access /dev/mem and are unable to mmap it due to PAT to use read/write
> instead. /dev/mem on 32 bit has some problems of its own and the
> recent patchset on mailing list fixes most of the issues there.

OK, understood. Thanks for the clarification.

-- 
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

      reply	other threads:[~2011-08-02 17:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20110801094611.AAF738A95F@mx2.suse.de>
2011-08-01 23:33 ` Venki Pallipadi
2011-08-02  8:03   ` Michal Hocko
2011-08-02 16:33     ` Venki Pallipadi
2011-08-02 17:02       ` Michal Hocko [this message]

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=20110802170256.GB23698@tiehlicka.suse.cz \
    --to=mhocko@suse.cz \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=venki@google.com \
    --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®