lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 23 Jun 2009 22:06:27 -0500
From:	"Serge E. Hallyn" <serue@...ibm.com>
To:	Oleg Nesterov <oleg@...hat.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Christoph Hellwig <hch@...radead.org>,
	James Morris <jmorris@...ei.org>, Ingo Molnar <mingo@...e.hu>,
	Chris Wright <chrisw@...s-sol.org>,
	Roland McGrath <roland@...hat.com>,
	linux-kernel@...r.kernel.org, Al Viro <viro@...IV.linux.org.uk>,
	linux-security-module@...r.kernel.org
Subject: Re: [PATCH 1/1] mm_for_maps: simplify, use ptrace_may_access()

Quoting Oleg Nesterov (oleg@...hat.com):
> It would be nice to kill __ptrace_may_access(). It requires task_lock(),
> but this lock is only needed to read mm->flags in the middle.
> 
> Convert mm_for_maps() to use ptrace_may_access(), this also simplifies
> the code a little bit.
> 
> Also, we do not need to take ->mmap_sem in advance. In fact I think
> mm_for_maps() should not play with ->mmap_sem at all, the caller should
> take this lock.

Yeah I think that makes sense.

> With or without this patch, without ->cred_guard_mutex held we can race
> with exec() and get the new ->mm but check old creds.
> 
> Signed-off-by: Oleg Nesterov <oleg@...hat.com>

reasoning on the security check also makes sense.

Reviewed-by: Serge Hallyn <serue@...ibm.com>

> --- WAIT/fs/proc/base.c~1_MM_FOR_MAPS	2009-06-17 14:11:26.000000000 +0200
> +++ WAIT/fs/proc/base.c	2009-06-23 20:16:44.000000000 +0200
> @@ -237,20 +237,19 @@ struct mm_struct *mm_for_maps(struct tas
>  	struct mm_struct *mm = get_task_mm(task);
>  	if (!mm)
>  		return NULL;
> +	if (mm != current->mm) {
> +		/*
> +		 * task->mm can be changed before security check,
> +		 * in that case we must notice the change after.
> +		 */
> +		if (!ptrace_may_access(task, PTRACE_MODE_READ) ||
> +		    mm != task->mm) {
> +			mmput(mm);
> +			return NULL;
> +		}
> +	}
>  	down_read(&mm->mmap_sem);
> -	task_lock(task);
> -	if (task->mm != mm)
> -		goto out;
> -	if (task->mm != current->mm &&
> -	    __ptrace_may_access(task, PTRACE_MODE_READ) < 0)
> -		goto out;
> -	task_unlock(task);
>  	return mm;
> -out:
> -	task_unlock(task);
> -	up_read(&mm->mmap_sem);
> -	mmput(mm);
> -	return NULL;
>  }
> 
>  static int proc_pid_cmdline(struct task_struct *task, char * buffer)
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ