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:	Fri, 2 Mar 2012 16:26:22 +0100
From:	Oleg Nesterov <oleg@...hat.com>
To:	Cyrill Gorcunov <gorcunov@...nvz.org>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
	Pavel Emelyanov <xemul@...allels.com>,
	Kees Cook <keescook@...omium.org>, Tejun Heo <tj@...nel.org>
Subject: Re: [RFC] c/r: prctl: Add ability to set new mm_struct::exe_file

On 03/02, Cyrill Gorcunov wrote:
>
> On Thu, Mar 01, 2012 at 08:41:20PM +0100, Oleg Nesterov wrote:
> ...
> > Still can't understand. I think you need:
> >
> > 	file = fget(fd);
> > 	if (!file)
> > 		return -EBADF;
> >
> > 	down_write(&mm->mmap_sem);
> > 	if (mm->num_exe_file_vmas) {
> > 		fput(mm->exe_file);
> > 		mm->exe_file = file;
> > 		file = NULL;
> > 	}
> > 	up_write(&mm->mmap_sem);
> >
> > 	if (!file)
> > 		return 0;
> >
> > 	fput(file);
> > 	return -ESOMETHING;
> >
> > and that is all.
>
> Hi Oleg, sure you were right. I even think testing for
> num_exe_file_vmas is not needed, since until real
> executable VMA is read and mapped it might remain
> zero. So I guess something like below should work.

No, you need to check num_exe_file_vmas != 0.

> +static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
> +{
> +	struct file *new_exe_file, *old_exe_file;
> +
> +	new_exe_file = fget(fd);
> +	if (!new_exe_file)
> +		return -EBADF;
> +
> +	down_write(&mm->mmap_sem);
> +	old_exe_file = mm->exe_file;
> +	mm->exe_file = new_exe_file;
> +	up_write(&mm->mmap_sem);

This changes the current rule: mm->exe_file goes away once
num_exe_file_vmas becomes zero.

Oleg.

--
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