[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-man
Subject:    Re: [PATCH] setpgid.2, exit.3: document the lack of POSIX-specified behaviour inside PID NS
From:       ebiederm () xmission ! com (Eric W !  Biederman)
Date:       2019-03-10 16:59:26
Message-ID: 87ef7esm1d.fsf () xmission ! com
[Download RAW message or body]

"Dmitry V. Levin" <ldv@altlinux.org> writes:

> On Thu, Mar 07, 2019 at 09:02:07PM +0100, Eugene Syromyatnikov wrote:
>> On Thu, Mar 7, 2019 at 8:05 PM Eugene Syromyatnikov <evgsyr@gmail.com> wrote:
>> >
>> > The POSIX-mandated behaviour of sending SIGCONT/SIGHUP to stopped processes
>> > of an orphaned process group is not observed inside PID namespaces, as
>> > can be verified by running [1] inside a PID namespace, for example.
>> >
>> > The derivation is (presumably) introduced by Linux commit
>> s/derivation/deviation/
>> 
>> > v2.6.24-rc1~237 ("pid namespaces: define is_global_init() and
>> > is_container_init()").
>> >
>> > [1] https://gitlab.com/strace/strace/commit/4278e6613f48273e7da0989712f1c18aaffefd84
>> >
>> > Reported-by: Dmitry V. Levin <ldv@altlinux.org>
>> > Signed-off-by: Eugene Syromyatnikov <evgsyr@gmail.com>
>> 
>> It should probably also be noted that the behaviour is also described
>> in TLPI, Section 34.8 ("Process groups, sessions, and job control:
>> Summary"), so it also likely has to be updated.
>
> Strictly speaking, whether orphaned process group semantics works in
> a PID namespace or not depends on the session ID.  If the session ID is
> the same as the session ID of init (which happens quite often in case
> of a PID namespace), then orphaned process group semantics doesn't work.
> If they differ, then the POSIX-mandated behaviour is supported.


http://pubs.opengroup.org/onlinepubs/9699919799 says:
> 3.264:  Orphaned Process Group
> 
> A process group in which the parent of every member is either itself
> a member of the process group or is not a member of the group's session.

It does not say anything about init.

Which makes the current version of orphaned process group handling posix
conformant.  By not ignoring the pid namespace init the code may not be
backwards compatible with the rest of linux.    Which may be a problem
worth addressing, either in the documentation or in the code.

It is not a break from posix.

Where is this behavior a problem?

> For example:
>
> $ unshare -fprU sh -c './orphaned_process_group >/dev/null' && echo good || echo bad
> Orphaned process group semantics is not supported by the kernel
> bad
> $ unshare -fprU sh -c 'setsid ./orphaned_process_group >/dev/null' && echo good || echo bad
> good
>
> What can I say?  The very least that could be done to fix this is
> to replace is_global_init() invocation with is_container_init()
> in will_become_orphaned_pgrp() as suggested in
> https://lkml.org/lkml/2007/12/8/208

Eric

p.s.  I will be will likely be slow to respond as I am experiencing a stream of real
life NMIs.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic