[Devel] [PATCH vz10] Revert "ve: Replace 0 ppid with 1 (workaround for bad utils)"
Vasileios Almpanis
vasileios.almpanis at virtuozzo.com
Tue Jul 28 10:44:52 MSK 2026
Reviewed-by: Vasileios Almpanis <vasileios.almpanis at virtuozzo.com>
On 7/27/26 7:35 PM, Konstantin Khorenko wrote:
> This reverts commit b6a803bdf66bf3da211704060a8f263706c2a364.
>
> We won't support so ancient utils which are not ready for getting 0 as a
> parent PID which actually is a normal situation and means that the
> parent process is from an outer pidns and is not visible in the
> current pidns.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-139436
> Feature: procfs: virtualization and visibility configuration
> Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
> ---
> fs/proc/array.c | 5 +++--
> include/linux/pid.h | 1 -
> kernel/pid.c | 12 ------------
> kernel/sys.c | 2 +-
> 4 files changed, 4 insertions(+), 16 deletions(-)
>
> diff --git a/fs/proc/array.c b/fs/proc/array.c
> index 80b882fe4832..0ff32bee5c50 100644
> --- a/fs/proc/array.c
> +++ b/fs/proc/array.c
> @@ -171,7 +171,8 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
> unsigned int max_fds = 0;
>
> rcu_read_lock();
> - ppid = pid_alive(p) ? ve_task_ppid_nr_ns(p, ns) : 0;
> + ppid = pid_alive(p) ?
> + task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
>
> tracer = ptrace_parent(p);
> if (tracer)
> @@ -551,7 +552,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
> }
>
> sid = task_session_nr_ns(task, ns);
> - ppid = ve_task_ppid_nr_ns(task, ns);
> + ppid = task_ppid_nr_ns(task, ns);
> pgid = task_pgrp_nr_ns(task, ns);
>
> unlock_task_sighand(task, &flags);
> diff --git a/include/linux/pid.h b/include/linux/pid.h
> index 04f983d477ff..34ef8e692fee 100644
> --- a/include/linux/pid.h
> +++ b/include/linux/pid.h
> @@ -184,7 +184,6 @@ static inline pid_t pid_nr(struct pid *pid)
>
> pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
> pid_t pid_vnr(struct pid *pid);
> -pid_t ve_task_ppid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns);
>
> #define do_each_pid_task(pid, type, task) \
> do { \
> diff --git a/kernel/pid.c b/kernel/pid.c
> index c95e572efd7d..350ca2fbff5c 100644
> --- a/kernel/pid.c
> +++ b/kernel/pid.c
> @@ -517,18 +517,6 @@ pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
> }
> EXPORT_SYMBOL(__task_pid_nr_ns);
>
> -pid_t ve_task_ppid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns)
> -{
> - pid_t ppid;
> - rcu_read_lock();
> - ppid = task_tgid_nr_ns(rcu_dereference(tsk->real_parent), ns);
> - rcu_read_unlock();
> - /* It's dirty hack. Some old utils don't work if ppid is zero*/
> - if (ppid == 0 && ns->child_reaper != tsk)
> - ppid = 1;
> - return ppid;
> -}
> -
> struct pid_namespace *task_active_pid_ns(struct task_struct *tsk)
> {
> return ns_of_pid(task_pid(tsk));
> diff --git a/kernel/sys.c b/kernel/sys.c
> index 33b05af556fa..80f8b9eb17c3 100644
> --- a/kernel/sys.c
> +++ b/kernel/sys.c
> @@ -990,7 +990,7 @@ SYSCALL_DEFINE0(getppid)
> int pid;
>
> rcu_read_lock();
> - pid = ve_task_ppid_nr_ns(current, task_active_pid_ns(current));
> + pid = task_tgid_vnr(rcu_dereference(current->real_parent));
> rcu_read_unlock();
>
> return pid;
--
Best regards, Vasileios Almpanis
Software Developer, Virtuozzo.
More information about the Devel
mailing list