From: "Mickaël Salaün" <mic@digikod.net>
To: "Alejandro Colomar (man-pages)" <alx.manpages@gmail.com>,
James Morris <jmorris@namei.org>,
"Serge E . Hallyn" <serge@hallyn.com>
Cc: "Jann Horn" <jannh@google.com>,
"Kees Cook" <keescook@chromium.org>,
"Konstantin Meskhidze" <konstantin.meskhidze@huawei.com>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nick Desaulniers" <ndesaulniers@google.com>,
"Paul Moore" <paul@paul-moore.com>,
"Shuah Khan" <shuah@kernel.org>,
linux-api@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org,
"Mickaël Salaün" <mic@linux.microsoft.com>
Subject: Re: [PATCH v1 2/7] landlock: Fix landlock_add_rule(2) signature
Date: Mon, 28 Feb 2022 08:59:39 +0100 [thread overview]
Message-ID: <274f63e6-ed9a-e49f-8779-6e4980f51b33@digikod.net> (raw)
In-Reply-To: <ae52c028-05c7-c22e-fc47-d97ee4a2f6c7@gmail.com>
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 <mic@linux.microsoft.com>
>>
>> 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:
> <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2904.htm>
> <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2908.htm>
>
> 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 <alx.manpages@gmail.com>
>> Cc: Nathan Chancellor <nathan@kernel.org>
>> Cc: Nick Desaulniers <ndesaulniers@google.com>
>> Signed-off-by: Mickaël Salaün <mic@linux.microsoft.com>
>> 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 <linux/types.h>
>> #include <linux/aio_abi.h>
>> @@ -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;
>
next prev parent reply other threads:[~2022-02-28 7:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-21 15:53 [PATCH v1 0/7] Minor Landlock fixes and new tests Mickaël Salaün
2022-02-21 15:53 ` [PATCH v1 1/7] landlock: Fix landlock_add_rule(2) documentation Mickaël Salaün
2022-02-21 15:53 ` [PATCH v1 2/7] landlock: Fix landlock_add_rule(2) signature Mickaël Salaün
2022-02-26 21:26 ` Alejandro Colomar (man-pages)
2022-02-28 7:59 ` Mickaël Salaün [this message]
2022-02-21 15:53 ` [PATCH v1 3/7] selftest/landlock: Make tests build with old libc Mickaël Salaün
2022-02-21 15:53 ` [PATCH v1 4/7] selftest/landlock: Extend tests for minimal valid attribute size Mickaël Salaün
2022-02-21 15:53 ` [PATCH v1 5/7] selftest/landlock: Add tests for unknown access rights Mickaël Salaün
2022-02-21 15:53 ` [PATCH v1 6/7] selftest/landlock: Extend access right tests to directories Mickaël Salaün
2022-02-21 15:53 ` [PATCH v1 7/7] selftest/landlock: Fully test file rename with "remove" access Mickaël Salaün
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=274f63e6-ed9a-e49f-8779-6e4980f51b33@digikod.net \
--to=mic@digikod.net \
--cc=alx.manpages@gmail.com \
--cc=jannh@google.com \
--cc=jmorris@namei.org \
--cc=keescook@chromium.org \
--cc=konstantin.meskhidze@huawei.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mic@linux.microsoft.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=paul@paul-moore.com \
--cc=serge@hallyn.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®