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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 D67FDC4332F for ; Mon, 6 Dec 2021 22:15:21 +0000 (UTC) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-401-DADd0lJuPA-GjKGwBYrKGQ-1; Mon, 06 Dec 2021 17:15:17 -0500 X-MC-Unique: DADd0lJuPA-GjKGwBYrKGQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB155101F00B; Mon, 6 Dec 2021 22:15:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 56C1419741; Mon, 6 Dec 2021 22:15:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0D64D1809CB9; Mon, 6 Dec 2021 22:15:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1B66uU2P005081 for ; Mon, 6 Dec 2021 01:56:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id DD1FC4010FFE; Mon, 6 Dec 2021 06:56:30 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D77A6400DB22 for ; Mon, 6 Dec 2021 06:56:30 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9D161380670D for ; Mon, 6 Dec 2021 06:56:30 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-192-rrTBjXSQP-abWm2Srxxhtg-1; Mon, 06 Dec 2021 01:56:29 -0500 X-MC-Unique: rrTBjXSQP-abWm2Srxxhtg-1 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) Date: Mon, 6 Dec 2021 08:49:01 +0200 From: Leon Romanovsky To: Leo Yan 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 In-Reply-To: <20211205145105.57824-2-leo.yan@linaro.org> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-loop: linux-audit@redhat.com X-Mailman-Approved-At: Mon, 06 Dec 2021 17:15:10 -0500 Cc: codalist@telemann.coda.cs.cmu.edu, Jan Harkes , Mathieu Poirier , Suzuki K Poulose , Alexander Shishkin , netdev@vger.kernel.org, Balbir Singh , linux-kernel@vger.kernel.org, Eric Paris , coda@cs.cmu.edu, linux-audit@redhat.com, coresight@lists.linaro.org, Jakub Kicinski , "David S. Miller" , linux-arm-kernel@lists.infradead.org, Mike Leach X-BeenThere: linux-audit@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Linux Audit Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=linux-audit-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit 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 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 140EAC433EF for ; Mon, 6 Dec 2021 06:49:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238144AbhLFGwm (ORCPT ); Mon, 6 Dec 2021 01:52:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233151AbhLFGwh (ORCPT ); Mon, 6 Dec 2021 01:52:37 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E91BC0613F8; Sun, 5 Dec 2021 22:49:09 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id D279FB80EE6; 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211205145105.57824-2-leo.yan@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 >