From: "Mickaël Salaün" <mic@digikod.net>
To: Konstantin Meskhidze <konstantin.meskhidze@huawei.com>
Cc: willemdebruijn.kernel@gmail.com, gnoack3000@gmail.com,
linux-security-module@vger.kernel.org, netdev@vger.kernel.org,
netfilter-devel@vger.kernel.org, yusongping@huawei.com,
artem.kuzin@huawei.com
Subject: Re: [PATCH v9 03/12] landlock: Refactor landlock_find_rule/insert_rule
Date: Fri, 10 Feb 2023 18:36:48 +0100 [thread overview]
Message-ID: <d014f6db-0073-5461-afcd-5b046f3db096@digikod.net> (raw)
In-Reply-To: <20230116085818.165539-4-konstantin.meskhidze@huawei.com>
On 16/01/2023 09:58, Konstantin Meskhidze wrote:
> Add a new landlock_key union and landlock_id structure to support
> a socket port rule type. A struct landlock_id identifies a unique entry
> in a ruleset: either a kernel object (e.g inode) or typed data (e.g TCP
> port). There is one red-black tree per key type.
>
> This patch also adds is_object_pointer() and get_root() helpers.
> is_object_pointer() returns true if key type is LANDLOCK_KEY_INODE.
> get_root() helper returns a red_black tree root pointer according to
> a key type.
>
> Refactor landlock_insert_rule() and landlock_find_rule() to support coming
> network modifications. Adding or searching a rule in ruleset can now be
> done thanks to a Landlock ID argument passed to these helpers.
>
> Remove unnecessary inlining.
>
You need to keep the Co-developed-by before the Signed-off-by for my entry.
> Signed-off-by: Mickaël Salaün <mic@digikod.net>
> Signed-off-by: Konstantin Meskhidze <konstantin.meskhidze@huawei.com>
> ---
>
> Changes since v8:
> * Refactors commit message.
> * Removes inlining.
> * Minor fixes.
>
> Changes since v7:
> * Completes all the new field descriptions landlock_key,
> landlock_key_type, landlock_id.
> * Refactors commit message, adds a co-developer.
>
> Changes since v6:
> * Adds union landlock_key, enum landlock_key_type, and struct
> landlock_id.
> * Refactors ruleset functions and improves switch/cases: create_rule(),
> insert_rule(), get_root(), is_object_pointer(), free_rule(),
> landlock_find_rule().
> * Refactors landlock_append_fs_rule() functions to support new
> landlock_id type.
>
> Changes since v5:
> * Formats code with clang-format-14.
>
> Changes since v4:
> * Refactors insert_rule() and create_rule() functions by deleting
> rule_type from their arguments list, it helps to reduce useless code.
>
> Changes since v3:
> * Splits commit.
> * Refactors landlock_insert_rule and landlock_find_rule functions.
> * Rename new_ruleset->root_inode.
>
> ---
> security/landlock/fs.c | 49 ++++++------
> security/landlock/ruleset.c | 148 +++++++++++++++++++++++++-----------
> security/landlock/ruleset.h | 65 +++++++++++++---
> 3 files changed, 185 insertions(+), 77 deletions(-)
>
> diff --git a/security/landlock/fs.c b/security/landlock/fs.c
> index 0ae54a639e16..273ed8549da1 100644
> --- a/security/landlock/fs.c
> +++ b/security/landlock/fs.c
[...]
> @@ -191,12 +193,15 @@ int landlock_append_fs_rule(struct landlock_ruleset *const ruleset,
> *
> * Returns NULL if no rule is found or if @dentry is negative.
> */
> -static inline const struct landlock_rule *
> +static const struct landlock_rule *
Can you please create a (previous) dedicated patch for all the inlining
changes?
> find_rule(const struct landlock_ruleset *const domain,
> const struct dentry *const dentry)
> {
> const struct landlock_rule *rule;
> const struct inode *inode;
> + struct landlock_id id = {
> + .type = LANDLOCK_KEY_INODE,
> + };
>
> /* Ignores nonexistent leafs. */
> if (d_is_negative(dentry))
[...]
> @@ -652,7 +657,7 @@ static inline int check_access_path(const struct landlock_ruleset *const domain,
> }
>
> static int current_check_access_path(const struct path *const path,
> - const access_mask_t access_request)
> + const access_mask_t access_request)
This syntax fix should be moved to patch 2/12.
[...]
> diff --git a/security/landlock/ruleset.c b/security/landlock/ruleset.c
> index 1f3188b4e313..c5c88a100f74 100644
> --- a/security/landlock/ruleset.c
> +++ b/security/landlock/ruleset.c
[...]
> @@ -285,23 +333,23 @@ static int merge_ruleset(struct landlock_ruleset *const dst,
> - if (WARN_ON_ONCE(walker_rule->num_layers != 1)) {
> - err = -EINVAL;
> - goto out_unlock;
> - }
> - if (WARN_ON_ONCE(walker_rule->layers[0].level != 0)) {
> - err = -EINVAL;
> - goto out_unlock;
> - }
> + if (WARN_ON_ONCE(walker_rule->num_layers != 1))
> + return -EINVAL;
> + if (WARN_ON_ONCE(walker_rule->layers[0].level != 0))
> + return -EINVAL;
This introduces two potential bugs. Why change this code?
next prev parent reply other threads:[~2023-02-10 17:36 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-16 8:58 [PATCH v9 00/12] Network support for Landlock Konstantin Meskhidze
2023-01-16 8:58 ` [PATCH v9 01/12] landlock: Make ruleset's access masks more generic Konstantin Meskhidze
2023-01-16 8:58 ` [PATCH v9 02/12] landlock: Allow filesystem layout changes for domains without such rule type Konstantin Meskhidze
2023-02-10 17:34 ` Mickaël Salaün
2023-02-14 8:51 ` Konstantin Meskhidze (A)
2023-02-14 12:07 ` Mickaël Salaün
2023-02-14 12:57 ` Konstantin Meskhidze (A)
2023-01-16 8:58 ` [PATCH v9 03/12] landlock: Refactor landlock_find_rule/insert_rule Konstantin Meskhidze
2023-02-10 17:36 ` Mickaël Salaün [this message]
2023-02-14 10:15 ` Konstantin Meskhidze (A)
2023-02-14 12:09 ` Mickaël Salaün
2023-02-14 13:28 ` Konstantin Meskhidze (A)
2023-01-16 8:58 ` [PATCH v9 04/12] landlock: Refactor merge/inherit_ruleset functions Konstantin Meskhidze
2023-01-16 8:58 ` [PATCH v9 05/12] landlock: Move and rename umask_layers() and init_layer_masks() Konstantin Meskhidze
2023-02-10 17:37 ` Mickaël Salaün
2023-02-14 10:15 ` Konstantin Meskhidze (A)
2023-01-16 8:58 ` [PATCH v9 06/12] landlock: Refactor _unmask_layers() and _init_layer_masks() Konstantin Meskhidze
2023-02-10 17:38 ` Mickaël Salaün
2023-02-14 10:16 ` Konstantin Meskhidze (A)
2023-02-21 18:07 ` Mickaël Salaün
2023-03-06 7:52 ` Konstantin Meskhidze (A)
2023-01-16 8:58 ` [PATCH v9 07/12] landlock: Refactor landlock_add_rule() syscall Konstantin Meskhidze
2023-02-10 17:38 ` Mickaël Salaün
2023-02-14 10:18 ` Konstantin Meskhidze (A)
2023-01-16 8:58 ` [PATCH v9 08/12] landlock: Add network rules and TCP hooks support Konstantin Meskhidze
2023-02-10 17:39 ` Mickaël Salaün
2023-02-14 10:19 ` Konstantin Meskhidze (A)
2023-03-13 9:33 ` Konstantin Meskhidze (A)
2023-03-14 12:13 ` Mickaël Salaün
2023-03-14 14:38 ` Konstantin Meskhidze (A)
2023-02-21 18:04 ` Mickaël Salaün
2023-03-06 10:18 ` Konstantin Meskhidze (A)
2023-01-16 8:58 ` [PATCH v9 09/12] selftests/landlock: Share enforce_ruleset() Konstantin Meskhidze
2023-01-16 8:58 ` [PATCH v9 10/12] selftests/landlock: Add 10 new test suites dedicated to network Konstantin Meskhidze
2023-02-10 17:40 ` Mickaël Salaün
2023-02-14 10:36 ` Konstantin Meskhidze (A)
2023-02-14 12:13 ` Mickaël Salaün
2023-02-14 13:28 ` Konstantin Meskhidze (A)
2023-02-21 18:05 ` Mickaël Salaün
2023-03-06 12:03 ` Konstantin Meskhidze (A)
2023-03-06 16:00 ` Mickaël Salaün
2023-03-06 18:13 ` Konstantin Meskhidze (A)
2023-01-16 8:58 ` [PATCH v9 11/12] samples/landlock: Add network demo Konstantin Meskhidze
2023-01-16 8:58 ` [PATCH v9 12/12] landlock: Document Landlock's network support Konstantin Meskhidze
2023-01-21 23:07 ` Günther Noack
2023-01-23 9:38 ` Konstantin Meskhidze (A)
2023-01-27 18:22 ` Mickaël Salaün
2023-01-30 10:03 ` Konstantin Meskhidze (A)
2023-02-21 16:16 ` Mickaël Salaün
2023-03-06 13:43 ` Konstantin Meskhidze (A)
2023-03-06 16:09 ` Mickaël Salaün
2023-03-06 17:55 ` Konstantin Meskhidze (A)
2023-01-30 12:26 ` Konstantin Meskhidze (A)
2023-02-23 22:17 ` [PATCH v9 00/12] Network support for Landlock Günther Noack
2023-03-06 7:45 ` Konstantin Meskhidze (A)
2023-03-13 17:16 ` Konstantin Meskhidze (A)
2023-03-14 13:28 ` Mickaël Salaün
2023-06-26 15:29 ` [PATCH v9 00/12] Network support for Landlock - allowed list of protocols Mickaël Salaün
2023-06-28 2:33 ` Jeff Xu
2023-06-28 19:03 ` Mickaël Salaün
2023-06-28 21:56 ` Jeff Xu
2023-06-28 8:44 ` Günther Noack
2023-06-28 17:03 ` Jeff Xu
2023-06-28 19:29 ` Mickaël Salaün
2023-06-29 3:18 ` Jeff Xu
2023-06-29 11:07 ` Mickaël Salaün
2023-06-30 4:18 ` Jeff Xu
2023-06-30 18:23 ` Mickaël Salaün
2023-07-05 15:00 ` Jeff Xu
2023-07-12 11:30 ` Mickaël Salaün
2023-07-13 13:20 ` Konstantin Meskhidze (A)
2023-07-13 14:52 ` Mickaël Salaün
2023-07-13 11:44 ` Konstantin Meskhidze (A)
2023-06-28 19:07 ` 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=d014f6db-0073-5461-afcd-5b046f3db096@digikod.net \
--to=mic@digikod.net \
--cc=artem.kuzin@huawei.com \
--cc=gnoack3000@gmail.com \
--cc=konstantin.meskhidze@huawei.com \
--cc=linux-security-module@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=willemdebruijn.kernel@gmail.com \
--cc=yusongping@huawei.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;
as well as URLs for NNTP newsgroup(s).