lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <70b5c38d-117e-0b07-f942-8025a83a3df7@digikod.net>
Date:   Fri, 10 Feb 2023 18:38:25 +0100
From:   Mickaël Salaün <mic@...ikod.net>
To:     Konstantin Meskhidze <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, yusongping@...wei.com,
        artem.kuzin@...wei.com
Subject: Re: [PATCH v9 06/12] landlock: Refactor _unmask_layers() and
 _init_layer_masks()


On 16/01/2023 09:58, Konstantin Meskhidze wrote:
> Add new key_type argument to the landlock_init_layer_masks() helper.
> Add a masks_array_size argument to the landlock_unmask_layers() helper.
> These modifications support implementing new rule types in the next
> Landlock versions.
> 
> Signed-off-by: Mickaël Salaün <mic@...ikod.net>
> Signed-off-by: Konstantin Meskhidze <konstantin.meskhidze@...wei.com>
> ---
> 
> Changes since v8:
> * None.
> 
> Changes since v7:
> * Refactors commit message, adds a co-developer.
> * Minor fixes.
> 
> Changes since v6:
> * Removes masks_size attribute from init_layer_masks().
> * Refactors init_layer_masks() with new landlock_key_type.
> 
> Changes since v5:
> * Splits commit.
> * Formats code with clang-format-14.
> 
> Changes since v4:
> * Refactors init_layer_masks(), get_handled_accesses()
> and unmask_layers() functions to support multiple rule types.
> * Refactors landlock_get_fs_access_mask() function with
> LANDLOCK_MASK_ACCESS_FS mask.
> 
> Changes since v3:
> * Splits commit.
> * Refactors landlock_unmask_layers functions.
> 
> ---
>   security/landlock/fs.c      | 43 ++++++++++++++++--------------
>   security/landlock/ruleset.c | 52 ++++++++++++++++++++++++++-----------
>   security/landlock/ruleset.h | 17 ++++++------
>   3 files changed, 70 insertions(+), 42 deletions(-)
> 
> diff --git a/security/landlock/fs.c b/security/landlock/fs.c
> index 73a7399f93ba..a73dbd3f9ddb 100644
> --- a/security/landlock/fs.c
> +++ b/security/landlock/fs.c
>

[...]

> @@ -658,10 +677,13 @@ access_mask_t landlock_init_layer_masks(
>   		const unsigned long access_req = access_request;
>   		unsigned long access_bit;
>   
> -		for_each_set_bit(access_bit, &access_req,
> -				 ARRAY_SIZE(*layer_masks)) {
> +		for_each_set_bit(access_bit, &access_req, num_access) {
> +			/*
> +			 * Artificially handles all initially denied by default
> +			 * access rights.
> +			 */

No need to re-add this old comment which was removed with patch 2/12.


>   			if (BIT_ULL(access_bit) &
> -			    landlock_get_fs_access_mask(domain, layer_level)) {
> +			    get_access_mask(domain, layer_level)) {
>   				(*layer_masks)[access_bit] |=
>   					BIT_ULL(layer_level);
>   				handled_accesses |= BIT_ULL(access_bit);
> diff --git a/security/landlock/ruleset.h b/security/landlock/ruleset.h
> index 60a3c4d4d961..77349764e111 100644
> --- a/security/landlock/ruleset.h
> +++ b/security/landlock/ruleset.h
> @@ -266,14 +266,15 @@ landlock_get_fs_access_mask(const struct landlock_ruleset *const ruleset,
>   	return landlock_get_raw_fs_access_mask(ruleset, layer_level) |
>   	       ACCESS_FS_INITIALLY_DENIED;
>   }
> -bool landlock_unmask_layers(
> -	const struct landlock_rule *const rule,
> -	const access_mask_t access_request,
> -	layer_mask_t (*const layer_masks)[LANDLOCK_NUM_ACCESS_FS]);
> +bool landlock_unmask_layers(const struct landlock_rule *const rule,
> +			    const access_mask_t access_request,
> +			    layer_mask_t (*const layer_masks)[],
> +			    const size_t masks_array_size);
>   
> -access_mask_t landlock_init_layer_masks(
> -	const struct landlock_ruleset *const domain,
> -	const access_mask_t access_request,
> -	layer_mask_t (*const layer_masks)[LANDLOCK_NUM_ACCESS_FS]);
> +access_mask_t
> +landlock_init_layer_masks(const struct landlock_ruleset *const domain,
> +			  const access_mask_t access_request,
> +			  layer_mask_t (*const layer_masks)[],
> +			  const enum landlock_key_type key_type);
>   
>   #endif /* _SECURITY_LANDLOCK_RULESET_H */

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ