Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2619560pxm; Mon, 28 Feb 2022 02:51:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzMj3cBCqrZ1hW5X1xXpT8+gwnj3c05x56FhnadfwezggAJkrsrRAqwPpPctYo06CzfT+S0 X-Received: by 2002:aa7:8d0f:0:b0:4e1:31de:9080 with SMTP id j15-20020aa78d0f000000b004e131de9080mr21023232pfe.1.1646045467070; Mon, 28 Feb 2022 02:51:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646045467; cv=none; d=google.com; s=arc-20160816; b=j2k9jj5ZdwVkddkN8OfLtkBzYgqD0tX1AdaGx6x7XB0yQyYeCoEUz/FMxTcZUP4o+J Jq+CNIptT4EZ3cYcEiZTWKo8Ixv5fWbfNSpYtdTRXu/AEs1jvPgRCg5RpRyIAqOrlgjf CprweDBor0LsJLOQqxabMJbqSzfHEUakmEaP2qpa6x/Ojm2rQ0gE3wlb1cm6qap2FXYO M8o9+U8UxQ7yVtaPYVmeDr2J5QqAEkD10EpyV+YofVypa3OeMwozh8SQQB1NbG+r+7cS w8HNmUGpL1LWMMRc70hChbZEAF6rd+3KUiodzcVfj9Y4KgpxNvivRDFWtiUa8CUnLkLu 9vQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id; bh=drrFGaqXGY5YnAy79x4fL5lSAQrblmZDjbam0j4Zgo8=; b=pXWKwKTYtvEjV/ksB2ERL88Ao9HjxgJAgN0P8YBAVBYgqp0iWiIaDKgvTqPn4YXY6g wMqaauVGSgH1zQYlS6rz7B28w1Mj2qdlx+wzfvjOGgqkgTY4OZUbo1G9+oV0IHTx554h 4XjCG/UiSqlbOFGvwkF8RNcEoew33plR5nub/4x5VgVYXNIw6bOEqSDvWDhRymcV5FXa AixHHd7qJN1CZnQBaTO/wIVLiyT1OqamAvTcdWNAkDYeC98hGkHsJZA7n1gW45xkrVTO 2r1kKWnmxuLfFU7rxZj+4WT/ktrUi6HDayiNyI/ZhgPfmAR4AACU5mbRFm2IMovRgcxk ihBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x8-20020a63b208000000b0037885117ee6si4280360pge.408.2022.02.28.02.50.52; Mon, 28 Feb 2022 02:51:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233784AbiB1IAK (ORCPT + 99 others); Mon, 28 Feb 2022 03:00:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233785AbiB1IAH (ORCPT ); Mon, 28 Feb 2022 03:00:07 -0500 Received: from smtp-190a.mail.infomaniak.ch (smtp-190a.mail.infomaniak.ch [IPv6:2001:1600:4:17::190a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B00024FC66 for ; Sun, 27 Feb 2022 23:59:28 -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 4K6XpN2CGLzMq0qN; Mon, 28 Feb 2022 08:59:24 +0100 (CET) Received: from ns3096276.ip-94-23-54.eu (unknown [23.97.221.149]) by smtp-3-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4K6XpL1ZyHzljTgK; Mon, 28 Feb 2022 08:59:22 +0100 (CET) Message-ID: <274f63e6-ed9a-e49f-8779-6e4980f51b33@digikod.net> Date: Mon, 28 Feb 2022 08:59:39 +0100 MIME-Version: 1.0 User-Agent: Content-Language: en-US To: "Alejandro Colomar (man-pages)" , James Morris , "Serge E . Hallyn" Cc: 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, =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= References: <20220221155311.166278-1-mic@digikod.net> <20220221155311.166278-3-mic@digikod.net> From: =?UTF-8?Q?Micka=c3=abl_Sala=c3=bcn?= Subject: Re: [PATCH v1 2/7] landlock: Fix landlock_add_rule(2) signature In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,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 On 26/02/2022 22:26, Alejandro Colomar (man-pages) wrote: > Hi Mickaël, > > On 21/2/22 16:53, Mickaël Salaün wrote: >> From: Mickaël Salaün >> >> Replace the enum landlock_rule_type with an int in the syscall signature >> of landlock_add_rule to avoid an implementation-defined size.  In >> practice an enum type is like an int (at least with GCC and clang), but >> compilers may accept options (e.g. -fshort-enums) that would have an >> impact on that [1].  This change is mostly a cosmetic fix according to >> the current kernel compilers and used options. > > There are two proposals for C2x that might bring C++ syntax to C for > enums, i.e., being able to specify the underlying type of an enum. > > See: > > > > Since the current kernel is safe from that enum problem, it may be > better to wait and see what the standard decides to do with enum.  I > guess they'll add this feature sooner or later. Ok, interesting, I'll remove this patch then. I'd be curious to know when this will impact Linux though. Thanks! > > Regards, > Alex > >> >> Link: >> https://lore.kernel.org/r/8a22a3c2-468c-e96c-6516-22a0f029aa34@gmail.com/ >> [1] >> Reported-by: Alejandro Colomar >> Cc: Nathan Chancellor >> Cc: Nick Desaulniers >> Signed-off-by: Mickaël Salaün >> Link: https://lore.kernel.org/r/20220221155311.166278-3-mic@digikod.net >> --- >>   include/linux/syscalls.h     | 3 +-- >>   security/landlock/syscalls.c | 7 ++++--- >>   2 files changed, 5 insertions(+), 5 deletions(-) >> >> diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h >> index 819c0cb00b6d..a5956f91caf2 100644 >> --- a/include/linux/syscalls.h >> +++ b/include/linux/syscalls.h >> @@ -71,7 +71,6 @@ struct clone_args; >>   struct open_how; >>   struct mount_attr; >>   struct landlock_ruleset_attr; >> -enum landlock_rule_type; >>   #include >>   #include >> @@ -1053,7 +1052,7 @@ asmlinkage long sys_pidfd_send_signal(int pidfd, >> int sig, >>   asmlinkage long sys_pidfd_getfd(int pidfd, int fd, unsigned int flags); >>   asmlinkage long sys_landlock_create_ruleset(const struct >> landlock_ruleset_attr __user *attr, >>           size_t size, __u32 flags); >> -asmlinkage long sys_landlock_add_rule(int ruleset_fd, enum >> landlock_rule_type rule_type, >> +asmlinkage long sys_landlock_add_rule(int ruleset_fd, int rule_type, >>           const void __user *rule_attr, __u32 flags); >>   asmlinkage long sys_landlock_restrict_self(int ruleset_fd, __u32 >> flags); >>   asmlinkage long sys_memfd_secret(unsigned int flags); >> diff --git a/security/landlock/syscalls.c b/security/landlock/syscalls.c >> index fd4b24022a06..3b40fc5d0216 100644 >> --- a/security/landlock/syscalls.c >> +++ b/security/landlock/syscalls.c >> @@ -277,8 +277,9 @@ static int get_path_from_fd(const s32 fd, struct >> path *const path) >>    * >>    * @ruleset_fd: File descriptor tied to the ruleset that should be >> extended >>    *        with the new rule. >> - * @rule_type: Identify the structure type pointed to by @rule_attr >> (only >> - *             LANDLOCK_RULE_PATH_BENEATH for now). >> + * @rule_type: Identify the structure type pointed to by @rule_attr >> as defined >> + *             by enum landlock_rule_type (only >> LANDLOCK_RULE_PATH_BENEATH for >> + *             now). >>    * @rule_attr: Pointer to a rule (only of type &struct >>    *             landlock_path_beneath_attr for now). >>    * @flags: Must be 0. >> @@ -301,7 +302,7 @@ static int get_path_from_fd(const s32 fd, struct >> path *const path) >>    * - EFAULT: @rule_attr inconsistency. >>    */ >>   SYSCALL_DEFINE4(landlock_add_rule, >> -        const int, ruleset_fd, const enum landlock_rule_type, rule_type, >> +        const int, ruleset_fd, const int, rule_type, >>           const void __user *const, rule_attr, const __u32, flags) >>   { >>       struct landlock_path_beneath_attr path_beneath_attr; >