From: ebiederm@xmission.com (Eric W. Biederman)
To: Djalal Harouni <tixxdz@opendz.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org,
kernel-hardening@lists.openwall.com
Subject: [kernel-hardening] Re: [PATCH 1/2] procfs: restore 0400 permissions on /proc/*/{syscall,stack,personality}
Date: Mon, 26 Aug 2013 09:49:48 -0700 [thread overview]
Message-ID: <871u5gqtw3.fsf@xmission.com> (raw)
In-Reply-To: <1377534240-13227-1-git-send-email-tixxdz@opendz.org> (Djalal Harouni's message of "Mon, 26 Aug 2013 17:23:59 +0100")
Djalal Harouni <tixxdz@opendz.org> writes:
> Avoid giving an fd on privileged files for free by switching these
> files to 0400 mode.
This seems to be a revert of Al's patch in March of 2011 based on broken
reasoning.
Al Viro commited:
> commit a9712bc12c40c172e393f85a9b2ba8db4bf59509
> Author: Al Viro <viro@zeniv.linux.org.uk>
> Date: Wed Mar 23 15:52:50 2011 -0400
>
> deal with races in /proc/*/{syscall,stack,personality}
>
> All of those are rw-r--r-- and all are broken for suid - if you open
> a file before the target does suid-root exec, you'll be still able
> to access it. For personality it's not a big deal, but for syscall
> and stack it's a real problem.
>
> Fix: check that task is tracable for you at the time of read().
>
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
How does changing the permissions to S_IRUSR prevent someone from
opening the file before, and reading the file after a suid exec?
> This patch restores the old mode which was 0400
Which seems to add no security whatsoever and obscure the fact that
anyone who cares can read the file so what is the point?
Eric
>
> Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
> ---
> fs/proc/base.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index 1485e38..6b162cd 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -2576,7 +2576,7 @@ static const struct pid_entry tgid_base_stuff[] = {
> REG("environ", S_IRUSR, proc_environ_operations),
> INF("auxv", S_IRUSR, proc_pid_auxv),
> ONE("status", S_IRUGO, proc_pid_status),
> - ONE("personality", S_IRUGO, proc_pid_personality),
> + ONE("personality", S_IRUSR, proc_pid_personality),
> INF("limits", S_IRUGO, proc_pid_limits),
> #ifdef CONFIG_SCHED_DEBUG
> REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
> @@ -2586,7 +2586,7 @@ static const struct pid_entry tgid_base_stuff[] = {
> #endif
> REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
> #ifdef CONFIG_HAVE_ARCH_TRACEHOOK
> - INF("syscall", S_IRUGO, proc_pid_syscall),
> + INF("syscall", S_IRUSR, proc_pid_syscall),
> #endif
> INF("cmdline", S_IRUGO, proc_pid_cmdline),
> ONE("stat", S_IRUGO, proc_tgid_stat),
> @@ -2614,7 +2614,7 @@ static const struct pid_entry tgid_base_stuff[] = {
> INF("wchan", S_IRUGO, proc_pid_wchan),
> #endif
> #ifdef CONFIG_STACKTRACE
> - ONE("stack", S_IRUGO, proc_pid_stack),
> + ONE("stack", S_IRUSR, proc_pid_stack),
> #endif
> #ifdef CONFIG_SCHEDSTATS
> INF("schedstat", S_IRUGO, proc_pid_schedstat),
> @@ -2915,14 +2915,14 @@ static const struct pid_entry tid_base_stuff[] = {
> REG("environ", S_IRUSR, proc_environ_operations),
> INF("auxv", S_IRUSR, proc_pid_auxv),
> ONE("status", S_IRUGO, proc_pid_status),
> - ONE("personality", S_IRUGO, proc_pid_personality),
> + ONE("personality", S_IRUSR, proc_pid_personality),
> INF("limits", S_IRUGO, proc_pid_limits),
> #ifdef CONFIG_SCHED_DEBUG
> REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
> #endif
> REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
> #ifdef CONFIG_HAVE_ARCH_TRACEHOOK
> - INF("syscall", S_IRUGO, proc_pid_syscall),
> + INF("syscall", S_IRUSR, proc_pid_syscall),
> #endif
> INF("cmdline", S_IRUGO, proc_pid_cmdline),
> ONE("stat", S_IRUGO, proc_tid_stat),
> @@ -2952,7 +2952,7 @@ static const struct pid_entry tid_base_stuff[] = {
> INF("wchan", S_IRUGO, proc_pid_wchan),
> #endif
> #ifdef CONFIG_STACKTRACE
> - ONE("stack", S_IRUGO, proc_pid_stack),
> + ONE("stack", S_IRUSR, proc_pid_stack),
> #endif
> #ifdef CONFIG_SCHEDSTATS
> INF("schedstat", S_IRUGO, proc_pid_schedstat),
WARNING: multiple messages have this Message-ID (diff)
From: ebiederm@xmission.com (Eric W. Biederman)
To: Djalal Harouni <tixxdz@opendz.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org,
kernel-hardening@lists.openwall.com
Subject: Re: [PATCH 1/2] procfs: restore 0400 permissions on /proc/*/{syscall,stack,personality}
Date: Mon, 26 Aug 2013 09:49:48 -0700 [thread overview]
Message-ID: <871u5gqtw3.fsf@xmission.com> (raw)
In-Reply-To: <1377534240-13227-1-git-send-email-tixxdz@opendz.org> (Djalal Harouni's message of "Mon, 26 Aug 2013 17:23:59 +0100")
Djalal Harouni <tixxdz@opendz.org> writes:
> Avoid giving an fd on privileged files for free by switching these
> files to 0400 mode.
This seems to be a revert of Al's patch in March of 2011 based on broken
reasoning.
Al Viro commited:
> commit a9712bc12c40c172e393f85a9b2ba8db4bf59509
> Author: Al Viro <viro@zeniv.linux.org.uk>
> Date: Wed Mar 23 15:52:50 2011 -0400
>
> deal with races in /proc/*/{syscall,stack,personality}
>
> All of those are rw-r--r-- and all are broken for suid - if you open
> a file before the target does suid-root exec, you'll be still able
> to access it. For personality it's not a big deal, but for syscall
> and stack it's a real problem.
>
> Fix: check that task is tracable for you at the time of read().
>
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
How does changing the permissions to S_IRUSR prevent someone from
opening the file before, and reading the file after a suid exec?
> This patch restores the old mode which was 0400
Which seems to add no security whatsoever and obscure the fact that
anyone who cares can read the file so what is the point?
Eric
>
> Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
> ---
> fs/proc/base.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index 1485e38..6b162cd 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -2576,7 +2576,7 @@ static const struct pid_entry tgid_base_stuff[] = {
> REG("environ", S_IRUSR, proc_environ_operations),
> INF("auxv", S_IRUSR, proc_pid_auxv),
> ONE("status", S_IRUGO, proc_pid_status),
> - ONE("personality", S_IRUGO, proc_pid_personality),
> + ONE("personality", S_IRUSR, proc_pid_personality),
> INF("limits", S_IRUGO, proc_pid_limits),
> #ifdef CONFIG_SCHED_DEBUG
> REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
> @@ -2586,7 +2586,7 @@ static const struct pid_entry tgid_base_stuff[] = {
> #endif
> REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
> #ifdef CONFIG_HAVE_ARCH_TRACEHOOK
> - INF("syscall", S_IRUGO, proc_pid_syscall),
> + INF("syscall", S_IRUSR, proc_pid_syscall),
> #endif
> INF("cmdline", S_IRUGO, proc_pid_cmdline),
> ONE("stat", S_IRUGO, proc_tgid_stat),
> @@ -2614,7 +2614,7 @@ static const struct pid_entry tgid_base_stuff[] = {
> INF("wchan", S_IRUGO, proc_pid_wchan),
> #endif
> #ifdef CONFIG_STACKTRACE
> - ONE("stack", S_IRUGO, proc_pid_stack),
> + ONE("stack", S_IRUSR, proc_pid_stack),
> #endif
> #ifdef CONFIG_SCHEDSTATS
> INF("schedstat", S_IRUGO, proc_pid_schedstat),
> @@ -2915,14 +2915,14 @@ static const struct pid_entry tid_base_stuff[] = {
> REG("environ", S_IRUSR, proc_environ_operations),
> INF("auxv", S_IRUSR, proc_pid_auxv),
> ONE("status", S_IRUGO, proc_pid_status),
> - ONE("personality", S_IRUGO, proc_pid_personality),
> + ONE("personality", S_IRUSR, proc_pid_personality),
> INF("limits", S_IRUGO, proc_pid_limits),
> #ifdef CONFIG_SCHED_DEBUG
> REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
> #endif
> REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
> #ifdef CONFIG_HAVE_ARCH_TRACEHOOK
> - INF("syscall", S_IRUGO, proc_pid_syscall),
> + INF("syscall", S_IRUSR, proc_pid_syscall),
> #endif
> INF("cmdline", S_IRUGO, proc_pid_cmdline),
> ONE("stat", S_IRUGO, proc_tid_stat),
> @@ -2952,7 +2952,7 @@ static const struct pid_entry tid_base_stuff[] = {
> INF("wchan", S_IRUGO, proc_pid_wchan),
> #endif
> #ifdef CONFIG_STACKTRACE
> - ONE("stack", S_IRUGO, proc_pid_stack),
> + ONE("stack", S_IRUSR, proc_pid_stack),
> #endif
> #ifdef CONFIG_SCHEDSTATS
> INF("schedstat", S_IRUGO, proc_pid_schedstat),
next prev parent reply other threads:[~2013-08-26 16:49 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-26 16:23 [kernel-hardening] [PATCH 1/2] procfs: restore 0400 permissions on /proc/*/{syscall,stack,personality} Djalal Harouni
2013-08-26 16:23 ` Djalal Harouni
2013-08-26 16:24 ` [kernel-hardening] [PATCH 2/2] procfs: restore 0400 permissions on /proc/*/pagemap Djalal Harouni
2013-08-26 16:24 ` Djalal Harouni
2013-08-26 16:50 ` [kernel-hardening] " Eric W. Biederman
2013-08-26 16:50 ` Eric W. Biederman
2013-08-26 16:49 ` Eric W. Biederman [this message]
2013-08-26 16:49 ` [PATCH 1/2] procfs: restore 0400 permissions on /proc/*/{syscall,stack,personality} Eric W. Biederman
2013-08-26 17:20 ` [kernel-hardening] " Al Viro
2013-08-26 17:20 ` Al Viro
2013-08-27 17:24 ` [kernel-hardening] " Djalal Harouni
2013-08-27 17:24 ` Djalal Harouni
2013-08-28 20:11 ` [kernel-hardening] " Djalal Harouni
2013-08-28 20:11 ` Djalal Harouni
2013-08-28 20:49 ` [kernel-hardening] " Kees Cook
2013-08-28 20:49 ` Kees Cook
2013-08-28 21:11 ` [kernel-hardening] " Djalal Harouni
2013-08-28 21:11 ` Djalal Harouni
2013-08-29 0:26 ` [kernel-hardening] " Eric W. Biederman
2013-08-29 0:26 ` Eric W. Biederman
2013-08-29 0:30 ` [kernel-hardening] " Kees Cook
2013-08-29 0:30 ` Kees Cook
2013-08-29 1:08 ` [kernel-hardening] " Eric W. Biederman
2013-08-29 1:08 ` Eric W. Biederman
2013-08-29 3:33 ` [kernel-hardening] " Kees Cook
2013-08-29 3:33 ` Kees Cook
2013-08-29 7:42 ` [kernel-hardening] " Eric W. Biederman
2013-08-29 7:42 ` Eric W. Biederman
2013-08-29 9:11 ` [kernel-hardening] " Djalal Harouni
2013-08-29 9:11 ` Djalal Harouni
2013-08-29 22:14 ` [kernel-hardening] " Kees Cook
2013-08-29 22:14 ` Kees Cook
2013-08-31 20:26 ` [kernel-hardening] " Djalal Harouni
2013-08-31 20:26 ` Djalal Harouni
2013-09-01 1:44 ` [kernel-hardening] " Eric W. Biederman
2013-09-01 1:44 ` Eric W. Biederman
2013-09-01 15:04 ` [kernel-hardening] " Kees Cook
2013-09-01 15:04 ` Kees Cook
2013-09-12 1:23 ` [kernel-hardening] " Djalal Harouni
2013-09-12 1:23 ` Djalal Harouni
2013-10-04 0:41 ` [kernel-hardening] " Kees Cook
2013-10-04 0:41 ` Kees Cook
2013-10-04 0:53 ` [kernel-hardening] " Ryan Mallon
2013-10-04 0:53 ` Ryan Mallon
2013-08-26 20:34 ` [kernel-hardening] " Djalal Harouni
2013-08-26 20:34 ` Djalal Harouni
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=871u5gqtw3.fsf@xmission.com \
--to=ebiederm@xmission.com \
--cc=akpm@linux-foundation.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tixxdz@opendz.org \
--cc=viro@zeniv.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.