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:	Mon, 6 Apr 2015 02:31:56 -0700
From:	Josh Triplett <josh@...htriplett.org>
To:	Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Cc:	Al Viro <viro@...iv.linux.org.uk>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Andy Lutomirski <luto@...nel.org>,
	Ingo Molnar <mingo@...hat.com>,
	Kees Cook <keescook@...omium.org>,
	Oleg Nesterov <oleg@...hat.com>,
	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
	"H. Peter Anvin" <hpa@...or.com>, Rik van Riel <riel@...hat.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Michael Kerrisk <mtk.manpages@...il.com>,
	Thiago Macieira <thiago.macieira@...el.com>,
	linux-kernel@...r.kernel.org, linux-api@...r.kernel.org,
	linux-fsdevel@...r.kernel.org, x86@...nel.org
Subject: Re: [PATCH v2 7/7] clone4: Add a CLONE_FD flag to get task exit
 notification via fd

On Mon, Apr 06, 2015 at 05:30:35PM +0900, Sergey Senozhatsky wrote:
> On (03/15/15 01:00), Josh Triplett wrote:
> [..]
> > +
> > +/* Handle the CLONE_FD case for copy_process. */
> > +int clonefd_do_clone(u64 clone_flags, struct task_struct *p,
> > +		     struct clone4_args *args, struct clonefd_setup *setup)
> > +{
> > +	int flags;
> > +	struct file *file;
> > +	int fd;
> > +
> > +	p->clonefd = !!(clone_flags & CLONE_FD);
> > +	if (!p->clonefd)
> > +		return 0;
> > +
> > +	if (args->clonefd_flags & ~(O_CLOEXEC | O_NONBLOCK))
> > +		return -EINVAL;
> > +
> > +	init_waitqueue_head(&p->clonefd_wqh);
> > +
> > +	get_task_struct(p);
> > +	flags = O_RDONLY | FMODE_ATOMIC_POS | args->clonefd_flags;
> > +	file = anon_inode_getfile("[process]", &clonefd_fops, p, flags);
> > +	if (IS_ERR(file)) {
> > +		put_task_struct(p);
> > +		return PTR_ERR(file);
> > +	}
> > +
> > +	fd = get_unused_fd_flags(flags);
> > +	if (fd < 0) {
> 
> +		put_task_struct(p); ?

No, once anon_inode_getfile has succeeded, the file owns the reference
to the task_struct, so fput(file) will call the release function which
calls put_task_struct.  Only the failure case for anon_inode_getfile
needs to call put_task_struct directly.

> > +		fput(file);
> > +		return fd;
> > +	}

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