From patchwork Mon Feb 21 15:53:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= X-Patchwork-Id: 12753778 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F5E3C433FE for ; Mon, 21 Feb 2022 15:43:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348013AbiBUPns (ORCPT ); Mon, 21 Feb 2022 10:43:48 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:36602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379401AbiBUPnr (ORCPT ); Mon, 21 Feb 2022 10:43:47 -0500 Received: from smtp-42af.mail.infomaniak.ch (smtp-42af.mail.infomaniak.ch [84.16.66.175]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57A412253C for ; Mon, 21 Feb 2022 07:43:20 -0800 (PST) Received: from smtp-3-0001.mail.infomaniak.ch (unknown [10.4.36.108]) by smtp-2-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4K2RQv034TzMptrY; Mon, 21 Feb 2022 16:43:19 +0100 (CET) Received: from localhost (unknown [23.97.221.149]) by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4K2RQt5MDgzlhMBw; Mon, 21 Feb 2022 16:43:18 +0100 (CET) From: =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= To: James Morris , "Serge E . Hallyn" Cc: =?utf-8?q?Micka=C3=ABl_Sala=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, Alejandro Colomar , =?utf-8?q?Micka=C3=ABl_Sala?= =?utf-8?q?=C3=BCn?= Subject: [PATCH v1 2/7] landlock: Fix landlock_add_rule(2) signature Date: Mon, 21 Feb 2022 16:53:06 +0100 Message-Id: <20220221155311.166278-3-mic@digikod.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220221155311.166278-1-mic@digikod.net> References: <20220221155311.166278-1-mic@digikod.net> MIME-Version: 1.0 Precedence: bulk List-ID: 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. 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;