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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20120330171430.GA5865@redhat.com>
Date:	Fri, 30 Mar 2012 19:14:30 +0200
From:	Oleg Nesterov <oleg@...hat.com>
To:	Karl Pickett <kjp@...uchicago.edu>
Cc:	linux-kernel@...r.kernel.org, kay.sievers@...y.org,
	Lennart Poettering <lennart@...ttering.net>
Subject: Re: Is prctl(PR_SET_CHILD_SUBREAPER) going to break my code which
	checks getppid == 1?

On 03/30, Karl Pickett wrote:
>
> On Mar 30, 2012, at 7:44 AM, Oleg Nesterov wrote:
>
> > Perhaps you can do something like
> >
> > 	ppid_for_child = getpid();
> >
> > 	if (!fork()) {
> > 		// Child
> > 		prctl(PR_SET_PDEATHSIG);
> > 		if (getppid() != ppid_for_child)
> > 			return;
> > 		...
> > 	}
>
> There are two problems with that.  1., I don't think TCL/TK lets me access
> the parent pre-fork env like that - all I can change is the execed code.

Can't comment this, I do not know tcl/tk

> 2., That has a clear race with pid wrap around.

Not really. This ppid_for_child can be re-used, yes. But the new process
which gets this pid can't become the parent, getppid() can't return this
number.

Btw, PR_SET_PDEATHSIG + getppid() check is racy anyway (with or without
PR_SET_CHILD_SUBREAPER), it can race with reparenting. But the window is
tiny and the problem is purely theoretical I think.

> You really need a
> prctl(PR_DID_MY_REAL_PARENT_DIE) function to be safe.

Oh, I don't know. Sure, PR_SET_CHILD_SUBREAPER can confuse the child.
Just suppose it does daemonize() + assert(getppid() == 1). But this
is not the kernel problem.

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