Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4822630iob; Mon, 9 May 2022 02:26:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyhcjIVJCIVCs5IyouTdwsHyhHhchAaVJKNg2HtduB4q5WGRppqg0incpTDg1ENMF4t3nv X-Received: by 2002:a05:6a00:1950:b0:510:739f:a32c with SMTP id s16-20020a056a00195000b00510739fa32cmr15069067pfk.77.1652088363945; Mon, 09 May 2022 02:26:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652088363; cv=none; d=google.com; s=arc-20160816; b=Lq/BW8OkS5LYGN3/H5B0TSvWt+i7XUqsSoiSq6WBQVQ7OaP63knS0xFe+DUUMe7Mb8 96XM8vx/Kkmx5lraXn5UQ7roecV3zBVpCyYnJjRfrFEH016FkNo4s5qNzA3+ZskS4DVQ Fpmc4o0q78xHQWgfAjpHenzxz/NXP8T8zi62ltUjcA87Ydx5iPWB4opQckVEYbtJBiPZ n9s6sU1XtdGWaJw74ntPUITWJ46/YAq4bGmNLfOrgimGSj0oWGFVmHPZIfmT/uZ7IfBe ABIn7qhmPxHQchHz+tGN0llIjenyk+RgHw8Z8x5yjHWA7zcVWaTrPjiFHimbBYQbF2QN 1wCw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OrPWB3aVYu8jWNPDpP5RHRy9nh//tsXlZ1dVuVYD45o=; b=p0EzXvF+HyZxsvUmFAMHC0Hn2kZVUpVBGxIeYbB3A1200yQ96rJUyabb0t81jlClwH w+8gTBKRP18rfbWYJBKjBRRdqtBMidhIWg6USVJB6dHcNsRvclYeZSbApEHHuksBqrRS q41yQzr8StGCFgCJWtAKPHPmyh/b+YOBFs4OQW8Mbwp3SZDJBniL3+0GeDn0zi2oErye s5aQr9ZFhOZaml+MzultcnzwG6phW52/XJkIKyvGF3MG+l78xydTQbprHwE8CL4/5/QG PeNC3fI0LfvOxnBPauy3ELV99Lly75JBN3Z2zpO+tISD8ebzNmpY+ZlX1xGak/fMBiTY F1qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=K7yCdbht; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id c3-20020a170902f30300b0015e999a2404si9560813ple.350.2022.05.09.02.26.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 02:26:03 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=K7yCdbht; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E368B26D6; Mon, 9 May 2022 02:15:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443497AbiEFQLD (ORCPT + 99 others); Fri, 6 May 2022 12:11:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443442AbiEFQKs (ORCPT ); Fri, 6 May 2022 12:10:48 -0400 Received: from smtp-42a9.mail.infomaniak.ch (smtp-42a9.mail.infomaniak.ch [IPv6:2001:1600:3:17::42a9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1CD156C0D for ; Fri, 6 May 2022 09:07:01 -0700 (PDT) Received: from smtp-3-0001.mail.infomaniak.ch (unknown [10.4.36.108]) by smtp-2-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4KvwS41jJtzMr2ZJ; Fri, 6 May 2022 18:07:00 +0200 (CEST) Received: from localhost (unknown [23.97.221.149]) by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4KvwS36zpTzlhMC1; Fri, 6 May 2022 18:06:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1651853220; bh=kL99cMtumD1QSIju+JYUr1ezJx54p7MQnxDHvS0ug5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K7yCdbhtnjRe+nxPNSrDCHTy9c7mQejcD3NxaH0m24ixTY2jesKdu4jlM9gqw6y9A kvHQR81mVeCaee/gP/xcdmCOXwKTZ3wfamX9O6Z2uZCyIsbdXaIRPfzQhPQ5eURt+O FQ4QVth19fHjMTsFAGQFXPRi+b8KzQWeQ1b5nv9c= From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: James Morris , "Serge E . Hallyn" Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Jann Horn , Kees Cook , Konstantin Meskhidze , Nathan Chancellor , Nick Desaulniers , Paul Moore , Shuah Khan , linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH v2 04/10] selftests/landlock: Add tests for unknown access rights Date: Fri, 6 May 2022 18:08:14 +0200 Message-Id: <20220506160820.524344-5-mic@digikod.net> In-Reply-To: <20220506160820.524344-1-mic@digikod.net> References: <20220506160820.524344-1-mic@digikod.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,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=no 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 Make sure that trying to use unknown access rights returns an error. Cc: Shuah Khan Signed-off-by: Mickaël Salaün Link: https://lore.kernel.org/r/20220506160820.524344-5-mic@digikod.net --- Changes since v1: * Format with clang-format and rebase. --- tools/testing/selftests/landlock/fs_test.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/selftests/landlock/fs_test.c index cc7fa7b17578..f293b7e2a1a7 100644 --- a/tools/testing/selftests/landlock/fs_test.c +++ b/tools/testing/selftests/landlock/fs_test.c @@ -448,6 +448,22 @@ TEST_F_FORK(layout1, file_access_rights) ASSERT_EQ(0, close(path_beneath.parent_fd)); } +TEST_F_FORK(layout1, unknown_access_rights) +{ + __u64 access_mask; + + for (access_mask = 1ULL << 63; access_mask != ACCESS_LAST; + access_mask >>= 1) { + struct landlock_ruleset_attr ruleset_attr = { + .handled_access_fs = access_mask, + }; + + ASSERT_EQ(-1, landlock_create_ruleset(&ruleset_attr, + sizeof(ruleset_attr), 0)); + ASSERT_EQ(EINVAL, errno); + } +} + static void add_path_beneath(struct __test_metadata *const _metadata, const int ruleset_fd, const __u64 allowed_access, const char *const path) -- 2.35.1