public inbox for linux-sh@vger.kernel.org
 help / color / mirror / Atom feed
From: Petr Tesarik <ptesarik@suse.cz>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 00/10] Enhance /dev/mem to allow read/write of arbitrary physical addresses
Date: Fri, 01 Jul 2011 20:44:57 +0000	[thread overview]
Message-ID: <201107012244.57593.ptesarik@suse.cz> (raw)
In-Reply-To: <20110701195629.GA19057@elte.hu>

Dne Pá 1. července 2011 21:56:29 Ingo Molnar napsal(a):
> * Petr Tesarik <ptesarik@suse.cz> wrote:
> > Dne Pá 1. července 2011 18:13:45 Ingo Molnar napsal(a):
> > > * H. Peter Anvin <hpa@zytor.com> wrote:
> > > > On 07/01/2011 08:36 AM, Ingo Molnar wrote:
> > > > > So we could kill multiple birds with the same stone here:
> > > > >  - remove various ugly uses of /dev/mem (including the rootkit
> > > > >  usage),
> > > > >  
> > > > >    with or without strict-devmem
> > > > >  
> > > > >  - extending it to above-4G for inspection purposes
> > > > >  
> > > > >  - allowing to kill /dev/mem access runtime similar to the
> > > > >  
> > > > >    disable_modules lock-down killswitch, for the so inclined.
> > > > > 
> > > > > Would you be interested in modifying your patch-set in such a
> > > > > fashion?
> > 
> > Yes, this works for me. How persistent should the kill-switch be? I
> > assume it doesn't make much sense to make a sysfs toggle, because
> > then it would still be open to abuse. I'd rather see it specified
> > on boot and never changed. Agreed?
> > 
> > Something like "enable_dev_mem" on the kenrel command line (default
> > is disabled).
> > 
> > On a similar note, I should probably rip off write_mem() completely
> > and disallow PROT_WRITE mmapping of the device. Right?
> 
> Yeah - there's two things here: one is the boot option to turn it on,
> the other is the kill-switch that is runtime and kills this method of
> access permanently (until next reboot that is).
> 
> the kill-switch works like modules_disabled: once you echo 1 into it
> you cannot move it back to 0 anymore.

Got it.

> The boot option would be a standard boot option - devmem=1 would be
> the canonical naming? (but no strong feelings about the naming)

I don't have any strong feelings either. "devmem=<int>" might be better, 
because it could be used to control whether the device is read-only. That is, 
if we want allow writing to /dev/mem under any circumstances. I'm fine with 
removing the write part completely.

> Do you expect distros to enable this boot option by default? I.e.
> would SuSE be willing to ship with a restrictive /dev/mem by default?
> That's really the wider goal we want to work towards.

I'm not really the decision-maker on this, but even though I don't need it for 
crash, there are several other users which would have to be fixed:

1. hwinfo (EFI, MPTABLE and ACPI table parsing, analyzing video BIOS)
2. dmidecode (SMBIOS, DMI)
3. possibly others

IMO there should be standard interfaces for all of these. SUSE will probably 
continue to ship devmem-enabled kernels until we have a complete replacement 
(esp. hwinfo seems to be important, because it is run as part of the 
supportconfig script, which is run on customer machines and gathers all kind 
of info that is useful to support teams). Note that these tools are mostly 
content with access to the lowest megabyte, so they can also be used with 
CONFIG_STRICT_DEVMEM.

However, somebody must do the first step, and since we are the ones who 
dislike the current state of affairs, it's probably our turn. Once /dev/mem is 
disabled, authors of diagnostic tools will probably complain loudly here. We 
(as in "kernel hackers") should provide proper interfaces for the low-level 
info, and they'll adjust user-space. At this point I would expect distros to 
disable /dev/mem by default.

> > > > There is another use that I have looked at, as well: for
> > > > testing purposes, it would be extremely good to be able to
> > > > dirty and/or flush an arbitrary physical cache line for testing
> > > > purposes.
> > > > 
> > > > This is very very similar to /dev/mem usage -- access to an
> > > > arbitrary chunk of memory -- and a fully enabled /dev/mem can
> > > > of course support this use (just mmap the page with the
> > > > relevant cache line).  However, it could also be a separate
> > > > device which could have looser permissions than /dev/mem; or a
> > > > set of ioctls on /dev/mem with a separate kill switch, because
> > > > no data would ever be have modified or returned to user space.
> > > > 
> > > > Either way, though, we found that it would share a lot of code
> > > > with the /dev/mem implementation, and as such fixing up the
> > > > underlying machinery is the sanest way to upstream this.
> > > 
> > > To me that cache flush thing sounds obscure (but still useful)
> > > enough to justify a new ioctl over /dev/mem.
> > > 
> > > Not sure it even needs a killswitch, unless there's some real
> > > security problem related to it.
> > 
> > It can be used for DoS, but if you have permission for the ioctl(),
> > then you probably also have easier ways to kill the system.
> 
> Hm, why would the ability "dirty and/or flush an arbitrary physical
> cache line for testing purposes" be a DoS?

Effectively switching off CPU caches can slow things down quite a bit... 
especially on a large SMP system. ;)

Petr Tesarik

  reply	other threads:[~2011-07-01 20:44 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-17  8:38 [PATCH 00/10] Enhance /dev/mem to allow read/write of arbitrary physical addresses Petr Tesarik
2011-06-17  8:46 ` [PATCH 06/10] sh: change valid_phys_addr_range's @addr param to phys_addr_t Petr Tesarik
2011-06-17  9:30 ` [PATCH 00/10] Enhance /dev/mem to allow read/write of arbitrary Ingo Molnar
2011-06-17  9:41   ` [PATCH 00/10] Enhance /dev/mem to allow read/write of Russell King - ARM Linux
2011-06-17  9:55   ` [PATCH 00/10] Enhance /dev/mem to allow read/write of arbitrary physical addresses Petr Tesarik
2011-06-20  2:42     ` [PATCH 00/10] Enhance /dev/mem to allow read/write of arbitrary Américo Wang
2011-06-27  7:46       ` [PATCH 00/10] Enhance /dev/mem to allow read/write of Petr Tesarik
2011-06-19 23:02   ` [PATCH 00/10] Enhance /dev/mem to allow read/write of arbitrary Ryan Mallon
2011-06-19 23:44     ` H. Peter Anvin
2011-06-20  7:41       ` Ingo Molnar
2011-06-20 15:59         ` H. Peter Anvin
2011-06-20 16:40           ` Ingo Molnar
2011-06-20 16:44             ` H. Peter Anvin
2011-06-21  6:56           ` [PATCH 00/10] Enhance /dev/mem to allow read/write of Srivatsa Vaddagiri
2011-06-20  0:42     ` Matthew Wilcox
2011-06-20  0:46       ` [PATCH 00/10] Enhance /dev/mem to allow read/write of arbitrary Ryan Mallon
2011-06-20  0:52         ` [PATCH 00/10] Enhance /dev/mem to allow read/write of Matthew Wilcox
2011-06-20  1:02           ` [PATCH 00/10] Enhance /dev/mem to allow read/write of arbitrary Ryan Mallon
2011-06-20  7:31     ` Ingo Molnar
2011-06-20  8:03       ` Ryan Mallon
2011-06-20 17:10     ` Ray Lee
2011-06-29  9:05   ` [PATCH 00/10] Enhance /dev/mem to allow read/write of arbitrary physical addresses Petr Tesarik
2011-07-01 12:58     ` [PATCH 00/10] Enhance /dev/mem to allow read/write of arbitrary Ingo Molnar
2011-07-01 13:43       ` [PATCH 00/10] Enhance /dev/mem to allow read/write of arbitrary physical addresses Petr Tesarik
2011-07-01 13:47       ` [PATCH 00/10] Enhance /dev/mem to allow read/write of arbitrary Christoph Hellwig
2011-07-01 14:37         ` Ingo Molnar
2011-07-01 14:41           ` Christoph Hellwig
2011-07-01 14:46             ` Ingo Molnar
2011-07-01 14:54               ` [PATCH 00/10] Enhance /dev/mem to allow read/write of arbitrary physical addresses Petr Tesarik
2011-07-01 15:36                 ` [PATCH 00/10] Enhance /dev/mem to allow read/write of arbitrary Ingo Molnar
2011-07-01 16:00                   ` H. Peter Anvin
2011-07-01 16:13                     ` Ingo Molnar
2011-07-01 19:34                       ` [PATCH 00/10] Enhance /dev/mem to allow read/write of arbitrary physical addresses Petr Tesarik
2011-07-01 19:56                         ` [PATCH 00/10] Enhance /dev/mem to allow read/write of arbitrary Ingo Molnar
2011-07-01 20:44                           ` Petr Tesarik [this message]
2011-07-03 19:46                             ` Ingo Molnar
2011-07-05 17:49                               ` [PATCH 00/10] Enhance /dev/mem to allow read/write of Matthew Garrett
2011-07-05 17:56                                 ` [PATCH 00/10] Enhance /dev/mem to allow read/write of arbitrary H. Peter Anvin
2011-07-05 22:34                                 ` H. Peter Anvin

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=201107012244.57593.ptesarik@suse.cz \
    --to=ptesarik@suse.cz \
    --cc=linux-arm-kernel@lists.infradead.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