linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm00@gmail.com>
To: Vasiliy Kulikov <segoon@openwall.com>
Cc: kernel-hardening@lists.openwall.com,
	Christoph Lameter <cl@linux-foundation.org>,
	Pekka Enberg <penberg@kernel.org>, Matt Mackall <mpm@selenic.com>,
	linux-mm@kvack.org, Kees Cook <kees@ubuntu.com>,
	Dave Hansen <dave@linux.vnet.ibm.com>,
	Valdis.Kletnieks@vt.edu,
	Linus Torvalds <torvalds@linux-foundation.org>,
	David Rientjes <rientjes@google.com>,
	Alan Cox <alan@linux.intel.com>,
	linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 2/2] mm: restrict access to /proc/meminfo
Date: Fri, 30 Sep 2011 13:03:53 -0700	[thread overview]
Message-ID: <20110930130353.0da54517.akpm00@gmail.com> (raw)
In-Reply-To: <20110930195329.GA2020@albatros>

On Fri, 30 Sep 2011 23:53:29 +0400
Vasiliy Kulikov <segoon@openwall.com> wrote:

> On Wed, Sep 28, 2011 at 14:46 -0700, Andrew Morton wrote:
> > On Tue, 27 Sep 2011 23:38:10 +0400
> > Vasiliy Kulikov <segoon@openwall.com> wrote:
> > 
> > > On Tue, Sep 27, 2011 at 21:56 +0400, Vasiliy Kulikov wrote:
> > > > /proc/meminfo stores information related to memory pages usage, which
> > > > may be used to monitor the number of objects in specific caches (and/or
> > > > the changes of these numbers).  This might reveal private information
> > > > similar to /proc/slabinfo infoleaks.  To remove the infoleak, just
> > > > restrict meminfo to root.  If it is used by unprivileged daemons,
> > > > meminfo permissions can be altered the same way as slabinfo:
> > > > 
> > > >     groupadd meminfo
> > > >     usermod -a -G meminfo $MONITOR_USER
> > > >     chmod g+r /proc/meminfo
> > > >     chgrp meminfo /proc/meminfo
> > > 
> > > Just to make it clear: since this patch breaks "free", I don't propose
> > > it anymore.
> > 
> > It will break top(1) too.  It isn't my favoritest-ever patch :)
> 
> FWIW, I consider it as a top's bug.  It tries to handle failed open(),
> but forgets to reset tty mode.
> 
> 
> Anyway, how do we expect userspace apps handle meminfo data?  Is it used
> as a debugging information only?  E.g. admin wants to see how much
> memory is used, monitoring daemon looks for memleaks and running out of
> memory (1)?  Or the numbers are used in some calculations e.g.
> calculation of approximate number of parallel processes to spawn (2)?

Well.  Both, of course.  And more.  eg, monitor it and send an SMS
message to the admin when things start to go wrong.

> If we care about (1) only, we may do the same as we do with kernel
> pointers, i.e. show zeroes to non-CAP_SYS_ADMIN users (plus emit a
> sinlge warning in syslog).  It will not break top, and top will simply
> show zero counters.  Admins who still want to read this information as
> non-root should chmod/chgrp it in boot scripts.  (And distros should
> provide a default "debugging" group for these needs.)

meminfo has been around for a very long time and is a convenient and
centralised point for collecting memory data.  There will be a large
number of apps/scripts/tools out there which use it.  Many of these
won't even be available to us.

All of which makes it very hard for us to predict how much breakage we
will cause.

> If we care about (2), we should pass non-zero counters, but imagine some
> default values, which will result in sane processes numbers.  But it
> might depend on specific applications, I'm not aware whether (2) is
> real.
> 
> 
> Other ideas?

echo "chmod 0400 /proc/meminfo" >> /etc/rc.local

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2011-09-30 20:04 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-27 17:54 [PATCH 1/2] mm: restrict access to slab files under procfs and sysfs Vasiliy Kulikov
2011-09-27 17:56 ` [PATCH 2/2] mm: restrict access to /proc/meminfo Vasiliy Kulikov
2011-09-27 18:27   ` David Rientjes
2011-09-27 19:14     ` Vasiliy Kulikov
2011-09-27 19:38   ` Vasiliy Kulikov
2011-09-27 20:03     ` Christoph Lameter
2011-09-27 20:33       ` David Rientjes
2011-09-27 20:47         ` Christoph Lameter
2011-09-28 20:31           ` Dave Hansen
2011-09-28 20:52             ` Alan Cox
2011-09-29  0:43             ` Valdis.Kletnieks
2011-09-29 14:11               ` Christoph Lameter
2011-09-29 16:18         ` Vasiliy Kulikov
2011-09-29 16:30           ` Dave Hansen
2011-09-29 16:43             ` [kernel-hardening] " Vasiliy Kulikov
2011-09-29 16:57           ` Valdis.Kletnieks
2011-09-29 17:25             ` [kernel-hardening] " Vasiliy Kulikov
2011-09-29 17:28           ` Vasiliy Kulikov
2011-09-28 21:46     ` Andrew Morton
2011-09-30 19:53       ` Vasiliy Kulikov
2011-09-30 20:03         ` Andrew Morton [this message]
2011-09-30 20:12           ` Vasiliy Kulikov
2011-09-30 20:15           ` Dave Hansen
2011-09-27 18:08 ` [PATCH 1/2] mm: restrict access to slab files under procfs and sysfs Christoph Lameter
2011-09-27 19:16   ` Vasiliy Kulikov
2011-09-27 19:35     ` Christoph Lameter
2011-09-27 18:21 ` David Rientjes
2011-09-27 20:00   ` Pekka Enberg

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=20110930130353.0da54517.akpm00@gmail.com \
    --to=akpm00@gmail.com \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=akpm@linux-foundation.org \
    --cc=alan@linux.intel.com \
    --cc=cl@linux-foundation.org \
    --cc=dave@linux.vnet.ibm.com \
    --cc=kees@ubuntu.com \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mpm@selenic.com \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=segoon@openwall.com \
    --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;
as well as URLs for NNTP newsgroup(s).