Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2197448iof; Tue, 7 Jun 2022 22:56:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDf5yqFQnxNbDgYLKnRx5cnrXX6MY8tnV/1oac6SwLIwTUqzH1ez16HbBkudld2eUKQFez X-Received: by 2002:a17:90a:be09:b0:1e8:a95c:3a40 with SMTP id a9-20020a17090abe0900b001e8a95c3a40mr6478277pjs.197.1654667795265; Tue, 07 Jun 2022 22:56:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654667795; cv=none; d=google.com; s=arc-20160816; b=hjoSvIxt4uMDi9SQg4dFLo28pnL96jjFhH+Xnc3TqFguv2EmcQkhR97cHPy0CqSN7W vcL1jQiZaVONDy4k0wY3u7/hD3egCQfoPb6/T258jZA1kf6p7JmxVilhxwkWCXJETWYh UW+1fjvfSKEtK0dfmgrwC8ElFmXBZ8cDoelljibV3fHCo2wyJVFjSeqlzj69rKsXObRV 6k1FBmvcAvPTLTmLLMV77n9zlbjtRePz8prSjrNqkw9uFhRziop+cNRo9SXhsYXGomx8 Yyb/+DiLEpbQJ+Q1JjOHR2YlKGbkgXG6iSFw5pedpZyMoGelS7HF4ZYsOIcTh3tcX/0T cZ1g== 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=cR1d43FD2NUGYAr3XTApNKniV1FdnrYnaFtooO9MoQg=; b=QiZnvtweJo+BN2w3uHUoS5wt2YhKNSIvX7U23kg/oXxY8osWtq8Fuuyxd9St8g4wZz QBzZh+mrb+OQXlZcJDh0ve4mRhA4BT/qfGy8aIxy3IFPTLYKhdcx6EhbgZV2g0TwOUi1 d3JdaPzT3wXYKjUy1qS7RhcQQt126hJBguRIqohhd4+jo6sjzJSmcgw4GJk0IpzSxvUE sG+7MfNEtMzTkzbWfXEXAkDhmXg79pvl3ZnS9yTAt4iaSqPemK+9TYQn38I55k6i+Keo FzHprxWZBit7AwlK4ea4YrbHAnEIuCKwN3wNIa5Ht73wkptoYp1MdBeMSG1khiPiUnDf OSXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vH4HMBRO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s76-20020a632c4f000000b003fbe1c24cd1si26493852pgs.684.2022.06.07.22.56.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:56:35 -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=@linuxfoundation.org header.s=korg header.b=vH4HMBRO; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DB22C4B176D; Tue, 7 Jun 2022 22:22:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443148AbiFHA5k (ORCPT + 99 others); Tue, 7 Jun 2022 20:57:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385395AbiFGWVg (ORCPT ); Tue, 7 Jun 2022 18:21:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D87B25696B; Tue, 7 Jun 2022 12:21:26 -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 74E2DB8233E; Tue, 7 Jun 2022 19:21:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA788C385A5; Tue, 7 Jun 2022 19:21:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629683; bh=a6TL4JGMCf1l+ghTXObmrd74SYUyO4vsE8A7pjANyUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vH4HMBROnKa3KtHPzjtwkwS2/ZV5jYqF1+ny9o+4in0ESgy98KP+WasEuq4Y2ov5f CzvoZuU2zso08QtdvR20eSYpGo0BgwvZV3eVFUdkRZinI2Is2INe/sd5WnroMporya OHz+I2JGjpcPc4jtWX4irNdJ5U2eirAExc2dQhU8= 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 780/879] selftests/landlock: Add tests for unknown access rights Date: Tue, 7 Jun 2022 19:04:58 +0200 Message-Id: <20220607165025.513081951@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 c56b3bf566da5a0dd3b58ad97a614b0928b06ebf upstream. Make sure that trying to use unknown access rights returns an error. Cc: Shuah Khan Link: https://lore.kernel.org/r/20220506160820.524344-5-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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) --- 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)