Skip to content

Commit c7ec845

Browse files
committed
Merge branch 'pid-introduce-helper-task_is_in_root_ns'
Leo Yan says: ==================== pid: Introduce helper task_is_in_root_ns() This patch series introduces a helper function task_is_in_init_pid_ns() to replace open code. The two patches are extracted from the original series [1] for network subsystem. As a plan, we can firstly land this patch set into kernel 5.18; there have 5 patches are left out from original series [1], as a next step, I will resend them for appropriate linux-next merging. [1] https://lore.kernel.org/lkml/[email protected]/ ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents a92f7a6 + 42c66d1 commit c7ec845

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

drivers/connector/cn_proc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ static void cn_proc_mcast_ctl(struct cn_msg *msg,
358358
* other namespaces.
359359
*/
360360
if ((current_user_ns() != &init_user_ns) ||
361-
(task_active_pid_ns(current) != &init_pid_ns))
361+
!task_is_in_init_pid_ns(current))
362362
return;
363363

364364
/* Can only change if privileged. */

include/linux/pid_namespace.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,9 @@ extern struct pid_namespace *task_active_pid_ns(struct task_struct *tsk);
8686
void pidhash_init(void);
8787
void pid_idr_init(void);
8888

89+
static inline bool task_is_in_init_pid_ns(struct task_struct *tsk)
90+
{
91+
return task_active_pid_ns(tsk) == &init_pid_ns;
92+
}
93+
8994
#endif /* _LINUX_PID_NS_H */

0 commit comments

Comments
 (0)