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]
Message-ID: <20120301194120.GA11400@redhat.com>
Date:	Thu, 1 Mar 2012 20:41:20 +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/01, Cyrill Gorcunov wrote:
>
> So, Oleg, basically the new version will use opened fd in form
> like (note, I'll recheck for refs and locks more so this is
> a draft version to point idea)
>
> static int prctl_set_mm_exe_file(struct mm_struct *mm, unsigned int fd)
> {
> 	struct files_struct *files;
> 	struct file *file;
> 	int ret;
>
> 	/*
> 	 * Make sure if someone is trying to obtain
> 	 * the existing exe_file it will not get
> 	 * results until we've finished.
> 	 */
> 	down_write(&mm->mmap_sem);
>
> 	files = get_files_struct(current);
> 	if (!files)
> 		return -EINVAL;
>
> 	spin_lock(&files->file_lock);
>
> 	file = fcheck_files(files, fd);
> 	if (!file) {
> 		ret = -EBADFD;
> 		goto out_unlock;
> 	}
> 	get_file(file);
> 	spin_unlock(&files->file_lock);
>
> 	if (mm->num_exe_file_vmas)
> 		removed_exe_file_vma(mm);

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.

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