Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1575146lqa; Mon, 29 Apr 2024 12:20:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW8zJpN12acSuhHMRAxjqHTurQbqv0vh6QzimK0qCegx720zD5CvrgYbd2Mpev4tSeegalD1hbFDQ4fJBkNfEVRbVhAT8c1mauTGqClaw== X-Google-Smtp-Source: AGHT+IHmK81i/rMSbK57cAqYJEuKWf2gTwnmeyuNhhX0YdY8RUywy6TN9QlYQKkMBXs2dXc4vu/v X-Received: by 2002:a05:6808:306:b0:3c6:f52:2f77 with SMTP id i6-20020a056808030600b003c60f522f77mr779962oie.18.1714418425875; Mon, 29 Apr 2024 12:20:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714418425; cv=pass; d=google.com; s=arc-20160816; b=OR8b84f9ncqfb2JoRwPBuQb/+sRw77/QMDW1sEy7S7i3IslBEqwknHpFlqF5rEIG3Q kR/V5GYW6FIeTwOTV4gTP/1YcH05tEGcPGzzJu0+xQ5uO0Xg/iE1dfe3v5c2+JZmnnTn wXbbLPTOQqb1ntJruO9WkylIieZMTJ/k6frJLE7IOJ88qgbUAPVpk1EkMm8ZF9Hg54Sn aHRZ15gPm3T2LrHYcAx6fYFdElpUWE53gdlSDENN/KmmFGCztczCQg65M8xM+mWNZEVp Sdh1coc8EjE/6BoEagH2e/araweNQJa5jKNwPNzrq64B7/CVBSy7B8IDH+eGzDYBBiKP 1hyw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=p33s5p5Vdy5r1eVN6RRq4XHyqSpcvZwSK3xeG2QQOy8=; fh=T/ngxZ/rchirObc+ozpAMGxUCKvTk1uHXxRS2gfk1OI=; b=N++0Smkm+fSrkwEIT02AFx/wKcbxcsSdusQ2MwXC3xg0/Oe4vRg+LXEH/jtXvrvQ++ /Qhss2q6n/Ab/d2cTwLvV9VF+LdtQxG0FTsACcsCI01132BpkCV02pxUFJKs7iEnqs3M E8E1Y+JM/DdbGxBVO14iM/9XWXwqDGmmoTlEHQiYVcrCyixhrNozOf+rCdspGVZ5F4fZ F28r5qfzZ+vtF6CW0fAUX+nb/Nz9KUx4fBQ/4IqMFE+2pPTdV3AMf49GL9WJCJ+Q7c5p HuCQfKSyTvlDNIMxisHCmg9QbGXBfo+0kLJu8QLdO3ix5MZRffq9WIdwZ1ZQ3V/or+TD cpFQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=NG0VA6yD; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-162903-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162903-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id k5-20020ad45be5000000b006a0ab21fd16si9149570qvc.484.2024.04.29.12.20.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 12:20:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162903-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=NG0VA6yD; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-162903-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162903-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9327B1C216BF for ; Mon, 29 Apr 2024 19:20:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 71F8E13C83B; Mon, 29 Apr 2024 19:19:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="NG0VA6yD" Received: from smtp-8fad.mail.infomaniak.ch (smtp-8fad.mail.infomaniak.ch [83.166.143.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA0A313BC08 for ; Mon, 29 Apr 2024 19:19:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.166.143.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714418366; cv=none; b=QbW0H/PHfy7Dc9ZxyEA3EuHPaOR8sEfYcaNtCdI8Os0/25ZNJpwuMAH4erHKOpWte7/QMqGICqyeJPXd4mDvewQcbeqYDv0fkECHkGOhxj8YpZs17kAkKuXoqkMFRRnw0OdXYsZfWEOIok+C2hAYnEtZZRwcKr1CV1GTMrNoC64= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714418366; c=relaxed/simple; bh=uDMj38+fL//L5yXMbT+YKMkWgL3txmOHkNUEy1Src38=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kvdIq7XYLWKU7m4sb+I86wgOUVChix/f7G+Lg+flEUC8O3vvLhXTbN4aQymDTNKTddYrOoi62/YF0YawxTBMpI3dIYpzRniDeXNbblF+LUxyrT4GrCqOic0mBFoxV4y0GiVCrrrQVJT//QE+KjlVAyCLf5M1I0a9aFPtTDFyFuM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b=NG0VA6yD; arc=none smtp.client-ip=83.166.143.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Received: from smtp-4-0000.mail.infomaniak.ch (smtp-4-0000.mail.infomaniak.ch [10.7.10.107]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4VStRm02zKz8B1; Mon, 29 Apr 2024 21:19:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1714418355; bh=uDMj38+fL//L5yXMbT+YKMkWgL3txmOHkNUEy1Src38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NG0VA6yDH70vKIGbabyBzpOFaTyb+OLMmYsrq2HFfce/EkAm6Pt5BX1UXPUc+NSAt KtIh0UiqAn0NL6foL4vQSwg84s4pFseDRAoagonAgB9iRkEEElLUghoIx8QXiUpVeP t87PZ7uuRC3y1OzKw3Q6hQXLnMm9e3WqJr2a1bk4= Received: from unknown by smtp-4-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4VStRl2sCQzF8Z; Mon, 29 Apr 2024 21:19:15 +0200 (CEST) From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: Christian Brauner , Jakub Kicinski , Kees Cook , Mark Brown , Shengyu Li , Shuah Khan Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , "David S . Miller" , =?UTF-8?q?G=C3=BCnther=20Noack?= , Will Drewry , kernel test robot , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan Subject: [PATCH v3 2/9] selftests/landlock: Fix FS tests when run on a private mount point Date: Mon, 29 Apr 2024 21:19:04 +0200 Message-ID: <20240429191911.2552580-3-mic@digikod.net> In-Reply-To: <20240429191911.2552580-1-mic@digikod.net> References: <20240429191911.2552580-1-mic@digikod.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Infomaniak-Routing: alpha According to the test environment, the mount point of the test's working directory may be shared or not, which changes the visibility of the nested "tmp" mount point for the test's parent process calling umount("tmp"). This was spotted while running tests in containers [1], where mount points are private. Cc: Günther Noack Cc: Shuah Khan Link: https://github.com/landlock-lsm/landlock-test-tools/pull/4 [1] Fixes: 41cca0542d7c ("selftests/harness: Fix TEST_F()'s vfork handling") Reviewed-by: Kees Cook Signed-off-by: Mickaël Salaün Link: https://lore.kernel.org/r/20240429191911.2552580-3-mic@digikod.net --- Changes since v1: * Update commit description. --- tools/testing/selftests/landlock/fs_test.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/selftests/landlock/fs_test.c index 9a6036fbf289..46b9effd53e4 100644 --- a/tools/testing/selftests/landlock/fs_test.c +++ b/tools/testing/selftests/landlock/fs_test.c @@ -293,7 +293,15 @@ static void prepare_layout(struct __test_metadata *const _metadata) static void cleanup_layout(struct __test_metadata *const _metadata) { set_cap(_metadata, CAP_SYS_ADMIN); - EXPECT_EQ(0, umount(TMP_DIR)); + if (umount(TMP_DIR)) { + /* + * According to the test environment, the mount point of the + * current directory may be shared or not, which changes the + * visibility of the nested TMP_DIR mount point for the test's + * parent process doing this cleanup. + */ + ASSERT_EQ(EINVAL, errno); + } clear_cap(_metadata, CAP_SYS_ADMIN); EXPECT_EQ(0, remove_path(TMP_DIR)); } -- 2.44.0