From: Steve Best <sfbest@us.ibm.com>
To: Scott Wood <scottwood@freescale.com>
Cc: linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] powerpc/mm: add devmem_is_allowed() for STRICT_DEVMEM checking
Date: Tue, 01 Feb 2011 12:21:45 -0500 [thread overview]
Message-ID: <1296580906.5343.6.camel@dhcp-100-2-27.bos.redhat.com> (raw)
In-Reply-To: <20110131134057.153d6844@udp111988uds.am.freescale.net>
On Mon, 2011-01-31 at 13:40 -0600, Scott Wood wrote:
> On Mon, 31 Jan 2011 14:16:00 -0500
> Steve Best <sfbest@us.ibm.com> wrote:
>
> > Provide devmem_is_allowed() routine to restrict access to kernel
> > memory from userspace.
> > Set CONFIG_STRICT_DEVMEM config option to switch on checking.
> >
> > Signed-off-by: Steve Best <sfbest@us.ibm.com>
> >
> > diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
> > index 2d38a50..6805d5d 100644
> > --- a/arch/powerpc/Kconfig.debug
> > +++ b/arch/powerpc/Kconfig.debug
> > @@ -299,4 +299,16 @@ config PPC_EARLY_DEBUG_CPM_ADDR
> > platform probing is done, all platforms selected must
> > share the same address.
> >
> > +config STRICT_DEVMEM
> > + def_bool y
> > + prompt "Filter access to /dev/mem"
> > + ---help---
> > + This option restricts access to /dev/mem. If this option is
> > + disabled, you allow userspace access to all memory, including
> > + kernel and userspace memory. Accidental memory access is likely
> > + to be disastrous.
> > + Memory access is required for experts who want to debug the kernel.
> > +
> > + If you are unsure, say Y.
> > +
> > endmenu
> > diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
> > index 53b64be..f225032 100644
> > --- a/arch/powerpc/include/asm/page.h
> > +++ b/arch/powerpc/include/asm/page.h
> > @@ -262,6 +262,11 @@ extern void copy_user_page(void *to, void *from, unsigned long vaddr,
> > struct page *p);
> > extern int page_is_ram(unsigned long pfn);
> >
> > +static inline int devmem_is_allowed(unsigned long pfn)
> > +{
> > + return 0;
> > +}
> > +
>
> I don't see how this is a sane thing to turn on by default (you're not
> restricting it, BTW -- you're completely disabling it with that
> implementation of devmem_is_allowed). It will break anything that
> uses /dev/mem to access I/O,
could you expand on what I/O depends on /dev/mem, so I can take
that into account?
> possibly including desktoppy stuff like X
> servers,
you are right just found out that X needs to access it. will
take that into account
> as well as lots of stuff that goes on in embedded setups.
could you explain more about what needs access to /dev/mem in
the embedded setups?
>
> You need to be root to access /dev/mem, and root has plenty of
> other options for causing "disastrous" results. You don't just stumble
> onto /dev/mem by accident.
>
> -Scott
-Steve
next prev parent reply other threads:[~2011-02-01 17:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-31 19:16 [PATCH] powerpc/mm: add devmem_is_allowed() for STRICT_DEVMEM checking Steve Best
2011-01-31 19:25 ` Josh Boyer
2011-01-31 19:32 ` Josh Boyer
2011-01-31 19:40 ` Scott Wood
2011-02-01 17:21 ` Steve Best [this message]
2011-02-01 18:35 ` Scott Wood
-- strict thread matches above, loose matches on Subject: below --
2011-06-14 16:58 Steve Best
2011-06-14 17:30 ` Nathan Lynch
2011-06-14 18:17 ` Steve Best
2011-06-14 19:04 ` Scott Wood
[not found] ` <20110614140431.31ae4357__48367.5367352136$1308078343$gmane$org@schlenkerla.am.freescale.net>
2011-06-29 22:01 ` Sukadev Bhattiprolu
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=1296580906.5343.6.camel@dhcp-100-2-27.bos.redhat.com \
--to=sfbest@us.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=scottwood@freescale.com \
/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;
as well as URLs for NNTP newsgroup(s).