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