From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D93A2C433EF for ; Mon, 6 Dec 2021 06:50:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+j1XaxQ2xPB2cDqJn99EB7be1ClYF5aq9+OJGpKEL5g=; b=QatrlSDcyzt9n2 cWGyzYrUXaB2N5ZYQ7Ef5HPNZfdGIO+70OZsgeckfYVRw+ZtW+YZo38brcUYiNVNXAnoHBUeYb8Sr iipwD0KqjVa0SNChI/WvC6TrYp7mx2ano2grU5H5HljbV6JhaNzRIOlr/9ytHtL2N+9h/Gl2gKwgl eZe/fht2BVo8U4hlUYXqI9zCKTCs3CBybG0NkGeIcDfDSHoMt+sSahtf82M90lhZy7fbrH3o9wzRZ EmvUxq6Hy2JQdJQB5PWVLN5vWpufiC3qA5XP/dXCV+MJ5qMMIkj31VKMtsf/pVc68KxafcaiyMVPB pJjpMkvtd7QanWCOuBAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mu7oH-002gj8-5C; Mon, 06 Dec 2021 06:49:13 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mu7oC-002ggW-Ak for linux-arm-kernel@lists.infradead.org; Mon, 06 Dec 2021 06:49:09 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 322E461161; Mon, 6 Dec 2021 06:49:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5955C341C7; Mon, 6 Dec 2021 06:49:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638773346; bh=c3IkfB6+YssMmenDD39hHVKdYX6KS+hEdVqhCCHzous=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XGC+8gy9OUDDSrdfBJPM3F5ynMzn+fA5T4r5MA5O3ULhiwBNLbKDSD9Wv7ow0XaGP H1/FGFXjlfvj7KfC1ygz9RIdKPpZXRGZs0IEaMYAA6vh22idvDJH+mp2YYCdccQOgz sLF6HF6utfsvnWn0B23Bvwm1BR/cs4cxB8JvmWOvvLhVrLsX21BAFoVn5WHgZD5pXx IBbhoBXqKoInnTja7mSOgLI599IIfz+SLg4wKszz5BR1donH0mPE7ojSwJaGzON0kM 90mZAesVPbp4FnB+iKBJ5ww+Ux2QNE6x/3Z5fmu/fRPjM4pCUrD134GqpTWHgNP/D2 je4mpy0LFNlEg== Date: Mon, 6 Dec 2021 08:49:01 +0200 From: Leon Romanovsky To: Leo Yan Cc: "David S. Miller" , Jakub Kicinski , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jan Harkes , coda@cs.cmu.edu, Paul Moore , Eric Paris , Balbir Singh , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, codalist@coda.cs.cmu.edu, linux-audit@redhat.com Subject: Re: [PATCH v1 1/7] pid: Introduce helper task_is_in_root_ns() Message-ID: References: <20211205145105.57824-1-leo.yan@linaro.org> <20211205145105.57824-2-leo.yan@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211205145105.57824-2-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211205_224908_474508_D4B14953 X-CRM114-Status: GOOD ( 19.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, Dec 05, 2021 at 10:50:59PM +0800, Leo Yan wrote: > Currently the kernel uses open code in multiple places to check if a > task is in the root PID namespace with the kind of format: > > if (task_active_pid_ns(current) == &init_pid_ns) > do_something(); > > This patch creates a new helper function, task_is_in_root_ns(), it > returns true if a passed task is in the root PID namespace, otherwise > returns false. So it will be used to replace open codes. > > Suggested-by: Suzuki K Poulose > Signed-off-by: Leo Yan > --- > include/linux/pid_namespace.h | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h > index 7c7e627503d2..bf82b373f022 100644 > --- a/include/linux/pid_namespace.h > +++ b/include/linux/pid_namespace.h > @@ -86,4 +86,9 @@ extern struct pid_namespace *task_active_pid_ns(struct task_struct *tsk); > void pidhash_init(void); > void pid_idr_init(void); > > +static inline bool task_is_in_root_ns(struct task_struct *tsk) It is bad that this name doesn't reflect PID nature of this namespace. Won't it better to name it task_is_in_init_pid_ns()? Thanks > +{ > + return task_active_pid_ns(tsk) == &init_pid_ns; > +} > + > #endif /* _LINUX_PID_NS_H */ > -- > 2.25.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel