Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2212949iof; Tue, 7 Jun 2022 23:23:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYauMQHASKjSFRzlVo5SqVI7n/RHS1nIlqC9Lo1THY/Ly6sAFMwf9gNm58PmMyyU/96rTk X-Received: by 2002:a17:90b:1a86:b0:1e8:2b80:5e07 with SMTP id ng6-20020a17090b1a8600b001e82b805e07mr29728940pjb.31.1654669387102; Tue, 07 Jun 2022 23:23:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654669387; cv=none; d=google.com; s=arc-20160816; b=lSAyn8uajqts0Y6MwZvCsbNCXZvTehGxH5f8IwHB6TL8BVvhSxLQIsowDPf0s1dyhm +REOHB1Ovf3ZkXUcDem7w5Tjo++Wn7djhdtwpVaJFbeFZkdxrPzLcM3t0kIwj7J7TNzE 8jl9bDToXM81AtJ2lREg+3QEg5tXWKkukeWCQeSwWxD2AnpPJ4NLNAuc1PyXPVjp0p4G sVYBsxXwEi7O9ydN/Q8oaUv3xhFbWyjw5J+CoVKQHFxXFkGnEGe4F54cZu8cIhmZF226 ZMGxWCUDjE6fVYNAhaN+Dwko99etz7fNQOT5JWxUtMFjiEA1yFFLoCoIuPfciyfjk8Pk GVYA== 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=p4nhPZshX4Cv98CwimFK6O9mVRWpJZRVR12d03l1Pyc=; b=d42vIOdxAclMZrxX7S3RBw3XKsAgN/diWrT0tMpxfZbZic5OQzurl/oUhIz+J1i/WB sqhyqJARQnqXRmKQYHHZwvEMl8I8Tgudu6jZ6XcCM6x7pNgh3KpAvIQykK9HEEjxIih0 5+BRUBxiuoxLc94eGR7DNVIXRu5bg/ePCzW2A2uXu1rgBqGnkkld5C4lyMdgz90w3u1w /lblOegTBPDg+2heAYRU+pmOmLEjEg9SEMhoWX8/XrFGnymey0hMHcyRpnklf2fwvxl1 1/wvVUBu4LkRlDgGJO6ji2//OqPLpiFvK7Yvek5fvvPUjuf5pza+c8/NsvgTo/P7tzcO cT6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="gQL19/RC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q187-20020a632ac4000000b003fdd8b44d24si8878253pgq.279.2022.06.07.23.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:23:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="gQL19/RC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 324343EB9C1; Tue, 7 Jun 2022 22:43:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1441989AbiFHCGI (ORCPT + 99 others); Tue, 7 Jun 2022 22:06:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1841781AbiFHAIO (ORCPT ); Tue, 7 Jun 2022 20:08:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 674E2267CE4; Tue, 7 Jun 2022 12:21:37 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 789FAB823CC; Tue, 7 Jun 2022 19:21:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEA7AC385A5; Tue, 7 Jun 2022 19:21:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629694; bh=GmrMzbqcZ2nl6Mbbuu93Fv32BUR3uWJx+cJ6lsJTsWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gQL19/RCxBR47po3oG7o7UK7viVmjQS+zR/PO0AbinNyLLX/i36rehHQJI6q1zmn7 TnCRgJJQQg0jBWMLSsLT+uT+ygsxImofP26Phc8XAHXSqIkZj70nxENiST0VjQS/Ho RbZn6N2Xk6Ron9mzw7qu782ijQANcxdUPbmX7E+s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shuah Khan , =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= Subject: [PATCH 5.18 783/879] selftests/landlock: Add tests for O_PATH Date: Tue, 7 Jun 2022 19:05:01 +0200 Message-Id: <20220607165025.597516138@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mickaël Salaün commit d1788ad990874734341b05ab8ccb6448c09c6422 upstream. The O_PATH flag is currently not handled by Landlock. Let's make sure this behavior will remain consistent with the same ruleset over time. Cc: Shuah Khan Link: https://lore.kernel.org/r/20220506160820.524344-8-mic@digikod.net Cc: stable@vger.kernel.org Signed-off-by: Mickaël Salaün Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/landlock/fs_test.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/tools/testing/selftests/landlock/fs_test.c +++ b/tools/testing/selftests/landlock/fs_test.c @@ -654,17 +654,23 @@ TEST_F_FORK(layout1, effective_access) enforce_ruleset(_metadata, ruleset_fd); ASSERT_EQ(0, close(ruleset_fd)); - /* Tests on a directory. */ + /* Tests on a directory (with or without O_PATH). */ ASSERT_EQ(EACCES, test_open("/", O_RDONLY)); + ASSERT_EQ(0, test_open("/", O_RDONLY | O_PATH)); ASSERT_EQ(EACCES, test_open(dir_s1d1, O_RDONLY)); + ASSERT_EQ(0, test_open(dir_s1d1, O_RDONLY | O_PATH)); ASSERT_EQ(EACCES, test_open(file1_s1d1, O_RDONLY)); + ASSERT_EQ(0, test_open(file1_s1d1, O_RDONLY | O_PATH)); + ASSERT_EQ(0, test_open(dir_s1d2, O_RDONLY)); ASSERT_EQ(0, test_open(file1_s1d2, O_RDONLY)); ASSERT_EQ(0, test_open(dir_s1d3, O_RDONLY)); ASSERT_EQ(0, test_open(file1_s1d3, O_RDONLY)); - /* Tests on a file. */ + /* Tests on a file (with or without O_PATH). */ ASSERT_EQ(EACCES, test_open(dir_s2d2, O_RDONLY)); + ASSERT_EQ(0, test_open(dir_s2d2, O_RDONLY | O_PATH)); + ASSERT_EQ(0, test_open(file1_s2d2, O_RDONLY)); /* Checks effective read and write actions. */