[LTP] [PATCH] setpgid02: Use pid_max as PGID for EPERM

Cyril Hrubis chrubis@suse.cz
Thu Apr 20 10:50:38 CEST 2023


Hi!
> The mechanism is indeed different. My first approach to this patch was 
> to fork and setsid() the child, which
> implied an EPERM due to the session difference.
> However, when discussing this approach on the mailing list (see 
> https://lists.linux.it/pipermail/ltp/2023-April/033505.html )
> it was brought to my attention that setpgid03 is in fact doing exactly 
> that already.
> 
> Knowing that, I didn't feel it would be worthwhile to add such a case in 
> setpgid02.
> 
> However, I spent more time looking at the code on the kernel side 
> prompted by your remark and I think
> that setpgid03 is going through another path:
> 
>      if (same_thread_group(p->real_parent, group_leader)) {
>          err = -EPERM;
>          if (task_session(p) != task_session(group_leader))
>              goto out;
> 
> So it might indeed make sense to add another case in setpgid02.
> 
> Would initializing a pty be necessary though ? Could it be simply 
> achieved by spawning a child that
> setsid() itself, and try to setpgid the parent to the child PGID ? 
> (Rather than setpgid the child as in setpgid03)

Right, no need for a tty, we can just change the session.

> Maybe it would make sense to add that case to setpgid03 rather than 
> setpgid02, as setpgid03 already has
> the necessary scaffolding ?

That would be the best, we can simply add TST_EXP_FAIL() to the
do_child() in setpgid03. However please make sure to update the test
descriptions in both tests.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list