From: Andrew Morton <akpm@linux-foundation.org>
To: Dan Rosenberg <drosenberg@vsecurity.com>
Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
mingo@elte.hu, kees.cook@canonical.com, security@kernel.org
Subject: Re: [PATCH v3] Restrict unprivileged access to kernel syslog
Date: Wed, 10 Nov 2010 15:49:56 -0800 [thread overview]
Message-ID: <20101110154956.83a3f84d.akpm@linux-foundation.org> (raw)
In-Reply-To: <1289431735.3847.9.camel@dan>
On Wed, 10 Nov 2010 18:28:55 -0500
Dan Rosenberg <drosenberg@vsecurity.com> wrote:
> The kernel syslog contains debugging information that is often useful
> during exploitation of other vulnerabilities, such as kernel heap
> addresses. Rather than futilely attempt to sanitize hundreds (or
> thousands) of printk statements and simultaneously cripple useful
> debugging functionality, it is far simpler to create an option that
> prevents unprivileged users from reading the syslog.
>
> This patch, loosely based on grsecurity's GRKERNSEC_DMESG, creates the
> dmesg_restrict sysctl. When set to "0", the default, no restrictions
> are enforced. When set to "1", only users with CAP_SYS_ADMIN can read
> the kernel syslog via dmesg(8) or other mechanisms.
>
> v3 sets a default for the config, renames to
> CONFIG_SECURITY_DMESG_RESTRICT to be consistent with the sysctl name,
> and adds Acks.
>
The patch adds trailing whitespace. checkpatch detects it.
> CC: stable <stable@kernel.org>
hm. Reasons for this?
> ...
>
> +dmesg_restrict:
> +
> +This toggle indicates whether unprivileged users are prevented
> +from using dmesg(8) to view messages from the kernel's log
> +buffer. By default, it is set to (0), resulting in no
> +restrictions. When set to (1), users must have CAP_SYS_ADMIN
> +to use dmesg(8).
Actually, the default depends on CONFIG_SECURITY_DMESG_RESTRICT ;)
> +==============================================================
> +
> domainname & hostname:
>
> These files can be used to set the NIS/YP domainname and the
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 450092c..f0d0088 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -293,6 +293,7 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
> unsigned int interval_msec);
>
> extern int printk_delay_msec;
> +extern int dmesg_restrict;
>
> /*
> * Print a one-time message (analogous to WARN_ONCE() et al):
> diff --git a/kernel/printk.c b/kernel/printk.c
> index b2ebaee..38e7d58 100644
> --- a/kernel/printk.c
> +++ b/kernel/printk.c
> @@ -261,6 +261,12 @@ static inline void boot_delay_msec(void)
> }
> #endif
>
> +#ifdef CONFIG_SECURITY_DMESG_RESTRICT
> +int dmesg_restrict = 1;
> +#else
> +int dmesg_restrict;
> +#endif
You might be able to make this an int type and do
int dmesg_restrict = CONFIG_SECURITY_DMESG_RESTRICT;
We did a trick like that with CONFIG_BASE_SMALL:
int whatever = CONFIG_BASE_SMALL ? 2 : 42;
otoh you might decide not to bother, in which case, this?
--- a/Documentation/sysctl/kernel.txt~restrict-unprivileged-access-to-kernel-syslog-fix
+++ a/Documentation/sysctl/kernel.txt
@@ -216,11 +216,14 @@ to decide what to do with it.
dmesg_restrict:
-This toggle indicates whether unprivileged users are prevented
-from using dmesg(8) to view messages from the kernel's log
-buffer. By default, it is set to (0), resulting in no
-restrictions. When set to (1), users must have CAP_SYS_ADMIN
-to use dmesg(8).
+This toggle indicates whether unprivileged users are prevented from using
+dmesg(8) to view messages from the kernel's log buffer. When
+dmesg_restrict is set to (0) there are no restrictions. When
+dmesg_restrict is set set to (1), users must have CAP_SYS_ADMIN to use
+dmesg(8).
+
+The kernel config option CONFIG_SECURITY_DMESG_RESTRICT sets the default
+value of dmesg_restrict.
==============================================================
_
next prev parent reply other threads:[~2010-11-10 23:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-10 23:28 [PATCH v3] Restrict unprivileged access to kernel syslog Dan Rosenberg
2010-11-10 23:49 ` Andrew Morton [this message]
2010-11-11 4:19 ` James Morris
2010-11-11 8:55 ` Ingo Molnar
2010-11-11 20:14 ` James Morris
2010-11-11 0:48 ` [Security] " Greg KH
2010-11-11 4:22 ` James Morris
2011-01-02 9:05 ` Pavel Machek
2011-01-02 16:08 ` Dan Rosenberg
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=20101110154956.83a3f84d.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=drosenberg@vsecurity.com \
--cc=kees.cook@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=security@kernel.org \
--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