Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3654815pxb; Mon, 24 Jan 2022 14:33:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIUX+lR3hp8YLqY6Khs/0HyGuiN+mTy+KwTkphWAalrLkP/SFsC7VVw4DKtAYJH8bQoKGd X-Received: by 2002:a17:902:8345:b0:14b:6f0a:337d with SMTP id z5-20020a170902834500b0014b6f0a337dmr1365864pln.112.1643063471656; Mon, 24 Jan 2022 14:31:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643063471; cv=none; d=google.com; s=arc-20160816; b=x6hmMGZ9ZkgCpFAutp57x91+Z+3EKJq9XBo8kUvmBp8wuVAm25iCMWUIHFK6lRCb9s aMuG9CbQKN29Uwa0ZUAfu9IKAk2EafPOZpQ0WrswOwRolB7JMssjJykGz2/iIMbp6UiH 3d5d8nHHkmywzYoZw6QEt8vSCvChdcDIxGBut8fMuK1SADRjKhBDl3rWA2P3lB0D4yom 4PAxXd9huSimLGshcYwOlaJ3HECUmJyESy+A3qchVQBl84FXlew9xB/RnEUxtE52kuP6 ITWeJYsNLmbYXEE1Zq4TelPgx8n2La81v6gvDnkym4FTWqC774DCpTGjR4Vjkcr9/N/1 kjIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZCfO1z6WEqMBBKzewMYlzKxRRA1/Dpekw9b4pJ/QFMQ=; b=Dyve9HP1g1zucNsD3C/EgjiQj7yljSGcupf9VPobwhwWBL1M+01sKSComZ1b6k9/dn 8hdclm5b+3UEA3d9ZjjKr2kup02RpZQw/m/fm+hrYpypvgDB894d5AQAAUvesTi3UXMG 1aWk9BMwDb3Diqb92JrNXjmpGjIExAe10JEfKhVKGja0VUvml22kk4yR1DigF80QTGdH mEG7g6hhn2h1FaErJlkAB+crJ66N/aRRddoS8aEnYtWhnx4uPK2wOImNtGgCx7wRyLKi W5SBLhdtOqPt9y5dtUJ2szPLH+rdunC2fWkcruuS3sQLmZaMZcD4R98xl8lxAcWp3AlI xYcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NJqCFMmO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k25si15206616pgi.402.2022.01.24.14.30.59; Mon, 24 Jan 2022 14:31:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NJqCFMmO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1586145AbiAXWZq (ORCPT + 99 others); Mon, 24 Jan 2022 17:25:46 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:49604 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1453214AbiAXV26 (ORCPT ); Mon, 24 Jan 2022 16:28:58 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 320A9614DE; Mon, 24 Jan 2022 21:28:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EA39C33E60; Mon, 24 Jan 2022 21:28:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059736; bh=UD6Ht1hPoWlejkDH/Gzpu/erG3jhCpBQYjkRtuiDRoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NJqCFMmOABegN9HEYI4t/yZsW+cN3L/BxVaPY51UuS2I2CHL7Rw0S8SQJLS5TMhy/ omJSs6u29xr6bEvLFbi/or4bOqPXEIwllvJ+ObgIi627XlrxwXlMkt/idPapmLEdTr wnaspKGZW9HxYp11JGYqX9LezvEG37WnAwie6/Dg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hangbin Liu , Jiri Olsa , Daniel Borkmann , Jussi Maki , Sasha Levin Subject: [PATCH 5.16 0716/1039] bpf/selftests: Fix namespace mount setup in tc_redirect Date: Mon, 24 Jan 2022 19:41:45 +0100 Message-Id: <20220124184149.401200286@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Olsa [ Upstream commit 5e22dd18626726028a93ff1350a8a71a00fd843d ] The tc_redirect umounts /sys in the new namespace, which can be mounted as shared and cause global umount. The lazy umount also takes down mounted trees under /sys like debugfs, which won't be available after sysfs mounts again and could cause fails in other tests. # cat /proc/self/mountinfo | grep debugfs 34 23 0:7 / /sys/kernel/debug rw,nosuid,nodev,noexec,relatime shared:14 - debugfs debugfs rw # cat /proc/self/mountinfo | grep sysfs 23 86 0:22 / /sys rw,nosuid,nodev,noexec,relatime shared:2 - sysfs sysfs rw # mount | grep debugfs debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec,relatime) # ./test_progs -t tc_redirect #164 tc_redirect:OK Summary: 1/4 PASSED, 0 SKIPPED, 0 FAILED # mount | grep debugfs # cat /proc/self/mountinfo | grep debugfs # cat /proc/self/mountinfo | grep sysfs 25 86 0:22 / /sys rw,relatime shared:2 - sysfs sysfs rw Making the sysfs private under the new namespace so the umount won't trigger the global sysfs umount. Reported-by: Hangbin Liu Signed-off-by: Jiri Olsa Signed-off-by: Daniel Borkmann Cc: Jussi Maki Link: https://lore.kernel.org/bpf/20220104121030.138216-1-jolsa@kernel.org Signed-off-by: Sasha Levin --- tools/testing/selftests/bpf/prog_tests/tc_redirect.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c index 4b18b73df10b6..c2426df58e172 100644 --- a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c +++ b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c @@ -105,6 +105,13 @@ static int setns_by_fd(int nsfd) if (!ASSERT_OK(err, "unshare")) return err; + /* Make our /sys mount private, so the following umount won't + * trigger the global umount in case it's shared. + */ + err = mount("none", "/sys", NULL, MS_PRIVATE, NULL); + if (!ASSERT_OK(err, "remount private /sys")) + return err; + err = umount2("/sys", MNT_DETACH); if (!ASSERT_OK(err, "umount2 /sys")) return err; -- 2.34.1