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, 30 Mar 2012 14:44:26 +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/29, Karl Pickett wrote:
>
> Re: http://thread.gmane.org/gmane.linux.kernel/1236479
>
> I'm wondering if this is going to break code that checks getppid() == 1?
>
> I have a TCL/TK GUI app that spawns ssh.  I want the ssh to die
> immediately if the GUI process crashes, so ssh is launched with a wrapper
> c program that does:
>
>    prctl(PR_SET_PDEATHSIG, SIGHUP);
>    if (getppid() == 1) /* parent died already? */
>        return 0;

Yes, this won't work if the parent of this app does PR_SET_CHILD_SUBREAPER.

> So what is getppid() going to return for some user using this new
> 'session manager reaper'?

The new parent's pid ;)

Perhaps you can do something like

	ppid_for_child = getpid();

	if (!fork()) {
		// Child
		prctl(PR_SET_PDEATHSIG);
		if (getppid() != ppid_for_child)
			return;
		...
	}

Just in case, I do not know how PR_SET_CHILD_SUBREAPER will be really used.
I do not know if systemd will run the "normal" user applications under
PR_SET_CHILD_SUBREAPER. Probably yes, but this is the question to Kay.

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