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