[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5c941be9-ac6a-d259-997e-13fdff09aeb4@digikod.net>
Date: Fri, 6 Jan 2023 20:34:27 +0100
From: Mickaël Salaün <mic@...ikod.net>
To: "Konstantin Meskhidze (A)" <konstantin.meskhidze@...wei.com>
Cc: willemdebruijn.kernel@...il.com, gnoack3000@...il.com,
linux-security-module@...r.kernel.org, netdev@...r.kernel.org,
netfilter-devel@...r.kernel.org, artem.kuzin@...wei.com
Subject: Re: [PATCH v8 11/12] samples/landlock: Add network demo
On 05/01/2023 04:46, Konstantin Meskhidze (A) wrote:
>
>
> 11/16/2022 5:25 PM, Mickaël Salaün пишет:
[...]
>>
>>> fprintf(stderr,
>>> "Hint: You should update the running kernel "
>>> "to leverage Landlock features "
>>> @@ -259,16 +342,36 @@ int main(const int argc, char *const argv[], char *const *const envp)
>>> access_fs_ro &= ruleset_attr.handled_access_fs;
>>> access_fs_rw &= ruleset_attr.handled_access_fs;
>>>
>>> + /* Removes bind access attribute if not supported by a user. */
>>> + env_port_name = getenv(ENV_TCP_BIND_NAME);
>>> + if (!env_port_name) {
>>
>> You can move this logic at the populate_ruleset_net() call site and
>> update this helper to not call getenv() twice for the same variable.
>
> But here I exclude ruleset attributes, not rule itself. It will break
> the logic: creating a ruleset then applying rules.
> I suggest to leave here as its.
Right, but you can still avoid the duplicate getenv() calls.
>>
>>
>>> + access_net_tcp &= ~LANDLOCK_ACCESS_NET_BIND_TCP;
>>> + }
>>> + /* Removes connect access attribute if not supported by a user. */
>>> + env_port_name = getenv(ENV_TCP_CONNECT_NAME);
>>> + if (!env_port_name) {
>>> + access_net_tcp &= ~LANDLOCK_ACCESS_NET_CONNECT_TCP;
>>> + }
>>> + ruleset_attr.handled_access_net &= access_net_tcp;
Powered by blists - more mailing lists