Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b488893a authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Linus Torvalds
Browse files

pid namespaces: changes to show virtual ids to user



This is the largest patch in the set. Make all (I hope) the places where
the pid is shown to or get from user operate on the virtual pids.

The idea is:
 - all in-kernel data structures must store either struct pid itself
   or the pid's global nr, obtained with pid_nr() call;
 - when seeking the task from kernel code with the stored id one
   should use find_task_by_pid() call that works with global pids;
 - when showing pid's numerical value to the user the virtual one
   should be used, but however when one shows task's pid outside this
   task's namespace the global one is to be used;
 - when getting the pid from userspace one need to consider this as
   the virtual one and use appropriate task/pid-searching functions.

[akpm@linux-foundation.org: build fix]
[akpm@linux-foundation.org: nuther build fix]
[akpm@linux-foundation.org: yet nuther build fix]
[akpm@linux-foundation.org: remove unneeded casts]
Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarAlexey Dobriyan <adobriyan@openvz.org>
Cc: Sukadev Bhattiprolu <sukadev@us.ibm.com>
Cc: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Paul Menage <menage@google.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 3eb07c8c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -227,7 +227,7 @@ ia64_rt_sigreturn (struct sigscratch *scr)
	si.si_signo = SIGSEGV;
	si.si_errno = 0;
	si.si_code = SI_KERNEL;
	si.si_pid = current->pid;
	si.si_pid = task_pid_vnr(current);
	si.si_uid = current->uid;
	si.si_addr = sc;
	force_sig_info(SIGSEGV, &si, current);
@@ -332,7 +332,7 @@ force_sigsegv_info (int sig, void __user *addr)
	si.si_signo = SIGSEGV;
	si.si_errno = 0;
	si.si_code = SI_KERNEL;
	si.si_pid = current->pid;
	si.si_pid = task_pid_vnr(current);
	si.si_uid = current->uid;
	si.si_addr = addr;
	force_sig_info(SIGSEGV, &si, current);
+1 −1
Original line number Diff line number Diff line
@@ -181,7 +181,7 @@ sys_rt_sigreturn(struct pt_regs *regs, int in_syscall)
	si.si_signo = SIGSEGV;
	si.si_errno = 0;
	si.si_code = SI_KERNEL;
	si.si_pid = current->pid;
	si.si_pid = task_pid_vnr(current);
	si.si_uid = current->uid;
	si.si_addr = &frame->uc;
	force_sig_info(SIGSEGV, &si, current);
+1 −1
Original line number Diff line number Diff line
@@ -866,7 +866,7 @@ asmlinkage int sunos_killpg(int pgrp, int sig)
	rcu_read_lock();
	ret = -EINVAL;
	if (pgrp > 0)
		ret = kill_pgrp(find_pid(pgrp), sig, 0);
		ret = kill_pgrp(find_vpid(pgrp), sig, 0);
	rcu_read_unlock();

	return ret;
+1 −1
Original line number Diff line number Diff line
@@ -831,7 +831,7 @@ asmlinkage int sunos_killpg(int pgrp, int sig)
	rcu_read_lock();
	ret = -EINVAL;
	if (pgrp > 0)
		ret = kill_pgrp(find_pid(pgrp), sig, 0);
		ret = kill_pgrp(find_vpid(pgrp), sig, 0);
	rcu_read_unlock();

	return ret;
+4 −3
Original line number Diff line number Diff line
@@ -103,6 +103,7 @@
#include <linux/selection.h>

#include <linux/kmod.h>
#include <linux/nsproxy.h>

#undef TTY_DEBUG_HANGUP

@@ -3107,7 +3108,7 @@ static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t
	 */
	if (tty == real_tty && current->signal->tty != real_tty)
		return -ENOTTY;
	return put_user(pid_nr(real_tty->pgrp), p);
	return put_user(pid_vnr(real_tty->pgrp), p);
}

/**
@@ -3141,7 +3142,7 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t
	if (pgrp_nr < 0)
		return -EINVAL;
	rcu_read_lock();
	pgrp = find_pid(pgrp_nr);
	pgrp = find_vpid(pgrp_nr);
	retval = -ESRCH;
	if (!pgrp)
		goto out_unlock;
@@ -3178,7 +3179,7 @@ static int tiocgsid(struct tty_struct *tty, struct tty_struct *real_tty, pid_t _
		return -ENOTTY;
	if (!real_tty->session)
		return -ENOTTY;
	return put_user(pid_nr(real_tty->session), p);
	return put_user(pid_vnr(real_tty->session), p);
}

/**
Loading