Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp617164pxb; Tue, 3 Nov 2020 08:08:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwlS7qk0b31hyx2tvtQ+60GadyNg8qTN7OA9yWC2or1K0fLD8tSODNE+Nxesto0akuOfGdW X-Received: by 2002:a17:906:3782:: with SMTP id n2mr16773912ejc.493.1604419680793; Tue, 03 Nov 2020 08:08:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604419680; cv=none; d=google.com; s=arc-20160816; b=DNPdknne+HK1Os0mwi/pgfj54ebilokdMEzs/RAs9n9Hj3oOiQat8mflkH9/+scKp4 rsRkNu/E2GiGW9bPDUiEieyljijKKqxAvjGiXQguIQDnWRhiFYmZRZlblJrny3RtcoVS fH/awnZdWIMx+uta3vfDwnsu+fLKFAfklZO3Kl5lR9SVLkbf1WBRfDYCqARshG11frNq IAeBg9/uWdqifIT27rpAW3e4mXtS+ek0JmeO84RtwGn/oRoPrSuakBo0O8ocRw8CX//L C2W+la8/BvGHnDaLjXeHHD7ZwxWRlLnJxvw/w2psc66DWrmwAvhSkM4OCxfrBv8I+0mb ZcxQ== 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=dbqc131nxfdVzu0O0e6bKJqnXRF3NrwZpzF/KFcrgC4=; b=f5mjWE64kyWko4HzI90674ynMzEPql2Yv2jUxPk60fRyjsbuXDIC4wQEbYbKuyYOyQ jIqxqECpvz1VoVtS8EjsN3naxI1AHY43OiBv6d7A8wSx7cFw0RyJ9ZlGxpnTJc6H6b0r RRF/CIJdyyj/2RFMTwfVC6DvychWc4gb6IztavzIIAfXlO7KGtTQ5sOI3zmnfOZ5J0aM aRh3dsNctb0pk0IjZbUy3cz/Y7WSokKcb0mrKNmRg44DSguOu5QqpL53A9/Hyv6O5ekw ulCiXUR48fTYUSpc/mAzyf2QT6Xqv8nP/v6Szb82VZoDj4hFnOoR3g65dp7y6ua5AvHF itsQ== 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 h10si14138088edn.193.2020.11.03.08.07.36; Tue, 03 Nov 2020 08:08:00 -0800 (PST) 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 S1728274AbgKCQDv (ORCPT + 99 others); Tue, 3 Nov 2020 11:03:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727743AbgKCQDv (ORCPT ); Tue, 3 Nov 2020 11:03:51 -0500 Received: from smtp-bc0e.mail.infomaniak.ch (smtp-bc0e.mail.infomaniak.ch [IPv6:2001:1600:4:17::bc0e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5B5EC0617A6 for ; Tue, 3 Nov 2020 08:03:50 -0800 (PST) Received: from smtp-3-0000.mail.infomaniak.ch (unknown [10.4.36.107]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4CQZMm1C8kzlhqv5; Tue, 3 Nov 2020 17:03:48 +0100 (CET) Received: from ns3096276.ip-94-23-54.eu (unknown [94.23.54.103]) by smtp-3-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4CQZMk0bzXzlh8TS; Tue, 3 Nov 2020 17:03:46 +0100 (CET) Subject: Re: [PATCH v22 07/12] landlock: Support filesystem access-control To: Jann Horn Cc: James Morris , "Serge E . Hallyn" , Al Viro , Andy Lutomirski , Anton Ivanov , Arnd Bergmann , Casey Schaufler , Jeff Dike , Jonathan Corbet , Kees Cook , Michael Kerrisk , Richard Weinberger , Shuah Khan , Vincent Dagonneau , Kernel Hardening , Linux API , linux-arch , "open list:DOCUMENTATION" , linux-fsdevel , kernel list , "open list:KERNEL SELFTEST FRAMEWORK" , linux-security-module , the arch/x86 maintainers , =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= References: <20201027200358.557003-1-mic@digikod.net> <20201027200358.557003-8-mic@digikod.net> From: =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= Message-ID: <056d8f1a-b45f-379f-d81a-8c13a1536c3f@digikod.net> Date: Tue, 3 Nov 2020 17:03:45 +0100 User-Agent: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/10/2020 02:06, Jann Horn wrote: > (On Tue, Oct 27, 2020 at 9:04 PM Mickaël Salaün wrote: >> diff --git a/security/landlock/fs.c b/security/landlock/fs.c > [...] >> +static inline u32 get_file_access(const struct file *const file) >> +{ >> + u32 access = 0; >> + >> + if (file->f_mode & FMODE_READ) { >> + /* A directory can only be opened in read mode. */ >> + if (S_ISDIR(file_inode(file)->i_mode)) >> + return LANDLOCK_ACCESS_FS_READ_DIR; >> + access = LANDLOCK_ACCESS_FS_READ_FILE; >> + } >> + /* >> + * A LANDLOCK_ACCESS_FS_APPEND could be added but we also need to check >> + * fcntl(2). >> + */ > > Once https://lore.kernel.org/linux-api/20200831153207.GO3265@brightrain.aerifal.cx/ > lands, pwritev2() with RWF_NOAPPEND will also be problematic for > classifying "write" vs "append"; you may want to include that in the > comment. (Or delete the comment.) Contrary to fcntl(2), pwritev2(2) doesn't seems to modify the file description. Otherwise, other LSMs would need to be patched. I'll remove this comment anyway. > >> + if (file->f_mode & FMODE_WRITE) >> + access |= LANDLOCK_ACCESS_FS_WRITE_FILE; >> + /* __FMODE_EXEC is indeed part of f_flags, not f_mode. */ >> + if (file->f_flags & __FMODE_EXEC) >> + access |= LANDLOCK_ACCESS_FS_EXECUTE; >> + return access; >> +} > [...] >