Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3677751pxb; Mon, 24 Jan 2022 15:07:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwpJ1F9uJIUXKorLb8YGq3+0GemtzXIXu4EBZ0q/FefuckesXRRSnTHzAcliBT3wsVpBQZL X-Received: by 2002:a65:56c6:: with SMTP id w6mr13426400pgs.1.1643065660939; Mon, 24 Jan 2022 15:07:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643065660; cv=none; d=google.com; s=arc-20160816; b=vVj0dTJ/mzUSEs94MSglZXDcOa/FPOjx+43ulhpil1yrPOCD5NHLLaU9439NvCGVav hqaLxXaAz9fTj2XpujYUZX6eyKuujcsgYUCf7N+0co6ZX2fdX1+8FMaxFgvMMDpfaH8N VHN/DZ6Wq1GMQCAwKJWdeCKcvDf9m5wOLhqMkDCiWCGB3SW75FEMYSs1lKpZTchU9r1W RwgLiv66T28qJ076OqrkAO+GFcgtSvGk0jUCivohMxiwyTXS9iLZNHJz42ElIkPy4daP xMDuAQWFt9uyjkpKmyUe0iR3/yzxTjl4bxMA0ClDQ5COoHlMTAlHt9dMoTA2MpajyOrW E6wA== 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=FA/RNAbktbOselHrXJE0mpBfJj1NX6tOFSAJJ2gGY+A=; b=f0aJr78ZSBA9wZI4LsAuaRi1GBQtJdwxSeqe78K2aszl5v+mLO/ArgrtB82XXSeL3Q rYMMNwPU2wkbZYSiGSEmWoAS6u1H9YoiEy7dVsdyoB5Ia5VTDh9LfVtyo3Ty3fTx7Rbo jfiLPEtJsZZV+Kko4zY+3ZxQImb48qLpC47cWMJ/TkjpvX1fLa09uiMGPsPOyRx++dyr ddOne8xf8xUjVq3UVtg4VKzwKyOrRcxbWWps0Pn2EW0xvybPBIWMqwG9UjCfPJ30Gzlf 4yw9w+3gnOlKCuVn9vrYXnA/RvsXRcr/rHGft69dCHH/GV/YtGnSRRto04np9LbUY9Uq +qVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aeVCzfIX; 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 k184si11553559pgd.727.2022.01.24.15.07.28; Mon, 24 Jan 2022 15:07:40 -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=aeVCzfIX; 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 S1843109AbiAXXDV (ORCPT + 99 others); Mon, 24 Jan 2022 18:03:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1577771AbiAXWBE (ORCPT ); Mon, 24 Jan 2022 17:01:04 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03170C02B8F7; Mon, 24 Jan 2022 12:40:10 -0800 (PST) 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 9466461542; Mon, 24 Jan 2022 20:40:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 652B6C340ED; Mon, 24 Jan 2022 20:40:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056809; bh=TElkjlzuCBV3Gc3JqGNMR1z/jwiZxTMPgmvaZtwLM8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aeVCzfIXdKwKxfkskB6/9LZu2DXY9g83p5QcEPuSuf+7WS2WFzdmWmoQKbXZhVOpp oSFlFSwaD78z6aTi3JBhyFj24cKiDaX6qE+zQFu4oR1Y5pj2bAfiWn/dB07QWEm9q1 XPK4abMrcJ2WVwTTDVCx/u4h2duLy6aGceltKOgg= 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.15 606/846] bpf/selftests: Fix namespace mount setup in tc_redirect Date: Mon, 24 Jan 2022 19:42:03 +0100 Message-Id: <20220124184121.927835297@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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 e7201ba29ccd6..47e3159729d21 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