* [PATCH -next] proc: fix task_struct infoleak
@ 2011-12-11 18:28 Vasiliy Kulikov
2011-12-11 20:59 ` Al Viro
2011-12-11 23:20 ` Hugh Dickins
0 siblings, 2 replies; 4+ messages in thread
From: Vasiliy Kulikov @ 2011-12-11 18:28 UTC (permalink / raw)
To: Andrew Morton
Cc: Al Viro, Alexey Dobriyan, kernel-hardening, linux-kernel,
Hugh Dickins
proc_pid_permission() doesn't put task_struct on every /proc/$pid/
access. A demo from Hugh Dickins:
while :; do ps; grep KernelStack /proc/meminfo; sleep 1; done
Reported-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
---
This is a patch against a hidepid patchset from -mm.
fs/proc/base.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 8caf5cb..0e5c577 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -646,9 +646,14 @@ static bool has_pid_permissions(struct pid_namespace *pid,
static int proc_pid_permission(struct inode *inode, int mask)
{
struct pid_namespace *pid = inode->i_sb->s_fs_info;
- struct task_struct *task = get_proc_task(inode);
+ struct task_struct *task;
+ int has_perms;
+
+ task = get_proc_task(inode);
+ has_perms = has_pid_permissions(pid, task, 1);
+ put_task_struct(task);
- if (!has_pid_permissions(pid, task, 1)) {
+ if (!has_perms) {
if (pid->hide_pid == 2) {
/*
* Let's make getdents(), stat(), and open()
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH -next] proc: fix task_struct infoleak
2011-12-11 18:28 [PATCH -next] proc: fix task_struct infoleak Vasiliy Kulikov
@ 2011-12-11 20:59 ` Al Viro
2011-12-12 11:31 ` Vasiliy Kulikov
2011-12-11 23:20 ` Hugh Dickins
1 sibling, 1 reply; 4+ messages in thread
From: Al Viro @ 2011-12-11 20:59 UTC (permalink / raw)
To: Vasiliy Kulikov
Cc: Andrew Morton, Alexey Dobriyan, kernel-hardening, linux-kernel,
Hugh Dickins
On Sun, Dec 11, 2011 at 10:28:21PM +0400, Vasiliy Kulikov wrote:
> proc_pid_permission() doesn't put task_struct on every /proc/$pid/
> access. A demo from Hugh Dickins:
>
> while :; do ps; grep KernelStack /proc/meminfo; sleep 1; done
>
> Reported-by: Hugh Dickins <hughd@google.com>
> Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
> ---
> This is a patch against a hidepid patchset from -mm.
Choose saner commit summary, please. It's not information leak, for pity sake
- it's a plain and simple memory leak...
Speaking of which, I've a couple of memory leaks in mainline procfs and
mqueue; Alexey, are you OK with that sucker going directly to Linus or
would you rather push it yourself? See the patch below...
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 9a8a2b7..03102d9 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -91,20 +91,18 @@ static struct file_system_type proc_fs_type = {
void __init proc_root_init(void)
{
- struct vfsmount *mnt;
int err;
proc_init_inodecache();
err = register_filesystem(&proc_fs_type);
if (err)
return;
- mnt = kern_mount_data(&proc_fs_type, &init_pid_ns);
- if (IS_ERR(mnt)) {
+ err = pid_ns_prepare_proc(&init_pid_ns);
+ if (err) {
unregister_filesystem(&proc_fs_type);
return;
}
- init_pid_ns.proc_mnt = mnt;
proc_symlink("mounts", NULL, "self/mounts");
proc_net_init();
@@ -209,5 +207,5 @@ int pid_ns_prepare_proc(struct pid_namespace *ns)
void pid_ns_release_proc(struct pid_namespace *ns)
{
- mntput(ns->proc_mnt);
+ kern_unmount(ns->proc_mnt);
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH -next] proc: fix task_struct infoleak
2011-12-11 18:28 [PATCH -next] proc: fix task_struct infoleak Vasiliy Kulikov
2011-12-11 20:59 ` Al Viro
@ 2011-12-11 23:20 ` Hugh Dickins
1 sibling, 0 replies; 4+ messages in thread
From: Hugh Dickins @ 2011-12-11 23:20 UTC (permalink / raw)
To: Vasiliy Kulikov
Cc: Andrew Morton, Al Viro, Alexey Dobriyan, kernel-hardening,
linux-kernel
On Sun, 11 Dec 2011, Vasiliy Kulikov wrote:
> proc_pid_permission() doesn't put task_struct on every /proc/$pid/
> access. A demo from Hugh Dickins:
>
> while :; do ps; grep KernelStack /proc/meminfo; sleep 1; done
>
> Reported-by: Hugh Dickins <hughd@google.com>
> Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
Thank you, yes, that fixes it for me:
Tested-by: Hugh Dickins <hughd@google.com>
but hopefully akpm will just fold this into the original patch.
Hmm, tiny niggle, but I notice that has_pid_permissions() is
declared, reasonably, as bool; so wouldn't it be better for
has_perms to be declared as bool instead of int? Hardly
worth bothering about, but if you've a mind to respin with
a corrected Subject as Al rightly suggests.
> ---
> This is a patch against a hidepid patchset from -mm.
>
> fs/proc/base.c | 9 +++++++--
> 1 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index 8caf5cb..0e5c577 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -646,9 +646,14 @@ static bool has_pid_permissions(struct pid_namespace *pid,
> static int proc_pid_permission(struct inode *inode, int mask)
> {
> struct pid_namespace *pid = inode->i_sb->s_fs_info;
> - struct task_struct *task = get_proc_task(inode);
> + struct task_struct *task;
> + int has_perms;
> +
> + task = get_proc_task(inode);
> + has_perms = has_pid_permissions(pid, task, 1);
> + put_task_struct(task);
>
> - if (!has_pid_permissions(pid, task, 1)) {
> + if (!has_perms) {
> if (pid->hide_pid == 2) {
> /*
> * Let's make getdents(), stat(), and open()
> --
> 1.7.0.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -next] proc: fix task_struct infoleak
2011-12-11 20:59 ` Al Viro
@ 2011-12-12 11:31 ` Vasiliy Kulikov
0 siblings, 0 replies; 4+ messages in thread
From: Vasiliy Kulikov @ 2011-12-12 11:31 UTC (permalink / raw)
To: Al Viro
Cc: Andrew Morton, Alexey Dobriyan, kernel-hardening, linux-kernel,
Hugh Dickins
On Sun, Dec 11, 2011 at 20:59 +0000, Al Viro wrote:
> On Sun, Dec 11, 2011 at 10:28:21PM +0400, Vasiliy Kulikov wrote:
> > proc_pid_permission() doesn't put task_struct on every /proc/$pid/
> > access. A demo from Hugh Dickins:
> >
> > while :; do ps; grep KernelStack /proc/meminfo; sleep 1; done
> >
> > Reported-by: Hugh Dickins <hughd@google.com>
> > Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
> > ---
> > This is a patch against a hidepid patchset from -mm.
>
> Choose saner commit summary, please. It's not information leak, for pity sake
> - it's a plain and simple memory leak...
Oops! s/infoleak/memleak/ surely, bad habit...
Thank you, I'll resend the patch.
--
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-12-12 11:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-11 18:28 [PATCH -next] proc: fix task_struct infoleak Vasiliy Kulikov
2011-12-11 20:59 ` Al Viro
2011-12-12 11:31 ` Vasiliy Kulikov
2011-12-11 23:20 ` Hugh Dickins
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox