From patchwork Sun Dec 5 14:50:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12694807 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 40BD7C433F5 for ; Sun, 5 Dec 2021 14:53:08 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=62cG3/Odwne9Z01ItW13uD383kNuhlvD7Zt4Mpwt0Zk=; b=nT+plJI9pVHzfN DTQTtH96ORMnlykDXh2dgunOf5kEvmpLR0Yvx9SH0ANzbQbWM6e3QWnfluShqdhvr+5kUIogHB1ji PkXZlOL/qxAuMC8lqCewyv2ok++3TG4fYZb4fKTKbQESgb5/ee1fIjcqspijgEOBWH2FAQJzOxUIz 7nF66l1T7ILyh/6vAsqFKhFJDb08Ygx+THhbQughHmWv8R8m96mD7ENFF0PopkYQn+kNYQ65XVTWs aPKutoEQ7Q09WNA/+ZdPbUI8gCWYyRdWg+awPtZYV1F17mRireBHeQYSpljqPxMcOXsQUD7Gul/tQ cAqyU2++VjLd3Hb2yr5g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtsrS-001Y8s-Pl; Sun, 05 Dec 2021 14:51:31 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtsrH-001Y60-Tz for linux-arm-kernel@lists.infradead.org; Sun, 05 Dec 2021 14:51:21 +0000 Received: by mail-pj1-x102c.google.com with SMTP id gx15-20020a17090b124f00b001a695f3734aso6370393pjb.0 for ; Sun, 05 Dec 2021 06:51:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YNiShhLycQhgX5gYnC4y4VBBuFZNS7ZHSY9AFesdrV8=; b=CMUN9P+RYDkzOLIKctNBP/6VANWwm6cOuLLsJD3LtQMfK65VWY+CtG+idsfLifL1lM Kai4/V2FAJa43SAL6u0ZK9haIclc89AinTlGqu1q6mOC4pS+rnK7mQhFl4kzcOHrSqGd M3ZPCvnCUbFiOiY5Ns7QSi3DDuskgjDRdTibTIoHKyNlvHl58PMZ8MZiD6t00CAxJo1Q UmuVgW/UDFjyLdXt1a/98lf7eCoHBTQPErjGfMXah86NtZVSSj/XGg0eBOtGJFR8E+Mb KDBBBe05Qop9MmT/s/O1jKd5VCY2Ii1kvVsxVxY4c1WMLnbyLHHA/0SrUheLWKYORnBv axTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YNiShhLycQhgX5gYnC4y4VBBuFZNS7ZHSY9AFesdrV8=; b=Ov35aGKh2ar43q2JM2VtK/iPnYTVjF06miemnL9tIP5m6g9txJEHSVE/02qtsfVx5E 7fTI587QZAWpZ2yH1YylaTufXBs24b0GbhY8ZX6dHamC9xTyRLrRfNb8r4aNZTQ7r1+3 JvhjoMeNO6qzF2KPDWP2OOLTg+dNXlA6dm1vfDkrJDP8KVMiGri58souYEtbeQ8kQFIv mkmufwhqG1r0c3DFLxSH9NgIldER3w0/fJKNt2WQP28cNQ4+X1Pr5wkhN3KTsDiZEZ0K PQR24MWn57Ik/sx7FBvdUJJ/7ZodIW44+saGcKLd7t5AjzWNKxi2XJafCwdalf3SdCg2 rLIg== X-Gm-Message-State: AOAM532v+ytf+8JbNYDECs7yG5WqocBEYIs/MjOvbhgfogrnCGKwjER1 nouwqmz3+GdJZQRgkOEn78E9ug== X-Google-Smtp-Source: ABdhPJzc9deUn8Xmj0L2AU7C6UVvRT82dukgejEcgPuHYSOcdCGBPFUz1V0TrkJ2f6OtnuKQPz44Jw== X-Received: by 2002:a17:90a:fe0b:: with SMTP id ck11mr29446156pjb.15.1638715878962; Sun, 05 Dec 2021 06:51:18 -0800 (PST) Received: from localhost ([2602:feda:dd1:19c7:f5dc:98c2:a1a4:6c61]) by smtp.gmail.com with ESMTPSA id o2sm9507666pfu.206.2021.12.05.06.51.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Dec 2021 06:51:18 -0800 (PST) From: Leo Yan To: "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 Cc: Leo Yan Subject: [PATCH v1 1/7] pid: Introduce helper task_is_in_root_ns() Date: Sun, 5 Dec 2021 22:50:59 +0800 Message-Id: <20211205145105.57824-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211205145105.57824-1-leo.yan@linaro.org> References: <20211205145105.57824-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211205_065119_997528_890D3FE9 X-CRM114-Status: GOOD ( 11.35 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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) +{ + return task_active_pid_ns(tsk) == &init_pid_ns; +} + #endif /* _LINUX_PID_NS_H */ From patchwork Sun Dec 5 14:51:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12694809 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 0B6B6C4332F for ; Sun, 5 Dec 2021 14:53:09 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ppYdh3csmKQV0ucZ6uZNRSAlYe5mPalbkriZBI9OQXk=; b=pvSR/tZr3au11J NhEl18qZ5xKiY3A2KkUNPymkv0jj4gz1GirHxPMB/+R/kwpHpXpNyQR1Z8IR+xNKOqHKKDpp0C1dA PlSSgXdRMNkVex6V/J+zlLXs/mXCmP0BwKMhpz6W8OuQh8yxkNb/FBu4aVoeA0HfswLTnPzZ2rbiq w1dUE3AKDooRJxr8J3alZFKd43onA9FdbopTAEL94ij4vHHEKsGChffkb0dD/45MZ+i5KKagtT4nj 3AsYP/JusbQ/tfEFkIbiANQs8BlklsmHGPBXIC5aZ/3xXbHPQYW5LjW/8UCKDqrQQobQw1E25pPkM TFSuXM0dZphmQT0wjiCw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtsrd-001YBD-0Q; Sun, 05 Dec 2021 14:51:41 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtsrL-001Y6k-8l for linux-arm-kernel@lists.infradead.org; Sun, 05 Dec 2021 14:51:24 +0000 Received: by mail-pj1-x1030.google.com with SMTP id fv9-20020a17090b0e8900b001a6a5ab1392so6335758pjb.1 for ; Sun, 05 Dec 2021 06:51:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TIZ1ekHamWsBpzx/c4rlzvRLrR0WcD4jTfep7Z0JpMg=; b=QDKpb2AU6Lu0PXY1xs9kgtm19LM/i5PF/nec/ihFtCbDaXPEgScrYCRZXt4d6HdrD6 Cuwr62idNZcMkMKQFCPzSVHRKJx8PlTpFuxU10OMtShYcCiovPtC16YkFKOd2zoaI7Ea rqiLZC1n08U4FoqhCzpsJ008nQOXyxuhgg2PKDm/ZJvRika6I+Q+TU/43dgLcLoEgmeV 861hb6jst0VVelVV4xipGCJ5uEb/tXF2OhLyPCqzEsWQwY86Q0BigMsr7fuIZT+xstw6 //ec5ZoaBVQNMHPu+/1mk6bK6x7JkErjVB0DxzPImdZ9taBfMUDnIAD20wFASG9UeJ1r oZDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TIZ1ekHamWsBpzx/c4rlzvRLrR0WcD4jTfep7Z0JpMg=; b=fJsXLfIJSjPki9jIZeXWFHeHNQnU6+wggP/BOiQs4g3umL/TgBA8LGGbrahv895Ia/ z3kYafyhpoeBJsWCcUVp+1jwD5v78SAbF9XFuNMkqpNEAEPwL6I091yNBop3Msw4sIP9 6zYJEtOqhaLxx7udjYxZZfQ6dnC7uzyvURweqSTwvtHdvWzuMcb+UtCmACWu+lyezaaH XcLtkS/3GNMURrpvBsti5mZB2KJiGuTa0rXhmZtXhFNtgKD5WD8mekiT8joaxHcIHfcj +Jwb/q7DPnagXDEDLHshE9m/g2IwsbDwee2zhicnB2NGnRH0Jni4YzEwdZ5X4uiCNhNV i6ZQ== X-Gm-Message-State: AOAM530cjy9DuRdA3vrFG60DbTgQp3f/w2JLCAHFaFNR8u24uEgBMF/S 4JAG8/fbukN32t4YzJfv3DfOuA== X-Google-Smtp-Source: ABdhPJwbtYvyednOqDHit4yIYRavSWV2oodDpZmOZnha4ZDGgas38FxP9ERRJu8LnK4qX8faP9/2ag== X-Received: by 2002:a17:902:b20b:b0:141:a92c:a958 with SMTP id t11-20020a170902b20b00b00141a92ca958mr37475204plr.24.1638715882411; Sun, 05 Dec 2021 06:51:22 -0800 (PST) Received: from localhost ([2602:feda:ddb:5fe8:b1a8:1b20:fbe9:2696]) by smtp.gmail.com with ESMTPSA id y28sm9218195pfa.208.2021.12.05.06.51.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Dec 2021 06:51:22 -0800 (PST) From: Leo Yan To: "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 Cc: Leo Yan Subject: [PATCH v1 2/7] coresight: etm3x: Use task_is_in_root_ns() to check PID namespace Date: Sun, 5 Dec 2021 22:51:00 +0800 Message-Id: <20211205145105.57824-3-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211205145105.57824-1-leo.yan@linaro.org> References: <20211205145105.57824-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211205_065123_386191_2FC7BE82 X-CRM114-Status: GOOD ( 11.97 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch uses helper task_is_in_root_ns() to replace open code for checking if a task is in root PID namespace. Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-etm3x-sysfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c index e8c7649f123e..baba16ad9bb1 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c @@ -1030,7 +1030,7 @@ static ssize_t ctxid_pid_show(struct device *dev, * Don't use contextID tracing if coming from a PID namespace. See * comment in ctxid_pid_store(). */ - if (task_active_pid_ns(current) != &init_pid_ns) + if (!task_is_in_root_ns(current)) return -EINVAL; spin_lock(&drvdata->spinlock); @@ -1058,7 +1058,7 @@ static ssize_t ctxid_pid_store(struct device *dev, * As such refuse to use the feature if @current is not in the initial * PID namespace. */ - if (task_active_pid_ns(current) != &init_pid_ns) + if (!task_is_in_root_ns(current)) return -EINVAL; ret = kstrtoul(buf, 16, &pid); @@ -1084,7 +1084,7 @@ static ssize_t ctxid_mask_show(struct device *dev, * Don't use contextID tracing if coming from a PID namespace. See * comment in ctxid_pid_store(). */ - if (task_active_pid_ns(current) != &init_pid_ns) + if (!task_is_in_root_ns(current)) return -EINVAL; val = config->ctxid_mask; @@ -1104,7 +1104,7 @@ static ssize_t ctxid_mask_store(struct device *dev, * Don't use contextID tracing if coming from a PID namespace. See * comment in ctxid_pid_store(). */ - if (task_active_pid_ns(current) != &init_pid_ns) + if (!task_is_in_root_ns(current)) return -EINVAL; ret = kstrtoul(buf, 16, &val); From patchwork Sun Dec 5 14:51:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12694810 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 5E358C43217 for ; Sun, 5 Dec 2021 14:53:09 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JwDz8fXRAR94BRX5B2804jdBeGmPoaW6fiJ9pYQuwQg=; b=d362jxUeamBQ7I EMa7iTcAP7P4shoGr3eFui37wPe/gTf3FBahJ0xPuwgUusAOMRg6jjlB8t4YcetLfEfaOSGHMlRoB 9TaeaJbiqb8xHV3cbfK2UlSObgOOeggT2wzYXu6ntsvHG0Syg5Sw2o9yNKubV0J7kP0g9WrnnNeW6 AKt4RmXYwBQ7l9+7OMQCDXoQIv+hSnd3UshyhUpfKWEZa9x7TcW03WJfuZAA5TX+9QA46t806z0vs OveOcZGMTzogFArTSTDTDwPyo70dPugX8ly+MDqtoePCv+29z8VpBYJzLpGKrj3RGSQ5JLMgFO6CE 8P8rf5/dty37eiCRYxKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtsrn-001YEy-99; Sun, 05 Dec 2021 14:51:51 +0000 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtsrP-001Y8O-Ot for linux-arm-kernel@lists.infradead.org; Sun, 05 Dec 2021 14:51:29 +0000 Received: by mail-pg1-x52a.google.com with SMTP id 137so8022647pgg.3 for ; Sun, 05 Dec 2021 06:51:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=r7FuDJBkqmbrNZ8AuyY2ToeqGTn3J1mJtK8z1ItIbdE=; b=QHCE7EcZHC03zy6MaqNqCBN+Fpm5uAGmWmVntGtp7U5n/wHjBc1F3Kdy8R5DdkiE6C CQQk3ZM5MTTKy0JcD6PEeBIml/H2OvjS1+XE7GeIX4nSPB+wH6DbJa5EN7/rSbhr8huE UHqFfcSu5fcVNqcxHbhD+z4rM3rUqKWbdIkOskuZOwi/gIOTZiDI+kT+wSq+lTHFcfzd 1v2/rTkuvQ7MBlcI3hEeye+s911D7DZq8FWScsalbNbWTbefEE0ebKEpw22Vn0eYAE2S jKIXPSXFADD5/RyLiApLFsI5CUfRYg7XX03NJYFL5WrukGmxvCtyU/83iSsJVFHH2siu JfLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r7FuDJBkqmbrNZ8AuyY2ToeqGTn3J1mJtK8z1ItIbdE=; b=mplItTZ61p4xSw0ramiJx5q7J0/9sP+63papofFr+ooVyroWGuubcnyWTFz+4ddhAF thEFWVArobaVqiBGNOQYmXj6otmmscIjwmhlMLuCyT8Y9tGPwY2XiyaGUhi7KJ+y1qSd WNAeMkKWc3XgvHfYlKiDBHnPmUfHLjTq0oUhoAbG5nAExLztK4jdURK5CLznU3I3DcTR uJBMXJ/OdJeOjqw9VqpxcbEc+pul6qJVIrXe0IKeQ8UoyoGxqE3LXewHmE2XwOnYNjFt 9llCB2tHKWyHRSheVYZWrQuH8gS/av5jZu08EszfxZluvGiH1LqIfXJRJEjkIvMeAuzi Orow== X-Gm-Message-State: AOAM530xlLF6iGkHTKAwJwhF0bScROzYnbzGmqM2AMFOWnj5ZauhXW6j nGviWjAYI9rqS7n9v6Rgovy2jw== X-Google-Smtp-Source: ABdhPJzUBAAPjj8z3sKrvIM+BkzPaczsu+Op3D9PsW9q5fj4Q5p9j0lxy8voeiQ//58dzghyGllY9g== X-Received: by 2002:a05:6a00:124a:b0:4a4:cfd2:b40f with SMTP id u10-20020a056a00124a00b004a4cfd2b40fmr31149267pfi.57.1638715886771; Sun, 05 Dec 2021 06:51:26 -0800 (PST) Received: from localhost ([2602:feda:dd5:6b5b:660b:141b:4f83:cd75]) by smtp.gmail.com with ESMTPSA id f5sm7548675pju.15.2021.12.05.06.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Dec 2021 06:51:26 -0800 (PST) From: Leo Yan To: "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 Cc: Leo Yan Subject: [PATCH v1 3/7] coresight: etm4x: Use task_is_in_root_ns() to check PID namespace Date: Sun, 5 Dec 2021 22:51:01 +0800 Message-Id: <20211205145105.57824-4-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211205145105.57824-1-leo.yan@linaro.org> References: <20211205145105.57824-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211205_065127_831503_A430D6A8 X-CRM114-Status: GOOD ( 11.68 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To avoid open code, this patch uses the helper task_is_in_root_ns() to check if a task is in root PID namespace. Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c index a0640fa5c55b..cd87ad8456d7 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c @@ -1890,7 +1890,7 @@ static ssize_t ctxid_pid_show(struct device *dev, * Don't use contextID tracing if coming from a PID namespace. See * comment in ctxid_pid_store(). */ - if (task_active_pid_ns(current) != &init_pid_ns) + if (!task_is_in_root_ns(current)) return -EINVAL; spin_lock(&drvdata->spinlock); @@ -1918,7 +1918,7 @@ static ssize_t ctxid_pid_store(struct device *dev, * As such refuse to use the feature if @current is not in the initial * PID namespace. */ - if (task_active_pid_ns(current) != &init_pid_ns) + if (!task_is_in_root_ns(current)) return -EINVAL; /* @@ -1951,7 +1951,7 @@ static ssize_t ctxid_masks_show(struct device *dev, * Don't use contextID tracing if coming from a PID namespace. See * comment in ctxid_pid_store(). */ - if (task_active_pid_ns(current) != &init_pid_ns) + if (!task_is_in_root_ns(current)) return -EINVAL; spin_lock(&drvdata->spinlock); @@ -1975,7 +1975,7 @@ static ssize_t ctxid_masks_store(struct device *dev, * Don't use contextID tracing if coming from a PID namespace. See * comment in ctxid_pid_store(). */ - if (task_active_pid_ns(current) != &init_pid_ns) + if (!task_is_in_root_ns(current)) return -EINVAL; /* From patchwork Sun Dec 5 14:51:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12694811 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 54369C433EF for ; Sun, 5 Dec 2021 14:53:21 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=v3VLN5rxtuUH8T7UhR3XI5gyQ4pTr7fc/04n71fHrx0=; b=0aLjBnPlbM8gJo NUBChmq1PGD+/+88JKy64C7i5/KQPNHeIDu6uyYEvA5oR0MuTEHSTFkfY4YL4PqzvvwJlIBm9UBRX QFutqGaHyz2RIFG2bwzjP9/g+w9olx40zw8Az5kjiaDV8eJ2HoJNUxLyG0EYFfc6U29RkPGIL5ICK 3T2zWnMA9wn2dh8RYWXSerk0vpm1qNWgU4Rx3DA5HkxR2/kdT+88XiUKptsNVOIExSxaMUNuKaYT6 mEmRwC9eFiMxEjwsrANn7c604Wok2X/yWD+Ari2tk5Onm1akWfTmysjjk6vlFx3d3HpSszErg5MAk cbIeaGPjso0hKUpPlzjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtsrx-001YG9-Co; Sun, 05 Dec 2021 14:52:01 +0000 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtsrT-001Y9E-BO for linux-arm-kernel@lists.infradead.org; Sun, 05 Dec 2021 14:51:32 +0000 Received: by mail-pg1-x534.google.com with SMTP id j11so8017561pgs.2 for ; Sun, 05 Dec 2021 06:51:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3LDDsH38QkceeUfcUldY6VFRPfPHtJesMGkSHVAh5YM=; b=f3fPCDNDHAaSIGPbUYS057ddh5pKujL9XVYkGT4eEig7wCM/t65G2aZKSXTDn/zR5X m5T/+pMCCs5rlWOOf+s2ocQZ7V16WVgz4DJ8NP+3yGnRL9TVsJ/ZWKqt3YXTnZMDYyhn 4lZ0B7y5iKOT/aj6AyagHYHph9TDHQCp1+kMfZ+Bpkv9qNZesc58bui4Kv5lafRwEd5c Y4DoyfsSszMrZ2Z/txZNZR/AzVByD905iRTYUkfJlKFC8A4m+j/SWLnjEUZolRYe+jcv 1zDI/cX8dGGp0oVBtZMmN3R24vooHnabpX22ZHu5jUGt0uh2jvLbgwjDxVongWQE/1gz 4W7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3LDDsH38QkceeUfcUldY6VFRPfPHtJesMGkSHVAh5YM=; b=3LmMMeRA9PED/uLZF6Uk0Wbx6hOs7HbQjGTHt4ECHwb/dGs3jsDrrNl5Tu72aVeqXH DQBejtlJLZ7EhE/EE9hoMMHMjfF5ViewSvkxNgcHGIb9Wsy3ltKBXw8rLXPDzSmNRmFF 20R3O+eSmBjGAtWjA8u2DQ6z+sIoI7KLdgVw5tNtE8vvlgUMb6UUK3O0zlni742Gd29R c2ZezdHtMfVAvzuEMSiavuVGpwK1hBC96xIkdEK+Kajl0JurVRBgKxunsl7TmKw8T9ev 1Z2YaF7JjVETz5qOYeF0hCCDiSqYpj0WGh1MaJwBd5d4ZEl2BnQ0Jf6CirPmn8RtQcQt xB3g== X-Gm-Message-State: AOAM531kN870X36+uHP7KxaSv7hvT0Ty4Ar4zfhL9XQgq2MdWvkZAdpk OGX8UmrN6jvEpA4bMYzdw9Ivwg== X-Google-Smtp-Source: ABdhPJyuJmKT3XfC+zhLm/KCB4bWKe9YooU6y1UfwRFRNjjlMVTSdo1heNNLMgTcMpJFMrBsLFPdqw== X-Received: by 2002:a63:6a83:: with SMTP id f125mr13999908pgc.340.1638715890495; Sun, 05 Dec 2021 06:51:30 -0800 (PST) Received: from localhost ([2602:feda:dd6:6f1c:af3b:f51c:baf0:62a]) by smtp.gmail.com with ESMTPSA id p124sm9212732pfg.110.2021.12.05.06.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Dec 2021 06:51:30 -0800 (PST) From: Leo Yan To: "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 Cc: Leo Yan Subject: [PATCH v1 4/7] connector/cn_proc: Use task_is_in_root_ns() to check PID namespace Date: Sun, 5 Dec 2021 22:51:02 +0800 Message-Id: <20211205145105.57824-5-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211205145105.57824-1-leo.yan@linaro.org> References: <20211205145105.57824-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211205_065131_417366_1765BD72 X-CRM114-Status: GOOD ( 11.77 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org To avoid open code, this patch uses the helper task_is_in_root_ns() to check if task is in root PID namespace. Signed-off-by: Leo Yan --- drivers/connector/cn_proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c index 646ad385e490..b8a4fa366b28 100644 --- a/drivers/connector/cn_proc.c +++ b/drivers/connector/cn_proc.c @@ -358,7 +358,7 @@ static void cn_proc_mcast_ctl(struct cn_msg *msg, * other namespaces. */ if ((current_user_ns() != &init_user_ns) || - (task_active_pid_ns(current) != &init_pid_ns)) + !task_is_in_root_ns(current)) return; /* Can only change if privileged. */ From patchwork Sun Dec 5 14:51:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12694812 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 86A6BC433EF for ; Sun, 5 Dec 2021 14:53:35 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UbjwoEqPhmZ+ooIKvVz4QbWtPeAwuglHXGKCUlHTtME=; b=FvXTjsmEH//mrt LlU3txnl+BiTL0xUYPZDuWx8d9ESTaZ9xlkvBdN5MNyEFAOfUMxVaX2vVX4DGFL3YI05JwBfM7Yac 8kUN8gvOJNfZ37p+a/MA3mfZQxkPbGl0lIfWv3OdPmwhTbAziqwwOaOB9OK9eY4e+jm6Luf1wRSAa iaKO4kb718o/F9U9/gKjRuPEornwYg/GIh1ag6Yf6SmRtlEJHBU0ueLGPu1/68aDZNGcqy8JibJPM pvGIKG1fnqlafZJ6dn+B0rQRldAlMm4VtAONQO2KKkAJwhu2vIa8l5+GeHzpQ32JTzwShUW2eUFuU MtYqHHHRf/uKe///hffA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtss9-001YKI-U5; Sun, 05 Dec 2021 14:52:14 +0000 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtsrY-001YAH-3F for linux-arm-kernel@lists.infradead.org; Sun, 05 Dec 2021 14:51:37 +0000 Received: by mail-pj1-x1029.google.com with SMTP id y14-20020a17090a2b4e00b001a5824f4918so8842400pjc.4 for ; Sun, 05 Dec 2021 06:51:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LxgaAqKPfY9+Fs9lU8SAVq20rT6hH9OdOm/kBs8bn3Q=; b=EGa7KxHBtggk+Rt/PaGDK60Ju5BJXpK5BICGg1t9YLhhLSgWFEbDxCeP6p2bnbMPGw 8NA0bwcpajU/GsYvoZSlTHwfAA+hqBSz+dqJXTB0yNbQlNZeANFqPv9cS1GnJf8nuWKQ dHkqQ7W5plSFalua9EQlzAoYGcZ4R7C6xS943c+/rF8QupsRxzqdWp32jPHgy23A16vx QhZ5WkRQlFdsHQy5SWANoxuN+0Ic2vX+Ewz9RTFITW+g056VdCViMP7aDzHklEHPP1oh mXHUybqyppw9ZPsCm/nTxE/hl7tYOE1zOnRg3kgHjDv9thUoHuMDnmjRYE1hGNge5CvS XZPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LxgaAqKPfY9+Fs9lU8SAVq20rT6hH9OdOm/kBs8bn3Q=; b=ahBZLigP7/fLwSVISDr6ulMcQmFV9UssvmTk1DCwx7bU64flzFZYJDQeppKuT9vfGv MTH5+YEEqdRz8AgW0op85OkNFfxMIi48WvAAi0WgWVf2Jy4OLOtsInJ3LxmpMSVl2liM CqZC9XlGnjfvafTi+vT3KeNFVsCksP7C++bRfeqwWBFsjq4ZlBPD//Vn/ejWjYmB8quW WNd7GHScT0p1HhChD3NOgTUKiSB0IOZAu75iHE0cHOAmQIZZoZXkn1iP9xW5gtk/lWBm YQv06zPxGcuAlHrLPgrCdThFFq3aBhChtDkqO2xb1Nqrhx9UhhbHIZMkLBpNg3o/pbR3 zgQg== X-Gm-Message-State: AOAM533yV346NlLfetXaBTsdmSNa1MTPGRwFwcngfzdVbppkMIKPVvJ+ lEOvsd2SZs2Hxc3IuowgVse3XQ== X-Google-Smtp-Source: ABdhPJyhz7mhy7c/6gh3uw7e17BV124wmThyRYdSZZNNApgX+01Pi1PcCXUsHi1AFphndxNGVWNNQQ== X-Received: by 2002:a17:90b:155:: with SMTP id em21mr30713254pjb.12.1638715895026; Sun, 05 Dec 2021 06:51:35 -0800 (PST) Received: from localhost ([2602:feda:ddd:e0c7:4151:8a98:ebd2:b9e3]) by smtp.gmail.com with ESMTPSA id o16sm10043005pfu.72.2021.12.05.06.51.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Dec 2021 06:51:34 -0800 (PST) From: Leo Yan To: "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 Cc: Leo Yan Subject: [PATCH v1 5/7] coda: Use task_is_in_root_ns() Date: Sun, 5 Dec 2021 22:51:03 +0800 Message-Id: <20211205145105.57824-6-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211205145105.57824-1-leo.yan@linaro.org> References: <20211205145105.57824-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211205_065136_163206_8DFEEAD8 X-CRM114-Status: GOOD ( 12.02 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Replace open coded checking root PID namespace with task_is_in_root_ns(). Signed-off-by: Leo Yan --- fs/coda/inode.c | 2 +- fs/coda/psdev.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/coda/inode.c b/fs/coda/inode.c index d9f1bd7153df..a7d630ac522e 100644 --- a/fs/coda/inode.c +++ b/fs/coda/inode.c @@ -152,7 +152,7 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent) int error; int idx; - if (task_active_pid_ns(current) != &init_pid_ns) + if (!task_is_in_root_ns(current)) return -EINVAL; idx = get_device_index((struct coda_mount_data *) data); diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c index b39580ad4ce5..54db13bf2e06 100644 --- a/fs/coda/psdev.c +++ b/fs/coda/psdev.c @@ -270,7 +270,7 @@ static int coda_psdev_open(struct inode * inode, struct file * file) struct venus_comm *vcp; int idx, err; - if (task_active_pid_ns(current) != &init_pid_ns) + if (!task_is_in_root_ns(current)) return -EINVAL; if (current_user_ns() != &init_user_ns) From patchwork Sun Dec 5 14:51:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12694813 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 5D5A0C433EF for ; Sun, 5 Dec 2021 14:53:50 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=L8mxMNDMMkP9czxTO0O+qCyaf8a89GRSynIbNpOE3IA=; b=UUC5/bTUEzkbEM Z9LcnVur5zEQtSOGl5er63ds2L3v0BMc3OFIzKpcyUPJ5HqtHII2D8aM4LRdVPMN6HAQ1FaHBpl++ AAznM/m8+X4Ep3Vv8o+mtGqMQmKzRjkbFaabG1KQnJEv6ffpwKTw6aoJsw6BtaVWUoUdIGZ5d18ie pI7JWTBwRFZ4bctJ7uky83mQEbL/PI5rAI8cE8xPlzuBDTiiVmrbi0135G8Pi/H6t0pLBC5u8+zhz 5dh6JrHa0uAI7Ju9SkctsDKHZDLEnKIEIVXQ+7R5vF7Su76coVikeW1IUAZT2ImOAiJiPfSKkBvMv H1G7jRyAWPq0kMTmfTmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtssO-001YQX-SV; Sun, 05 Dec 2021 14:52:29 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtsrd-001YBg-1M for linux-arm-kernel@lists.infradead.org; Sun, 05 Dec 2021 14:51:42 +0000 Received: by mail-pf1-x432.google.com with SMTP id 8so7754916pfo.4 for ; Sun, 05 Dec 2021 06:51:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h3YljNelpLYurDb9qdET1+BdmKMP449z9py0Gh1sNcI=; b=KlyrDEascSedjmQ6m/eg0D7PY7G612B3EmrP1NscQ4eGbJj037PV8M1Zqtheb9+iwj AviQ0zImdyacEmnQoGcfHQmj9rgspgyCDSljp3SbLn0a0kITqDiFzACuqlNquyDB/aUq khC6D78Hlm54RUCVwrvYwn0QGePXwTgubI6CFc0WGrFzMvEUKJkXe6sgWprCQRTyf1KQ 2g1KWGPY0eLViCDSUZQkV901Iumk+ZRnoCmGC/XEgkCxoLsB/3eeoAxIw0d2HY2OvASB SNScQOEdxWI1dMoWQRQcwl68nHAENfYelEVYRK/JoIVvYToujYdjoYkhfPFsXxisz391 heFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h3YljNelpLYurDb9qdET1+BdmKMP449z9py0Gh1sNcI=; b=Cv9cdaOnkqySzTDzcwaCv0pxe14KkBk9+wWppJviJ2pBue/g1xaBG6F1RzpxYURvGY 95w1fyTSjFod4NNY0pF6HK7kfh+uLQsss0CJZ0FpwcL2yEV6lJNtEjHNnz8/AF/AYIME hOWaZwn9z8bIplxzMIlF5bykV5zPZpfE0r62fGjgJUCc03QVPkDhGZj6b6Ox5yM2MZkZ KYK5stDjzMXHtG8sB0h8YgPSdVpjAz8XmJyT+fM6nDycvQIUO6BpYX0zHOUtPpbUGvC+ apNbYwGlirixzWpgrZx7PSki7J2WD4vg0HH95hkTbOvP6cgeelvGHG7EiJQbvGOfV4bD /m+w== X-Gm-Message-State: AOAM5323Zl766KMIOpihfbivEd+h8WGMtwEvoAzmKM/JLjqf5wHfzhHM YL7wUKJ47WQ1s1IpJibcuRwVyw== X-Google-Smtp-Source: ABdhPJw/kut7WA2CgtIMvPTxsWYwUnt4uJMZW1REaKKpU+Wjg8UkgeddhtYG0nXWVQme7QOqSE/rLg== X-Received: by 2002:a05:6a00:1248:b0:4a2:5cba:89cb with SMTP id u8-20020a056a00124800b004a25cba89cbmr31642944pfi.12.1638715900203; Sun, 05 Dec 2021 06:51:40 -0800 (PST) Received: from localhost ([2602:feda:dd6:6166:ad52:d50b:8700:3c60]) by smtp.gmail.com with ESMTPSA id y130sm8967440pfg.202.2021.12.05.06.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Dec 2021 06:51:39 -0800 (PST) From: Leo Yan To: "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 Cc: Leo Yan Subject: [PATCH v1 6/7] audit: Use task_is_in_root_ns() Date: Sun, 5 Dec 2021 22:51:04 +0800 Message-Id: <20211205145105.57824-7-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211205145105.57824-1-leo.yan@linaro.org> References: <20211205145105.57824-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211205_065141_101499_C4CD7962 X-CRM114-Status: GOOD ( 11.70 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Replace open coded checking root PID namespace with task_is_in_root_ns(). Signed-off-by: Leo Yan --- kernel/audit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/audit.c b/kernel/audit.c index 121d37e700a6..c71d4182c05d 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -1034,7 +1034,7 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type) case AUDIT_MAKE_EQUIV: /* Only support auditd and auditctl in initial pid namespace * for now. */ - if (task_active_pid_ns(current) != &init_pid_ns) + if (!task_is_in_root_ns(current)) return -EPERM; if (!netlink_capable(skb, CAP_AUDIT_CONTROL)) From patchwork Sun Dec 5 14:51:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12694814 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 210E2C433F5 for ; Sun, 5 Dec 2021 14:54:04 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=olmxkdG9PIgeZaMmDBa473F5BsLA7LuklZU7gYjgXSw=; b=wAkHcYQsFGIbkc ysIavji3hbNqOoNk/b28AAEEPrDsLnvyFUWAvVwMcT3QYtJadoDzzoLMCxFsPOKrSUSvEzoZNDwzQ N0uG1RNNPN+wBuY9jLl4mbXtmAXEhnWhdYEs8mDdq8UfGpfLJMMYZw3OrXvViWHxYoH6r15hTyKnX sjDLJqgJ8SJQ7GyVmqVLi3Hm0AjoF2prKYlTi62/ckNVGst6xCmg+Lh2IoFHO+fqFI7zFTNM9zqJd 3gxUKi3hVDqUQN2L+u2wljNUxv5Z8XBGHvCDZgFBGty0u+vtPZ7IIn8jMcH2kK2xgzka0RQ9G2O7N 9WBp3HlzOiZSuH2/QnfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtssf-001YYo-PU; Sun, 05 Dec 2021 14:52:46 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mtsrh-001YDb-Pg for linux-arm-kernel@lists.infradead.org; Sun, 05 Dec 2021 14:51:47 +0000 Received: by mail-pg1-x52f.google.com with SMTP id l190so7984078pge.7 for ; Sun, 05 Dec 2021 06:51:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WoYH3kUyU3rR597Qe29Tyg1cbdekiS3zv4yqA77Ra+o=; b=PQrQcoOw1V9KP76uLbFLDEDyrU9vqBzJPlKj+pTPusgS4daHAq7p66wzfdvZqqIJc2 QRKtdzA1IbWpSH8mHpn027kXF9Mild4jnXfXrzwYxqZxzF9JDoK6kTv1YaFv05Il+rEv lIvw4Xq6j53moojd4Yjl4KoUFlH9LWXrmjmmWREieVyxw8BExrw3buKuSVltSk3mNAaz mh2fAPVWvCLZscc+IivAkObQD8K+H0FitLX6DJ4jpbHnoQAEwMEadj7f8xY8967azkF6 Q5w6kToRbIlON6L0NmISOYfuZ8vwO6RrksQaoigaYoCM56mEQPl8QUiaddf/27eSZl0n V4MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WoYH3kUyU3rR597Qe29Tyg1cbdekiS3zv4yqA77Ra+o=; b=wq+HRZ4n0nLwW9MwiuQkPqe4c39LBytRta+ZBRRA5qE6l35HOpbzC2UqVy9cThSCxW YeqzbyYwNWTX0KAqTAZ1wc7gIZW8kow0le8IAiMuL67AUfKz3fmjuSqWYs5MMlWpiy9j Vm2yWivwlZmdOgihzEnzCUQgNmEC3ZXtyLMkSgCCyd+3TUwqBr2HlXWLH0SVnRAC7tZu YbSnjB18C6dGQO2tQ1UgXzGItHndOq+NpXU7/EI66OcDZuUrOhU+7NQcE40MMtwgFaga CApOQboWu51TzcGiBOMrFOwih80IGOBh9M+YXXvcF41SBBYNw5VOiGEowRfvGwHMAaDW wUwg== X-Gm-Message-State: AOAM531og+n/IXVRhqEE7BNDsun98/sqeviwainAq1GbeLA/9EwGJ7FT w81gR2stW3uTDpxUke8Ph4O+5Q== X-Google-Smtp-Source: ABdhPJycmQqaqKyYV6rADGSOztK52rZFL5guaz/TJWi/jAvOjSlm3KATDKooWY63M7hIdTmll6FeGw== X-Received: by 2002:aa7:8d0a:0:b0:4a2:82d7:1695 with SMTP id j10-20020aa78d0a000000b004a282d71695mr31790299pfe.86.1638715904962; Sun, 05 Dec 2021 06:51:44 -0800 (PST) Received: from localhost ([2602:feda:ddb:737a:816:168e:3e5a:d93]) by smtp.gmail.com with ESMTPSA id c3sm9960145pfv.67.2021.12.05.06.51.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Dec 2021 06:51:44 -0800 (PST) From: Leo Yan To: "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 Cc: Leo Yan Subject: [PATCH v1 7/7] taskstats: Use task_is_in_root_ns() Date: Sun, 5 Dec 2021 22:51:05 +0800 Message-Id: <20211205145105.57824-8-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211205145105.57824-1-leo.yan@linaro.org> References: <20211205145105.57824-1-leo.yan@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211205_065145_853555_D3E884A4 X-CRM114-Status: GOOD ( 11.61 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Replace open coded checking root PID namespace with task_is_in_root_ns(). Signed-off-by: Leo Yan --- kernel/taskstats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/taskstats.c b/kernel/taskstats.c index 2b4898b4752e..c6a19d3911b3 100644 --- a/kernel/taskstats.c +++ b/kernel/taskstats.c @@ -284,7 +284,7 @@ static int add_del_listener(pid_t pid, const struct cpumask *mask, int isadd) if (current_user_ns() != &init_user_ns) return -EINVAL; - if (task_active_pid_ns(current) != &init_pid_ns) + if (!task_is_in_root_ns(current)) return -EINVAL; if (isadd == REGISTER) {