From: "Mickaël Salaün" <mic@digikod.net>
To: Li Wang <liwang@redhat.com>
Cc: gnoack@google.com, paul@paul-moore.com,
linux-kernel@vger.kernel.org, ltp@lists.linux.it,
Konstantin Meskhidze <konstantin.meskhidze@huawei.com>
Subject: Re: [RFC PATCH] landlock: fix minimal required size for landlock_ruleset_attr copying
Date: Tue, 2 Jul 2024 15:00:20 +0200 [thread overview]
Message-ID: <20240702.Auya5Chaipho@digikod.net> (raw)
In-Reply-To: <20240702094745.96521-1-liwang@redhat.com>
On Tue, Jul 02, 2024 at 05:47:45PM +0800, Li Wang wrote:
> As kernel commit fff69fb03dde ("landlock: Support network rules with TCP bind and connect")
> introducing a new field 'handled_access_net' in the structure landlock_ruleset_attr,
> but in the landlock_create_ruleset() it still uses the first field 'handled_access_fs'
> to calculate minimal size, so that made decrease 1 is useless in LTP landlock01.c to
> test the too-small-size.
>
> Test code:
> rule_small_size = sizeof(struct landlock_ruleset_attr) - 1;
> tst_syscall(__NR_landlock_create_ruleset, ..., rule_small_size, 0)
>
> Result:
> landlock01.c:49: TFAIL: Size is too small expected EINVAL: ENOMSG (42)
Interesting, this looks like a bug in these LTP tests.
>
> Signed-off-by: Li Wang <liwang@redhat.com>
> Cc: Mickaël Salaün <mic@digikod.net>
> Cc: Konstantin Meskhidze <konstantin.meskhidze@huawei.com>
> Cc: Paul Moore <paul@paul-moore.com>
> ---
>
> Notes:
> Hi Mickael,
> I'm not quite sure if that is on purpose to use the first field or kernel
> bug, can you take a look?
Hi Li,
Yes this is on purpose. The handled_access_fs minimal size check should
never change for backward compatibility reason. User space built with
old headers must still work with new kernels. This is tested with the
"inconsistent_attr" test in tools/testing/selftests/landlock/base_test.c
>
> security/landlock/syscalls.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/security/landlock/syscalls.c b/security/landlock/syscalls.c
> index 03b470f5a85a..f3cd7def7624 100644
> --- a/security/landlock/syscalls.c
> +++ b/security/landlock/syscalls.c
> @@ -198,7 +198,7 @@ SYSCALL_DEFINE3(landlock_create_ruleset,
> /* Copies raw user space buffer. */
> err = copy_min_struct_from_user(&ruleset_attr, sizeof(ruleset_attr),
> offsetofend(typeof(ruleset_attr),
> - handled_access_fs),
> + handled_access_net),
> attr, size);
> if (err)
> return err;
> --
> 2.45.2
>
prev parent reply other threads:[~2024-07-02 13:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-02 9:47 Li Wang
2024-07-02 13:00 ` Mickaël Salaün [this message]
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=20240702.Auya5Chaipho@digikod.net \
--to=mic@digikod.net \
--cc=gnoack@google.com \
--cc=konstantin.meskhidze@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liwang@redhat.com \
--cc=ltp@lists.linux.it \
--cc=paul@paul-moore.com \
/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®