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: <20120403150225.GA6152@redhat.com>
Date:	Tue, 3 Apr 2012 17:02:25 +0200
From:	Oleg Nesterov <oleg@...hat.com>
To:	Cong Wang <xiyou.wangcong@...il.com>
Cc:	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	Alexey Dobriyan <adobriyan@...il.com>,
	Al Viro <viro@...iv.linux.org.uk>,
	Vasiliy Kulikov <segoon@...nwall.com>,
	David Rientjes <rientjes@...gle.com>
Subject: Re: [Patch v2] proc: clean up /proc/<pid>/environ handling

On 04/03, Cong Wang wrote:
>
> +static int environ_open(struct inode *inode, struct file *file)
> +{
> +	struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
> +	struct mm_struct *mm;
> +
> +	if (!task)
> +		return -ESRCH;
> +
> +	mm = mm_for_maps(task);
> +	put_task_struct(task);
> +
> +	if (IS_ERR(mm))
> +		return PTR_ERR(mm);
> +
> +	if (mm) {
> +		/* ensure this mm_struct can't be freed */
> +		atomic_inc(&mm->mm_count);
> +		/* but do not pin its memory */
> +		mmput(mm);
> +	}
> +
> +	file->private_data = mm;
> +
> +	return 0;
> +}

Well, can we unify this code with mem_open() ? Say, let it be
__mem_open() or whatever, then mem_open() can use the common
helper and add FMODE_UNSIGNED_OFFSET. Just we need another
argument for mm_access.

> +static int environ_release(struct inode *inode, struct file *file)
> +{
> +	struct mm_struct *mm = file->private_data;
> +	if (mm)
> +		mmdrop(mm);
> +	return 0;
> +}

Again, this is identical with mem_release(), proc_environ_operations
can simply use it instead.

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