Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751748Ab3HTVdf (ORCPT ); Tue, 20 Aug 2013 17:33:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50733 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751690Ab3HTVdd (ORCPT ); Tue, 20 Aug 2013 17:33:33 -0400 From: Richard Guy Briggs To: linux-audit@redhat.com, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org Cc: Richard Guy Briggs , Eric Paris , Al Viro , Ingo Molnar , Peter Zijlstra , "Serge E. Hallyn" , John Johansen , James Morris , Andrew Morton , Oleg Nesterov , Kentaro Takeda , Tetsuo Handa , Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH 05/12] pid: get pid_t of task in init_pid_ns correctly Date: Tue, 20 Aug 2013 17:31:57 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2361 Lines: 71 Added the functions task_pid_nr_init_ns() task_tgid_nr_init_ns() to avoid the use of the error-prone duplicity of task->pid and task->tgid, avoid changing the existing usage of task_pid_nr() and task_tgid_nr() while it gets converted away from task->pid and task->tgid, and provide a clear abstraction of the frequently used init_pid_ns in task_pid_nr_ns() and task_tgid_nr_ns(). Also added pid_nr_init_ns() to explicitly use init_pid_ns. (informed by ebiederman's 3a2e8c59) Cc: Eric W. Biederman Signed-off-by: Richard Guy Briggs --- include/linux/pid.h | 6 ++++++ include/linux/sched.h | 10 ++++++++++ 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/include/linux/pid.h b/include/linux/pid.h index 23705a5..051e134 100644 --- a/include/linux/pid.h +++ b/include/linux/pid.h @@ -172,6 +172,12 @@ 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); +static inline pid_t pid_nr_init_ns(struct pid *pid) +{ + return pid_nr_ns(pid, &init_pid_ns); +} + + #define do_each_pid_task(pid, type, task) \ do { \ if ((pid) != NULL) \ diff --git a/include/linux/sched.h b/include/linux/sched.h index ec04090..9651d95 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1482,6 +1482,11 @@ static inline pid_t task_pid_nr_ns(struct task_struct *tsk, return __task_pid_nr_ns(tsk, PIDTYPE_PID, ns); } +static inline pid_t task_pid_nr_init_ns(struct task_struct *tsk) +{ + return task_pid_nr_ns(tsk, &init_pid_ns); +} + static inline pid_t task_pid_vnr(struct task_struct *tsk) { return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL); @@ -1495,6 +1500,11 @@ static inline pid_t task_tgid_nr(struct task_struct *tsk) pid_t task_tgid_nr_ns(struct task_struct *tsk, struct pid_namespace *ns); +static inline pid_t task_tgid_nr_init_ns(struct task_struct *tsk) +{ + return task_tgid_nr_ns(tsk, &init_pid_ns); +} + static inline pid_t task_tgid_vnr(struct task_struct *tsk) { return pid_vnr(task_tgid(tsk)); -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/