Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4037075pxb; Mon, 21 Feb 2022 10:37:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDTbvqdiI72GsEKM+R+g6ekIMVhd/H4hLIwLTzElU0lxjdPGYYCLTuXF9fQZueIODjjwq+ X-Received: by 2002:a17:906:6d0b:b0:6d1:d64e:3142 with SMTP id m11-20020a1709066d0b00b006d1d64e3142mr2330876ejr.631.1645468674271; Mon, 21 Feb 2022 10:37:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645468674; cv=none; d=google.com; s=arc-20160816; b=THlCiDA3rXEo8m/StZF6uWxj+2READQ9SPZca3oNu8TaJyVxxvYZmA39oqVse1395D FtDatpmAFkvCCX187jariMIi6W1rN5Jb3/rWmylQVOkd3bSFpLOZjdN7lLY+mV6zAMoZ O5WQczFFk31esdfSWLn1Cm7hWxkdEGcxFeynL1fl9CeBFjlJPrvQBG1w16CNhg68+Seo IyKw0yTMGJb4czu8UHH68PioPgNEw+TaNe4vgQm4+21pMrOY+V9K0cIroY1dVI0zQmZc k6SEcD7rsftrpAy8hYOTjGQAt2ZwoxKw7YOwkTGFLpFBmrVJp9+CnnmnvnFTdZwJZM8p LZEA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=NGS5Vk0cigr+fQUf1aoZNCvUI+XK/AH5Ru1HZqnu78w=; b=WxKn3bJViqDn2eJcp53Qd744SltjeMGwLMBNn9cIliA73KkTDwZDcvCJ8bLrBaZerr tS7q/r4PA/geaWVWTdrIjiI7k71Ivx2ijWo04n9Jpi3Nug0CiiyFy8MFduBl5/Im9HvD Umt5nz/xY3lZeY1KsVcjHf+ed1BdvgPPB4tTSZsH535gR0xlidJHoJ9jLKWUDHYl1XQa X8MPUX8r505pBfarQ5gRlzwQMGTwxTQ14MPFnUWnSJp4CNdZp1jF5WY6Gwsu38LAUWGM Jn1LlP5mGKFWiU52fhb19dZPId1YswAxGVh+LyCZTkpbcP9AKREjbLQ15MdhAeb9hXL3 i99g== 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 fy1si12054953ejc.750.2022.02.21.10.37.31; Mon, 21 Feb 2022 10:37:54 -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 S1379413AbiBUPns (ORCPT + 99 others); Mon, 21 Feb 2022 10:43:48 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:36600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379403AbiBUPnr (ORCPT ); Mon, 21 Feb 2022 10:43:47 -0500 Received: from smtp-8fa9.mail.infomaniak.ch (smtp-8fa9.mail.infomaniak.ch [IPv6:2001:1600:3:17::8fa9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD03322511 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=20Sala=C3=BCn?= To: James Morris , "Serge E . Hallyn" Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=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=20Sala=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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 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; -- 2.35.1