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 EDA6AC433EF for ; Tue, 14 Dec 2021 05:55:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230149AbhLNFzn (ORCPT ); Tue, 14 Dec 2021 00:55:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230115AbhLNFzm (ORCPT ); Tue, 14 Dec 2021 00:55:42 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B70ADC061574; Mon, 13 Dec 2021 21:55:42 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id iq11so13538226pjb.3; Mon, 13 Dec 2021 21:55:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=mOz2n15l7yDI+2sTaql2TW0ZegS4iVHrtlIatnwxZak=; b=JKbBjpTcOheo4O1Tm2aQLZIg7Km7Aw8/gAEC7Uh6B4zFk1IywU2qs0VI53wNYvyB+J MqvUC3pGSLrTyTEJqg134zkq8ffV7kTdHo0f1dSAF891KwZc/gIWLKiRdx7mk25KZMpR d3x9us09mUW8t4F507N2z72zbR7EUlIxSrvc61xfg5Iq7JZQX2BM2b/B1wQsbjYj44AA 7W/xCqQhLFPsEPZz8/1aDsCOgtWWKBZr7dQxQoxNu/v3gXCFsAn42hW9CahMFYi6/5v5 ToamyTTcqlUM/M14avRWVrqy/zAQ0OPvy7N/Y7hjdBfz/PfUiXiGvYwJVXryPCNnNVWP 4yYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mOz2n15l7yDI+2sTaql2TW0ZegS4iVHrtlIatnwxZak=; b=H4DumrJGCD3m4HZhMmcEHy69xzXx46ldDgVGc/FQMqgbK6u8BHwp35yNkeCrKQ8uM+ Fn22oNWEfaZciVX5fkiUY/kxFMueMnoJGyDEsiENU1ZEX+yIiD2tQ3+u5JzHTx5BDnEf wsdecGWCwdP1WBe4pmlcWsulLUbzxKDxCSP9v6IVrz1Pvwv1uFeWuY+YOwZSwke1DEK0 po0Cj8ZtUY961EeKT3yiVC2K1rXR4Jpn9kaurndTyIRBjob8SSFQ5/41/Jr73FAVn0S8 2k99i6uJ/wt12BSy2HUnc0w3UiOOaPltZ9HOqUIVORc5YxN5oQce7BNtKCX5/DV5WuVN pwaQ== X-Gm-Message-State: AOAM530BVjvMcog2MAR8EEM6q8VrLZTKzl5kT9rhZgu8JRUdiSGD6/0V tkKWZM4P2nr1yN97yfZuirE= X-Google-Smtp-Source: ABdhPJwR7OAh6kARLVf4WgF3DrQmjQDIPb+uBpwn/LUpUvw8DOFFteE1EgPHeyPCAT7ULeMuvkYdWQ== X-Received: by 2002:a17:90a:ec15:: with SMTP id l21mr3315172pjy.48.1639461342170; Mon, 13 Dec 2021 21:55:42 -0800 (PST) Received: from localhost ([110.141.142.237]) by smtp.gmail.com with ESMTPSA id y12sm13983437pfe.140.2021.12.13.21.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 21:55:41 -0800 (PST) Date: Tue, 14 Dec 2021 16:55:38 +1100 From: Balbir Singh To: Leo Yan Cc: "David S. Miller" , Jakub Kicinski , Leon Romanovsky , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jan Harkes , coda@cs.cmu.edu, Paul Moore , Eric Paris , 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 v2 1/7] pid: Introduce helper task_is_in_init_pid_ns() Message-ID: References: <20211208083320.472503-1-leo.yan@linaro.org> <20211208083320.472503-2-leo.yan@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211208083320.472503-2-leo.yan@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 08, 2021 at 04:33:14PM +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_init_pid_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..07481bb87d4e 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_init_pid_ns(struct task_struct *tsk) > +{ > + return task_active_pid_ns(tsk) == &init_pid_ns; > +} > + > #endif /* _LINUX_PID_NS_H */ > -- > 2.25.1 > Acked-by: Balbir Singh 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 D9B8BC433FE for ; Tue, 14 Dec 2021 05:57:05 +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=IEB3k/DBfoDECCKTr2vbq2fgfA3GnrZw+fGqbs5q+dY=; b=mob9+bdqAusNCr 8O/xuqQfjlfTs8DMNLB7/+VW3K7jVuoARX3IfQtqlX/SCUWlc6j0mazOO/aPG2fPvx8bo7Fa8yXZ9 NlgmCPjuQclIvglU92Dl7hLeXMv80oFKKGxp3DItWPzKse31fSmGP4uKAxHCzFlm6bYJhEHi0MvO/ K13xbhdXVsFhhQsr4SgmtvlT7fqTIShh4jTotl9v69QDpk+0HN9glWuRSlXIFbljR27C2gKWHJJFP Kijgb8W+NYQDHUKbGj+OEAeWIQxznoJGWdAjuFTE/BHC1mAwGIOWist/c1h3czYmqzpYY/7Lpc5T7 y79kQNaVQy6vDivylnEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mx0n0-00Cg26-Nx; Tue, 14 Dec 2021 05:55:50 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mx0mv-00CfzM-Ou for linux-arm-kernel@lists.infradead.org; Tue, 14 Dec 2021 05:55:47 +0000 Received: by mail-pl1-x62a.google.com with SMTP id y8so12832400plg.1 for ; Mon, 13 Dec 2021 21:55:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=mOz2n15l7yDI+2sTaql2TW0ZegS4iVHrtlIatnwxZak=; b=JKbBjpTcOheo4O1Tm2aQLZIg7Km7Aw8/gAEC7Uh6B4zFk1IywU2qs0VI53wNYvyB+J MqvUC3pGSLrTyTEJqg134zkq8ffV7kTdHo0f1dSAF891KwZc/gIWLKiRdx7mk25KZMpR d3x9us09mUW8t4F507N2z72zbR7EUlIxSrvc61xfg5Iq7JZQX2BM2b/B1wQsbjYj44AA 7W/xCqQhLFPsEPZz8/1aDsCOgtWWKBZr7dQxQoxNu/v3gXCFsAn42hW9CahMFYi6/5v5 ToamyTTcqlUM/M14avRWVrqy/zAQ0OPvy7N/Y7hjdBfz/PfUiXiGvYwJVXryPCNnNVWP 4yYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mOz2n15l7yDI+2sTaql2TW0ZegS4iVHrtlIatnwxZak=; b=6mcPVCKQ+cBy1u2CU/dA78/RfxUuIoxcrTp3cuyj115ge42u6w+ljm8XtDTaBxmykt 4DU9VUB+k3ooOLvMZOMxruEOaMPseUUyx9OVyGPIGY4gFGOTSE6oJvbV3XfkIvqgLh/b 82BiL+pzyO0KjymPWJVdPD3h4LalDdi4iW2v3cDeNLh4wffUxHxdpLl3Qau0f6KUErk0 oMqPr6zmcJgoVMYcG2nEiruZMUyucJw+nHo/aezLlCQXdD7dQ26DPY501saDedM68WZI C6n0nTG4ynFqEzJEPnlPwqjZtK7q882UIqcQKErbBs0reTlLL+OHfStHkfrgDOojQdf2 GXlA== X-Gm-Message-State: AOAM533cP6WjJwucqyE+mnRZrVNpy68Yp/kWUG5k1XMkVsBmncaBchUP OYor5qQF+yjjB0cc2RGyZR0= X-Google-Smtp-Source: ABdhPJwR7OAh6kARLVf4WgF3DrQmjQDIPb+uBpwn/LUpUvw8DOFFteE1EgPHeyPCAT7ULeMuvkYdWQ== X-Received: by 2002:a17:90a:ec15:: with SMTP id l21mr3315172pjy.48.1639461342170; Mon, 13 Dec 2021 21:55:42 -0800 (PST) Received: from localhost ([110.141.142.237]) by smtp.gmail.com with ESMTPSA id y12sm13983437pfe.140.2021.12.13.21.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 21:55:41 -0800 (PST) Date: Tue, 14 Dec 2021 16:55:38 +1100 From: Balbir Singh To: Leo Yan Cc: "David S. Miller" , Jakub Kicinski , Leon Romanovsky , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Alexander Shishkin , Jan Harkes , coda@cs.cmu.edu, Paul Moore , Eric Paris , 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 v2 1/7] pid: Introduce helper task_is_in_init_pid_ns() Message-ID: References: <20211208083320.472503-1-leo.yan@linaro.org> <20211208083320.472503-2-leo.yan@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211208083320.472503-2-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211213_215545_841323_05D8AC17 X-CRM114-Status: GOOD ( 19.47 ) 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 Wed, Dec 08, 2021 at 04:33:14PM +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_init_pid_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..07481bb87d4e 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_init_pid_ns(struct task_struct *tsk) > +{ > + return task_active_pid_ns(tsk) == &init_pid_ns; > +} > + > #endif /* _LINUX_PID_NS_H */ > -- > 2.25.1 > Acked-by: Balbir Singh _______________________________________________ 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 83564C433EF for ; Tue, 14 Dec 2021 18:23:44 +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-662-q3UX70lhM1ObPaw9hwwi6w-1; Tue, 14 Dec 2021 13:23:40 -0500 X-MC-Unique: q3UX70lhM1ObPaw9hwwi6w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 41801612A1; Tue, 14 Dec 2021 18:23:37 +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 D623277EAE; Tue, 14 Dec 2021 18:23:36 +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 73D3F1809CB9; Tue, 14 Dec 2021 18:23:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BE5tm06029172 for ; Tue, 14 Dec 2021 00:55:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1CD941121319; Tue, 14 Dec 2021 05:55:48 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 176861121315 for ; Tue, 14 Dec 2021 05:55:45 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 30EC1185A79C for ; Tue, 14 Dec 2021 05:55:45 +0000 (UTC) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-1-BRMS0o6KMUi8y2TyIY-BwQ-1; Tue, 14 Dec 2021 00:55:43 -0500 X-MC-Unique: BRMS0o6KMUi8y2TyIY-BwQ-1 Received: by mail-pj1-f50.google.com with SMTP id v16so337653pjn.1; Mon, 13 Dec 2021 21:55:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mOz2n15l7yDI+2sTaql2TW0ZegS4iVHrtlIatnwxZak=; b=D0ufzJgq3Yhl6r4Wj4gUVhMI7pge7CpFcAQBBrVS9j4QxNcOVObYzYPNyTKlPJONq0 iN3clSI7O53NJgd5JXx6iz9QJYL3JTd7ZRz7NoKNilflHFor6TX7Gg7lBJThjXorGOxQ m/V2LjOVzGgYsOQILVi2vAK+Oi+R1qPtzqY7A0+HL+cW0+PuFTJ/DCPRI8ZSzx/tyM+E kWDEOXe9U4GzvL7UohEoPyEh1Y0tLe1LX6YnDOXo9EOIXVBWbQ71RgN5rFzIFZFljkEH hMOTrNahntR5TOSm3upNV3xngUZcUM6MUr8pwgZojBjRfWah6oktKwF9TUsjOHi9rli+ Dm2Q== X-Gm-Message-State: AOAM5305Ht3FS12he4YOcUltPdUbzJzMWm+TD8HC8B7uVWBC4wdp6OMu y6Xmhac2QjTAf8RHxTHjIKI= X-Google-Smtp-Source: ABdhPJwR7OAh6kARLVf4WgF3DrQmjQDIPb+uBpwn/LUpUvw8DOFFteE1EgPHeyPCAT7ULeMuvkYdWQ== X-Received: by 2002:a17:90a:ec15:: with SMTP id l21mr3315172pjy.48.1639461342170; Mon, 13 Dec 2021 21:55:42 -0800 (PST) Received: from localhost ([110.141.142.237]) by smtp.gmail.com with ESMTPSA id y12sm13983437pfe.140.2021.12.13.21.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 21:55:41 -0800 (PST) Date: Tue, 14 Dec 2021 16:55:38 +1100 From: Balbir Singh To: Leo Yan Subject: Re: [PATCH v2 1/7] pid: Introduce helper task_is_in_init_pid_ns() Message-ID: References: <20211208083320.472503-1-leo.yan@linaro.org> <20211208083320.472503-2-leo.yan@linaro.org> MIME-Version: 1.0 In-Reply-To: <20211208083320.472503-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.78 on 10.11.54.3 X-loop: linux-audit@redhat.com X-Mailman-Approved-At: Tue, 14 Dec 2021 13:23:33 -0500 Cc: codalist@telemann.coda.cs.cmu.edu, Jan Harkes , Leon Romanovsky , Mathieu Poirier , Suzuki K Poulose , Alexander Shishkin , netdev@vger.kernel.org, coresight@lists.linaro.org, linux-kernel@vger.kernel.org, Eric Paris , coda@cs.cmu.edu, linux-audit@redhat.com, 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.79 on 10.5.11.15 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 Wed, Dec 08, 2021 at 04:33:14PM +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_init_pid_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..07481bb87d4e 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_init_pid_ns(struct task_struct *tsk) > +{ > + return task_active_pid_ns(tsk) == &init_pid_ns; > +} > + > #endif /* _LINUX_PID_NS_H */ > -- > 2.25.1 > Acked-by: Balbir Singh -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit