Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1651853pxf; Fri, 19 Mar 2021 12:07:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4TaH62YOCtcKV6PiU04eYlrchhJJk9rhgBgW/7gWtL54exM5sKmyO8v2JndmzK1P8lyto X-Received: by 2002:aa7:c14a:: with SMTP id r10mr10965851edp.132.1616180824018; Fri, 19 Mar 2021 12:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616180824; cv=none; d=google.com; s=arc-20160816; b=FfsZ8EGws3IqjGb1G2bCA4XZKbkRt3ESwdD1tNA4Sf3nv1UaA6RgeJ6L408VYN3L/K FDSwvD9KYFDkfEQNBH3YoeclP28fPGlLLAK1A9F+wIPr9WlAP4jBuOgYfK6qmfbASLy6 TuthtdVquJ6Bk5YbSlJTw0MoC9Pp13P/cfnN1+VyqjL4QqU1gA90yNJY1aByZRgpeddn feUt13uMPoQy8IfFslLuX8r83mwYq3MrTPUCULKu2p2rvndy5cBwK91WWRRzCVF7ACCu 7Wn/un01oJ6ay0zk6Ywj82x9ACuUnE35Sz6mEVLs3xpGWDS/28b0lv6C+g1JmpTiqw7n i7uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=4LnsBn4Z0RC/NkbWt3ktkK7x7L/M6wLEd0V4DT9qTM4=; b=W0hZhxhoLwwuSUSQrryRTBOh0eWdyytLDIyl3GQprJLJ3BKrOg4/M0gUZkk4FonqEW d61qfNdlGrj4SthUqA2qVtlhvVNTcptwwG6xCzmcqocWYbTwgeyz0C8b9PPr1rGZgW4c /VRLZQ8PsJfLWJU3+dWYpFYXfjbENSiWLoxfIF6yRTaSW74nN52nZLpBk5PTFEnLOm13 guQTSMjLVMaEBecQwe+Q/1tj5RPt+V806NojF6vNZzkDsTRA4khqqDntRkJoDZKap91j 3YxaorhD6BP/+HdB8M3rYl+ucHelObZ5NOhbec13cyikitS6LqUNqBxKNpyxQEPN2ngb DoSw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fl2si4677961ejc.666.2021.03.19.12.06.40; Fri, 19 Mar 2021 12:07:04 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230348AbhCSTDW (ORCPT + 99 others); Fri, 19 Mar 2021 15:03:22 -0400 Received: from smtp-bc0d.mail.infomaniak.ch ([45.157.188.13]:47187 "EHLO smtp-bc0d.mail.infomaniak.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230335AbhCSTDM (ORCPT ); Fri, 19 Mar 2021 15:03:12 -0400 Received: from smtp-3-0001.mail.infomaniak.ch (unknown [10.4.36.108]) by smtp-2-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4F2Cvy58JSzMqrNj; Fri, 19 Mar 2021 20:03:10 +0100 (CET) Received: from ns3096276.ip-94-23-54.eu (unknown [23.97.221.149]) by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4F2Cvt0cSqzlh8T3; Fri, 19 Mar 2021 20:03:06 +0100 (CET) Subject: Re: [PATCH v30 02/12] landlock: Add ruleset and domain management To: Kees Cook Cc: James Morris , Jann Horn , "Serge E . Hallyn" , Al Viro , Andrew Morton , Andy Lutomirski , Anton Ivanov , Arnd Bergmann , Casey Schaufler , David Howells , Jeff Dike , Jonathan Corbet , Michael Kerrisk , Richard Weinberger , Shuah Khan , Vincent Dagonneau , kernel-hardening@lists.openwall.com, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-security-module@vger.kernel.org, x86@kernel.org, =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= References: <20210316204252.427806-1-mic@digikod.net> <20210316204252.427806-3-mic@digikod.net> <202103191114.C87C5E2B69@keescook> From: =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= Message-ID: Date: Fri, 19 Mar 2021 20:03:22 +0100 User-Agent: MIME-Version: 1.0 In-Reply-To: <202103191114.C87C5E2B69@keescook> Content-Type: text/plain; charset=iso-8859-15 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19/03/2021 19:40, Kees Cook wrote: > On Tue, Mar 16, 2021 at 09:42:42PM +0100, Micka?l Sala?n wrote: >> From: Micka?l Sala?n >> >> A Landlock ruleset is mainly a red-black tree with Landlock rules as >> nodes. This enables quick update and lookup to match a requested >> access, e.g. to a file. A ruleset is usable through a dedicated file >> descriptor (cf. following commit implementing syscalls) which enables a >> process to create and populate a ruleset with new rules. >> >> A domain is a ruleset tied to a set of processes. This group of rules >> defines the security policy enforced on these processes and their future >> children. A domain can transition to a new domain which is the >> intersection of all its constraints and those of a ruleset provided by >> the current process. This modification only impact the current process. >> This means that a process can only gain more constraints (i.e. lose >> accesses) over time. >> >> Cc: James Morris >> Cc: Jann Horn >> Cc: Kees Cook >> Signed-off-by: Micka?l Sala?n >> Acked-by: Serge Hallyn >> Link: https://lore.kernel.org/r/20210316204252.427806-3-mic@digikod.net > > (Aside: you appear to be self-adding your Link: tags -- AIUI, this is > normally done by whoever pulls your series. I've only seen Link: tags > added when needing to refer to something else not included in the > series.) It is an insurance to not lose history. :) > >> [...] >> +static void put_rule(struct landlock_rule *const rule) >> +{ >> + might_sleep(); >> + if (!rule) >> + return; >> + landlock_put_object(rule->object); >> + kfree(rule); >> +} > > I'd expect this to be named "release" rather than "put" since it doesn't > do any lifetime reference counting. It does decrement rule->object->usage . > >> +static void build_check_ruleset(void) >> +{ >> + const struct landlock_ruleset ruleset = { >> + .num_rules = ~0, >> + .num_layers = ~0, >> + }; >> + >> + BUILD_BUG_ON(ruleset.num_rules < LANDLOCK_MAX_NUM_RULES); >> + BUILD_BUG_ON(ruleset.num_layers < LANDLOCK_MAX_NUM_LAYERS); >> +} > > This is checking that the largest possible stored value is correctly > within the LANDLOCK_MAX_* macro value? Yes, there is builtin checks for all Landlock limits. > >> [...] > > The locking all looks right, and given your test coverage and syzkaller > work, it's hard for me to think of ways to prove it out any better. :) Thanks! > > Reviewed-by: Kees Cook > >