From patchwork Wed Dec 8 08:33:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12695296 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 6A6DAC433F5 for ; Wed, 8 Dec 2021 08:35:19 +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=CbIU2m4/vMgvfu91GNuzyL+d/GetdhCmBQYm1fAzm8A=; b=SZGQ2Yq8MPUsCf EzR5FY4xVNQEulcR638p+oNZFxtVLobne/rRQ/MNeE+xml+w4DWLG8peeVkUpegfXvYGSHEf9/BsS vitkpzSA6tVsqtKYWey5Vo56S49tycc9XqWJa5eIvQf3VpKGRFzm/+eUxQfa/eZiWQME+czC7Xwrb MG8QAT7BgRlBlIei3fXjp9AnObYRA/A4T4lx5GRf0+s8vln7RDul43gRVdQCAgcsKE7YLFOijBaEO GTOsca4m5jPPPByaDoErExddR9mW3F8OlzmJ3I73P2n4MdbOcfjbYgBFO7pXAtJRA+izTBoZwCFlD ABKCLMvVMEDLhB4VOHSA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1musOT-00Bi32-8D; Wed, 08 Dec 2021 08:33:41 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1musOI-00Bhxy-Ed for linux-arm-kernel@lists.infradead.org; Wed, 08 Dec 2021 08:33:31 +0000 Received: by mail-ed1-x536.google.com with SMTP id y13so5621060edd.13 for ; Wed, 08 Dec 2021 00:33:29 -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=HhbhdM+UVkV69ylyGAUrfry6xL5WJfe10RQ3MgDri3E=; b=eaX02OEPSS+RjOClG9DGc+v6cgQ88a34E72u12SEvVTKae7LfSyBfOb82cG4ik+ihQ vMC/UinqwVByxQYNyaTphU4u1cPFoa3FXqjaXb9X9cmergltDcgJY6geO6dTNjMs/2Cr 2ckYlk3wDqtGK3dMjrahko4FFZAV2ZLENLDoRtZJulXk1fVkjlKnE9ISE0Zkh/Lv5x6d 3WHnHmdLbdozO2mDzEn3AK9XR42fFN9yqUlC6TVJAjiG2+oVvxbL3wlzbFnUlZMr9iVU YwDGI5KC09SF8tOHXYvP5dtqvieq6x4p02D04zO16Lh/5pIAR3UtwpUgEBbKD8H37KIh 9+ZA== 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=HhbhdM+UVkV69ylyGAUrfry6xL5WJfe10RQ3MgDri3E=; b=dYwwZFMODG6V5g1JImIgAQp9LnC5cvaDs4oeFxjoAqq3yk/iu3P6SNiNCzpOidcTKx kf8ZgclA83DF+25rrWN123L/3hTathVl8lCNfHmFZl9cgEbryJ4SbhjAIXa94bBUKFsy I0pL75pLspeFmlgSfd06nwPnGbhH4CpgUnLHyYCKhgsAAXvpcTmGbtQIcW6RtqnSImmG rZ1Rs/vv/ZaIlw0ezvL/KFFuoHf4t1PsgDV8yef3kmH06gZZ03KzpZ4uPzHJGzWNB2OI ZWXZ3fx1hd7ATz/XjSJNS4OFz7bpGVwUZ8MjNzd7HgBUPD62MMqubVvIYAM18HqUrBYZ eQkQ== X-Gm-Message-State: AOAM531A3sC2vNnnXIj7jOzVo/qQEnUbAYiSJ802eEYsQjTooWfshN2F 9iN/RovMG43q9TmsBOXwbqFmhw== X-Google-Smtp-Source: ABdhPJz/Aub/CN7cwflA5aTaNqCW0zeff09QK+an5jfSI+P/yEVmx3XrZ525aOOBfp2sz8qeApVlag== X-Received: by 2002:a17:906:40c4:: with SMTP id a4mr5430305ejk.185.1638952407946; Wed, 08 Dec 2021 00:33:27 -0800 (PST) Received: from localhost ([104.245.96.202]) by smtp.gmail.com with ESMTPSA id z22sm1716370edd.78.2021.12.08.00.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 00:33:27 -0800 (PST) From: Leo Yan To: "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 , 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 v2 1/7] pid: Introduce helper task_is_in_init_pid_ns() Date: Wed, 8 Dec 2021 16:33:14 +0800 Message-Id: <20211208083320.472503-2-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211208083320.472503-1-leo.yan@linaro.org> References: <20211208083320.472503-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-20211208_003330_521867_643B0ACE X-CRM114-Status: GOOD ( 11.98 ) 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_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 Reviewed-by: Leon Romanovsky Acked-by: Suzuki K Poulose Acked-by: Balbir Singh --- 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 */ From patchwork Wed Dec 8 08:33:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12695297 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 54F0CC433EF for ; Wed, 8 Dec 2021 08:35:33 +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=5x1vgCwEA2e2boq6ZzYRJQPZaRfKDTYQEu6V1ffIlwc=; b=MSWBgGw1zHqJDT v34WaCoxN2R7FPb9ZrEY3BpQVBCDISOl3I2pQGik7ebMp+s+YkiRfYHOUrp6lXT8uNqSNBvzavsH3 +kLC7VZXv+hzdQ9QHtdefE6PiWHTbAG0ejuSy+XOf8RPGsQZdrg9awy7s0G6SGrhc+/4KQ2QtTN+u 3aLtz4sc5jkFpni5+E6IoKnyql2WZ6Drj6WANgymLet9kr5FhXQqQJWiegVzWPa3hsL+EODSHKZnt Wv4TF9cXuhItz3gmxQopiR5w1VUMwXOw6Qt7weu4RcZEAFkHOH2GGMq3b6CBnN5tRdTVb6ZGQ/iIs xVhgdDF9ur24vUc4tboA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1musOe-00Bi72-72; Wed, 08 Dec 2021 08:33:52 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1musOK-00Bhz9-ML for linux-arm-kernel@lists.infradead.org; Wed, 08 Dec 2021 08:33:34 +0000 Received: by mail-ed1-x529.google.com with SMTP id r11so5689266edd.9 for ; Wed, 08 Dec 2021 00:33:32 -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=nFpFNbcBX+lPeRGnonpR3BH6HPTPVDEm6tJ4QkqNbVo=; b=fyG2uCc9nPoybzx4IqY3kG3z4y/lzE2jNZjrff8vePl8GWtgZSaNMC65PLruzfzUFf dnAryvQpAWnYYa+ME9rtNg1BTldjtTWg8VMYpcbot++nJgPC/ZvNC6kvI9qPx5jokeor FLe6DmMQqJ6Xdfyq3TIhyZprBoXpZvj3lBY/aE6+D94wICjzXxClnejSEVcBq/MV9IzW HrGn3gPWi+N9sN8OZXa3LEvuAMppB3NSf2FAbkU2AzptV5XKKGctLZSdg2jCAIt+V7jH 6fHxN+eiDJ/z+RtnCyZ2TsqW3jbM4KHQCxYjmcLv5BGrsVHdBbRouve9mNV6lsfHWB21 WaGA== 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=nFpFNbcBX+lPeRGnonpR3BH6HPTPVDEm6tJ4QkqNbVo=; b=wh9Fo6RSPp7fmR4RaaqDIbJEEDKRtYXJgC/oTH6lfe6XREUGZUpbYDZzr8Z3kuzkqW l0XqTBIe3nNBchWE7+fV2LOiY2bex+nfEg83v9QnR4ofDQpp1pdBamnxGRCpi7v9z47+ PCDC04bj6ak2kAJ20gx6G0EC3LvuGKSr+YvzpUtexCFMvuvL9fW9QMhhMCTU+6lsqWdu gytO7SI5CzY3iscStJx9868L09niUHxlapp3ENA05S8+MOfRzW25ZQ9pqtHb2822rJen MQqAUlAytv8BH7GpgoJd9CIZXHBCZkTEUZd9W/XcSkqTbVkUoEoGJMmDaU+AyVcIITUA PSaw== X-Gm-Message-State: AOAM530xvnzcMCH+4E5kSzbR/5c2pjhI6IrmuB6HtQP3LGIcuzzqIp6J 2c6TubjhkjQB2e7RLlyGcxGtFw== X-Google-Smtp-Source: ABdhPJwjB4j2qwDPyk+4ObiPFmUCJJ3bfOq7wkfrgeKtjhkWvjp7+SQ4o/Bu5lKqkBurHaCAuz088g== X-Received: by 2002:a17:907:7e91:: with SMTP id qb17mr5835776ejc.449.1638952410925; Wed, 08 Dec 2021 00:33:30 -0800 (PST) Received: from localhost ([104.245.96.202]) by smtp.gmail.com with ESMTPSA id d10sm1089074eja.4.2021.12.08.00.33.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 00:33:30 -0800 (PST) From: Leo Yan To: "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 , 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 v2 2/7] coresight: etm3x: Use task_is_in_init_pid_ns() Date: Wed, 8 Dec 2021 16:33:15 +0800 Message-Id: <20211208083320.472503-3-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211208083320.472503-1-leo.yan@linaro.org> References: <20211208083320.472503-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-20211208_003332_752605_4ED57EA1 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 This patch replaces open code with task_is_in_init_pid_ns() to check if a task is in root PID namespace. Signed-off-by: Leo Yan Reviewed-by: Suzuki K Poulose Acked-by: Balbir Singh --- 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..ff76cb56b727 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_init_pid_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_init_pid_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_init_pid_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_init_pid_ns(current)) return -EINVAL; ret = kstrtoul(buf, 16, &val); From patchwork Wed Dec 8 08:33:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12695298 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 1AC3DC433EF for ; Wed, 8 Dec 2021 08:35: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=Ep+2UtEnoePfzNM/PCAf0hvscVRaK3+nmyCnvsIRLtI=; b=dCuh6CmCMzVlUz oXKGG5oqPZeUsSG1ePUvtFULID95F4NAzP+b1NmewPRoHB5eFzooBFMJNLiYk/0EUgdOORMzC/BoC el0Ehc/Gs0oXFkOikNG7LhHU4+nuRNm/lOOmBsCXiZinQhNABIZh1dMEwKouxypfnKxky/dW+nf1o hqDd2uJplrivn+bQf2LtLWJ2q2jDvswbsVajhpgKRXv+vOTUYdtT6RGB4/nOOy65h6v6PMznRC8CX L1QK4HP5Bzqc9gUEU1hHG1oqQJD8zzbDtI2/yC2zPPpYGn8XDj38XCQowl+TtDyWtw3vKe89lXHmw pbZvMrdTgFIzGJxTAIcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1musOp-00BiB6-Gm; Wed, 08 Dec 2021 08:34:03 +0000 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1musON-00Bi0Y-Qf for linux-arm-kernel@lists.infradead.org; Wed, 08 Dec 2021 08:33:37 +0000 Received: by mail-ed1-x533.google.com with SMTP id y12so5639685eda.12 for ; Wed, 08 Dec 2021 00:33: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=syFihbslZjHwDTq+JkTCaQ6HIW4tudCEAOhWOsBW3f8=; b=FIcHYQplia/uHOPYAfm7N4eTvgq4ZpEMly4CQ2o0QB93pCqBsp+PSLAfFRfUDZnr3d MVR+UGxBOo8yJC1+svs7NhIjnCKAh7zb3bNifNkQMEK0r5f8e4YkobRfY62ijRcn/pZM 4A4cuMgB/V0bZLEf4NPKIrZaenwkaBKW+tLpJGMnq2kf/VeM4qg9N9PFTChUHiz2GnUY 9LWFIUa+BvjfShAdss2LJxz6+R3B82S8nFqn+mVpe/RKju8AEjKG7ViBK4MpZ2eiqfTw w30Wtv2qlMPm7e2YizgaBP/mHGY0IpAGRqVXFjB865p54jcxfIBpxefgck3adHPeoG+I FB9w== 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=syFihbslZjHwDTq+JkTCaQ6HIW4tudCEAOhWOsBW3f8=; b=5xygm19W3ssVUd7MiPE3fAKY0Mlq0y6nyj2D8xYbLTqmbGJIv0yU9pkzwLgVpkjGFP rx1KP8YfGc3NBzrUPVBc+n47kAh/ap+RoWbxC3R8TCBk/neGAGpJmY8YBm3X1HBpinop l6VrDi239yCKLQ7KJcO2C/oUHZJA0wIXjqkoI3vpX/UtxuZBiDVtSa/WyozAEgGY6/u2 +gZq/y9/gFJT/AqFs4VZa0Z4zW5Lg8JGlTePBV4laAkWq3zEtOvAM9kUCwsVqHDUe/IG kj4iIk4LaSbD/x6FNmnsoi4mYtdA1RKXxtiKsDyUGrsItw9QS59qV+wn4OLBoGq7sxyc 2aKg== X-Gm-Message-State: AOAM5317/gJJzHFMK0rEHBHF/XOwDNi0mW4Chd+O+rHznXQGyxXWqin8 3x3tvHH+mzUOouV58ZQ5eyE0Wcp9EqWmK/+eY1o= X-Google-Smtp-Source: ABdhPJwbn0b/epdtBx4MFnKaeNyNgHRZAK/UbmJSYo1onUQVReJD7IxMwNpCQLIpnZb6sOh1Sxmpew== X-Received: by 2002:a05:6402:2744:: with SMTP id z4mr17639355edd.310.1638952413660; Wed, 08 Dec 2021 00:33:33 -0800 (PST) Received: from localhost ([104.245.96.202]) by smtp.gmail.com with ESMTPSA id hs8sm1077396ejc.53.2021.12.08.00.33.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 00:33:33 -0800 (PST) From: Leo Yan To: "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 , 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 v2 3/7] coresight: etm4x: Use task_is_in_init_pid_ns() Date: Wed, 8 Dec 2021 16:33:16 +0800 Message-Id: <20211208083320.472503-4-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211208083320.472503-1-leo.yan@linaro.org> References: <20211208083320.472503-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-20211208_003335_921990_6B62A175 X-CRM114-Status: GOOD ( 11.53 ) 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 replaces open code with task_is_in_init_pid_ns() to check if a task is in root PID namespace. Signed-off-by: Leo Yan Reviewed-by: Suzuki K Poulose Acked-by: Balbir Singh --- 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..10ef2a29006e 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_init_pid_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_init_pid_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_init_pid_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_init_pid_ns(current)) return -EINVAL; /* From patchwork Wed Dec 8 08:33:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12695299 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 6A5DDC433F5 for ; Wed, 8 Dec 2021 08:35:52 +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=SiAWgojgDlo2ALStpmZLs9VFC1F8jzZbg2dbC+hJeAg=; b=Pi/n01SZfsy3uY XBnSGlRn0JWPK198uOjZuqOywEdASTz+B5DGlYqdaMD3E7qMpSn1syqgFho1eWNiIwMCNb7uBE/gG ur4FUnUayfwVl8w0JhqEO87hiM/C74Rg6ZHvBJsIYkrdmZIccOTOm3O23bY8Lr6FyeUurfDhG3bL8 /78R19cpBqAUjRljWeaZOiALWGIDspvirqkvVeqCy2PyGWh9P5p6B6Y5ExSMHJKXM3mhOSiXG3smE N6yleoBm3Eg5VmbbpVYB6YU5xNci4/FOYpP8fYqwt/SQxGT1cXRXZXo6jpSgtgvCE5+BqNsdAJ498 jOY+cP5iXIwCOz/20bIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1musP0-00BiEJ-EW; Wed, 08 Dec 2021 08:34:14 +0000 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1musOP-00Bi1C-L9 for linux-arm-kernel@lists.infradead.org; Wed, 08 Dec 2021 08:33:39 +0000 Received: by mail-ed1-x52d.google.com with SMTP id z5so5822157edd.3 for ; Wed, 08 Dec 2021 00:33:37 -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=hWyoQ03AyiBHBWIuTqdgSeOsB5qpmILnrb6mYHioPfI=; b=GK/tVEYgxyUvQFbH1SFaI008Q6trqxRp+nDnHpWJh12YtgZvbGJk7hLGvDKtbMk0zL xwxFOvtPy5Xws67MVe0W3I1aNVjzUyGZyPf3+O1fQL3ZgDQjB7hbdqzibnwyeKrAcu0N cSC1DwRNG2Bi/kRBZPruIAUWTmK9G9R9L61HhNugyhWORaHFD6KuBK2n54VgavYyRtWX xWjRuUE9N4UFyNalIs+WgArU0ULJWBg5CFsNz+up0sQflSRhtjbfTo3eED7zMHqY7CCh TxoVqGs1HEsiyMx/GajB/vBzL9/2K0vzgb4+KGOfFP61CG2M2VeinnQQud5jG93QQ3vr XM4g== 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=hWyoQ03AyiBHBWIuTqdgSeOsB5qpmILnrb6mYHioPfI=; b=B92JQzeflkcu92V+OqPW7F8wowvLhRSW2P0DojxXU6cOso6hsWTvpRaIVxZfFVurMN kpHXGM9KvZW7fbRe0s9XTD6ggIYbAxbG8K0Arc7wepDtGiN9rAlNg4PCuJTgzUJ6PPM/ xTGDd2mHkECkR8aoI8WrJafLhw1zlbzjyIsQBSc9XAWvgYfscGUR/ZGNYQJbYTQkk46x /oiiR6QvqWe7+nVH/TOMBJtkO1tRb7EpqvSPTq9GjQGetFomPDs3dD5HJ390H+zDw6Z+ 3svc+qMTfWdh+3WEq2WYfuPrfcDZyxLQEJ0UYOVcZ4s6301kaaWsOtsImReIpFSzX/De AKFw== X-Gm-Message-State: AOAM530mfEasVh7AYRNQRxsfbUdLMyLLexwofPdddz7yJo2+jCCwhJgo 9//QYCWWTRF2yj98vDZfAGBXEw== X-Google-Smtp-Source: ABdhPJxuBtI+/+kQ5BUm3igh6ZDVewoV1vYV0z/0/tl6BZ5inncH5WbsQjgaDaLRdh5hJdL1dj1EgA== X-Received: by 2002:a17:906:7b53:: with SMTP id n19mr5897162ejo.538.1638952416319; Wed, 08 Dec 2021 00:33:36 -0800 (PST) Received: from localhost ([104.245.96.202]) by smtp.gmail.com with ESMTPSA id t5sm1564891edd.68.2021.12.08.00.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 00:33:36 -0800 (PST) From: Leo Yan To: "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 , 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 v2 4/7] connector/cn_proc: Use task_is_in_init_pid_ns() Date: Wed, 8 Dec 2021 16:33:17 +0800 Message-Id: <20211208083320.472503-5-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211208083320.472503-1-leo.yan@linaro.org> References: <20211208083320.472503-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-20211208_003337_746717_B31FD1B6 X-CRM114-Status: GOOD ( 11.57 ) 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 replaces open code with task_is_in_init_pid_ns() to check if a task is in root PID namespace. Signed-off-by: Leo Yan Acked-by: Balbir Singh --- 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..ccac1c453080 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_init_pid_ns(current)) return; /* Can only change if privileged. */ From patchwork Wed Dec 8 08:33:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12695300 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 09225C433FE for ; Wed, 8 Dec 2021 08:36:14 +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=RUa0+KUYb0oH+g/qbxCVWat7AZ8b8omYioXMKui95oY=; b=0Fak5JcacqK76A V8MUsS1I5x8eILWui/ebd2CQijY8stiqocWMM7Qevj1zyxDThgcZaFlq5LlP5NVqXr6GWDcOFfgOB cjpL8AZp7n1qQd4Ytdh/fIdjQuSoZeAoDfuVeBA3Ueppjg5DeOkjfyBF/z8zl+jvTOiTQhRzWeYi1 5ZT+GQENYfJt17flAO0ewNy1LOjNLxRJdkaaAU5xuqhKIzBri+HgOQ0YptARfI1KFi0zb+npfH3jp w67aT8q4chX7WEg2i/+jiYh4udbPBPFxHbmBf2B/2QAoW7tEaGglsPjHIDj0HJI4coEUVP+RmJd+u UeUWc1HnG7mGdHYXqrVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1musPG-00BiKQ-K7; Wed, 08 Dec 2021 08:34:30 +0000 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1musOS-00Bi2a-Tr for linux-arm-kernel@lists.infradead.org; Wed, 08 Dec 2021 08:33:42 +0000 Received: by mail-ed1-x530.google.com with SMTP id z5so5822543edd.3 for ; Wed, 08 Dec 2021 00:33: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=kWkrWIVd0/tR6K54G/x68wI67h0lySobA9zdXOmvIu4=; b=defM02iiv0IuxmhLtI7Q91bOiZbH9EqLeP10tH5ALqWf7R+haF+jgmUJ9uAyaKbBQK k3h8RCQOzjyxiA2Nt9jTqv9wJow4oQK1mOTwjiankLQ+2J92Ml5eYsOmSKs9HLE0TGhK nlz7h+3ca/HKUfg723Vt0Bal0l19de2P1lx1goPBgFEVtxjaSWVsvLWEHSWTXeYQNs0s C/V1RAckrBlIKHtfpw3tlSk4ncANDAe+YfGbE98zhwCu9y5wUNNORJyNtXRZr6DNPysi YQfk/eqDVG94A41nzcjytS3Go9SvHW+T/dD70WTpUSNgtWIgl/jKmiaK428o8YJ7V7YD Z9vQ== 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=kWkrWIVd0/tR6K54G/x68wI67h0lySobA9zdXOmvIu4=; b=Yv3mEPhhZzRSFoa+MHe1owk6ySED3YWMIyrxjADTQXIIiqSMzU2R7yBPO1o+AQZyZF bw/iHO8004hzPnFnSuz4zYA/mkk1sSzBtGe0+3Xpps3xmLZbas140EmjWvW7Oh0L0osR 4ma2COtNlaTiY/riSPzaHQNgTF7xznccfUPsqz2+fsBW9R7I/aojpe3NbWNOjxxORdq7 zjxa1lzYmRbGF36Q6QPsNSp0QDfnoJHEVD3iCNO67h2ZdkoN/mxDufOKbarN48+c0hoY 0FBIH2FB6q0ieTDfMjzuRCGMNWW+klzxxAJ3kbxnIGX3xNfYAd9mphoyxY8cFFeYndjB 5fQg== X-Gm-Message-State: AOAM531R4tRBdshK0BdXzqBDTXdf9IOtFpPh169ueMl5/qg9YC0E1K6Z l3JHJfDUm+s2b4aCXujb0G5zhw== X-Google-Smtp-Source: ABdhPJz4wjRib7Te/OFIfhE1RhBahkANQSzD5tFXSlekwOc7sbVMSqZYx/8aXbTYVdMw6+UCNgG39g== X-Received: by 2002:a50:fd16:: with SMTP id i22mr17261360eds.224.1638952418992; Wed, 08 Dec 2021 00:33:38 -0800 (PST) Received: from localhost ([104.245.96.202]) by smtp.gmail.com with ESMTPSA id f7sm1491975edw.44.2021.12.08.00.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 00:33:38 -0800 (PST) From: Leo Yan To: "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 , 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 v2 5/7] coda: Use task_is_in_init_pid_ns() Date: Wed, 8 Dec 2021 16:33:18 +0800 Message-Id: <20211208083320.472503-6-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211208083320.472503-1-leo.yan@linaro.org> References: <20211208083320.472503-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-20211208_003341_005439_BD48374D X-CRM114-Status: GOOD ( 12.60 ) 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 code with task_is_in_init_pid_ns() for checking root PID namespace. 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..931f4560fdd0 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_init_pid_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..73457661fbe8 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_init_pid_ns(current)) return -EINVAL; if (current_user_ns() != &init_user_ns) From patchwork Wed Dec 8 08:33:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12695301 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 BF7BAC433F5 for ; Wed, 8 Dec 2021 08:36:32 +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=7eEiVERfkjr5Wf2XId8Jg043izL7Y2fhQHSdUFneSGA=; b=tsp/K9jUA4juPp Sh3lY9qwC7UPMWu+BmSmFg9hNQlehYoDZfFW8+lrV02plPOmkueN+IAMsw5Jd36+XTpt+g1i9gBve cJwkJ9spLQp6Jht5YboTSn2gPMkmPmWOhJZknDh1OSvg283vOR+rwTy9yqdkFtzpkm4R+KAc6f7Fz YbT0pp4WQ+wG8vCAZmT/XEKYApSIHq3iyM45dk4pROh4x00AtMPAcomSwPH8lH25OsgTL6fwSXVFe eKKUh4J4pTpYV4T+TQ+W99PSk7LTS4M3Q0I/nUvK8QOHqzHEzRLrTPoPqpFie9Fhu8wsXd4/0pria pKAsNKSnm5c8BP9595jA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1musPc-00BiWB-R7; Wed, 08 Dec 2021 08:34:53 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1musOU-00Bi43-Tc for linux-arm-kernel@lists.infradead.org; Wed, 08 Dec 2021 08:33:44 +0000 Received: by mail-ed1-x529.google.com with SMTP id l25so5665209eda.11 for ; Wed, 08 Dec 2021 00:33:42 -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=JOIrFFDk5p1ePCS4wLsIC6TxcwfDzOnZW25hdk34YK4=; b=kSQY+Eco2ps92/BlhAqd7jefj8Pdfe4ynmziuDHzEAafJ37bIJPkawc6HSkLE5sODW tDuULAoTyoSbi7H+ZfhjLgCPoo0RA4hi8mEUOLjpdNsGwEB5Tea03e3pfkI8UdM0S1w8 PqMC/RTOL8e/Zbcdr5gBsIXxFIeJBuFF9UhrydqJqZTOJSdLj4vk29fuhsC5UqVNVyY3 0f5Gefqwl3HwzyQdOWS6bJsMnOfwX0FMEFcypOxGhsxBAEExLdd9VF7okrcLVtOdy+Du mhwUMtVYhBHQW2a67E6uwfob9IcIN8VvpJDoFM/9iIhf/vyDwwf3XW6c16TfGoLAkXmd hc/Q== 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=JOIrFFDk5p1ePCS4wLsIC6TxcwfDzOnZW25hdk34YK4=; b=DYy5ZqjsSC1KPPrF7Pi2CI5cNrmO1OJPAfXI8tNAYZYQ6IUoLvBN0wHy58HFpmJMQ9 JGyDA+CgV3RUOY4ZslAxpxmwCg8iszHZo6BlUoLrZf6k1718w+M6Gq2taJtD5F30HuQe Ry1jW+/CeVOoOY9RaUGlSCKZJ104hkbYUYUVlom4W/U53QP2/ueTbVqXwWPi3rucCiz4 0ppFQ+00dCttUyB6VJu/cvQwRDAp+Z76dZZxN3u36ycyp/ClFs7IKFjzpGM4RH5PNqD0 PDN/5NO9IRbgc+2B+aMYPTaXMTP+PMBYCrmIE9ihWhu3JCrC6gyLjoAtae3OqL5vX7gl j/sA== X-Gm-Message-State: AOAM532FcuFjaZWOaQV2QlSDKIKSuKXgXTE+OPzgWXdfg8EboRkgk6Ta YWOvLddWp9zz4E9XUaHRsTe49Q== X-Google-Smtp-Source: ABdhPJwnBjeapybURWXW5vGntY1jPXQPELsuOkB3wJNQFHsP8w+vL940CmsfbOEisLwAdfpYEq7JGg== X-Received: by 2002:a50:d543:: with SMTP id f3mr16932046edj.56.1638952421670; Wed, 08 Dec 2021 00:33:41 -0800 (PST) Received: from localhost ([104.245.96.202]) by smtp.gmail.com with ESMTPSA id y15sm1805947eda.13.2021.12.08.00.33.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 00:33:41 -0800 (PST) From: Leo Yan To: "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 , 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 v2 6/7] audit: Use task_is_in_init_pid_ns() Date: Wed, 8 Dec 2021 16:33:19 +0800 Message-Id: <20211208083320.472503-7-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211208083320.472503-1-leo.yan@linaro.org> References: <20211208083320.472503-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-20211208_003342_981172_C8F66F53 X-CRM114-Status: GOOD ( 12.30 ) 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 code with task_is_in_init_pid_ns() for checking root PID namespace. Signed-off-by: Leo Yan Acked-by: Balbir Singh Acked-by: Paul Moore Reviewed-by: Richard Guy Briggs --- kernel/audit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/audit.c b/kernel/audit.c index 121d37e700a6..56ea91014180 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_init_pid_ns(current)) return -EPERM; if (!netlink_capable(skb, CAP_AUDIT_CONTROL)) From patchwork Wed Dec 8 08:33:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 12695302 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 58A92C433EF for ; Wed, 8 Dec 2021 08:36:53 +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=Jwflx5l3G455OMryTYDmfYdfoDPZBFkDX9VRrzQk7GY=; b=CSPFBgK2vQ2m59 iUoIVgYnJRpbx+qFyB7PyQ5ne6kvDAlvyRbpcHUz5k45Z1tdr4WeFip0YtvPuGkF1Qs4g8u5H128a 0sBecH4fNVfpuhQsXWl4noNBdMFj9YuqeXfd9A2YL2y+u9OvsknL7OJeumgySrUsCBCIH8mVuRBDd x6Fo0cy2Gr11tu0C8rlHkwh0CeerL9keqaV9dNRhaKX/XIiP+ptAyqEDsYVrU8MmvrdwEvVJsVXPW QNONLlYXrdMCb7wzCoNAidKzIimDpJBk98MvGiZBxZzmd6nmDYlWV+2+67SCWWEDGPohV/vTrxjsJ Nk97HNSKqIVb6l99UFag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1musQ6-00Bim9-Dp; Wed, 08 Dec 2021 08:35:22 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1musOY-00Bi4z-Bp for linux-arm-kernel@lists.infradead.org; Wed, 08 Dec 2021 08:33:47 +0000 Received: by mail-ed1-x531.google.com with SMTP id y12so5641265eda.12 for ; Wed, 08 Dec 2021 00:33: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=M/eeez3BcNi8tVHbYa2oBkvP6t/vK4B43HUQensSi3k=; b=Orp+rG52g6tM3+l/drNhrh6yzPRKPWZcTew2ozeopfwXTy+KpnrLnl684tWf9cNuId 90kmKsM3VRgMXWqcqdESh5J1AGweiDOXeVoQTaQS48SQ9Wry/FVDCuCK/RT/pbO9Yob/ rYfqQQycRbfrii9WQHGS+mEoTkl/Pm0Tfsv/OvzNw9fNjzIwVW42i+23ej2a7xId11CY glJ9F28NR3du8wtSsiCXLBpv8IGoJzuKkyjVSUsucqtdae/j7C0GaWmXZErgIOlHL9cD +Lqevqy4d/UggetMCsYR27VuZdjK35h10UgFe32dZVb00Uc1/SdZP8CLdokKIY/Etzwk Uhpw== 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=M/eeez3BcNi8tVHbYa2oBkvP6t/vK4B43HUQensSi3k=; b=tt8i7fxEc8Qdt9lAJlW+0zX0mXk9Qb85KhLIUlrL23HkqoovGfJOaJxnJpmu4BndUd aKpif8KWJwPdlvYlzUJdfvhaKmZJCwG96eRDU4K2COPY5Gw7mHliDGgWDur/bMDEYf/4 1syHndGGsI4Uq4oJ0zZtXYIkqw4mNkYILcyD3ZuIuI4xwxcQPOC2r/wbRS5RtR4jzc+G Fhheq2xmbMo3mpITjO4vF96LI2FO7h5aZg1jPmAE7a6wHMbon3Y0IlmQ/X/2MCu41uFj VX+lm9VpJlt0H+ZxkSGvZeL7LNzaQ6mCAOcVF6DFB73neRQ7S79uoIgUinYG52buFMB+ WnTQ== X-Gm-Message-State: AOAM531bZY7uf4Ac1OK+bJqgyMN0XoxhRK4MQYxRcmN7dD1J5NBq+UAX Pij9Q2y98z/65MFYrR8Cx0AtAg== X-Google-Smtp-Source: ABdhPJx1gsuPUNsaXFXbyVaebM4oFOMmmWAz5pvxHoEHLYLkpCRym4tCyOQ0c/34zl8r1AV4FxeNkQ== X-Received: by 2002:a05:6402:3496:: with SMTP id v22mr16781811edc.177.1638952424146; Wed, 08 Dec 2021 00:33:44 -0800 (PST) Received: from localhost ([104.245.96.202]) by smtp.gmail.com with ESMTPSA id h10sm1472866edr.95.2021.12.08.00.33.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 00:33:43 -0800 (PST) From: Leo Yan To: "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 , 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 v2 7/7] taskstats: Use task_is_in_init_pid_ns() Date: Wed, 8 Dec 2021 16:33:20 +0800 Message-Id: <20211208083320.472503-8-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211208083320.472503-1-leo.yan@linaro.org> References: <20211208083320.472503-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-20211208_003346_430125_11F8537B X-CRM114-Status: GOOD ( 12.19 ) 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 code with task_is_in_init_pid_ns() for checking root PID namespace. Signed-off-by: Leo Yan Acked-by: Balbir Singh --- kernel/taskstats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/taskstats.c b/kernel/taskstats.c index 2b4898b4752e..f570d8e1f001 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_init_pid_ns(current)) return -EINVAL; if (isadd == REGISTER) {