public inbox for linux-security-module@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] landlock: Add counted_by and fix comment in landlock_ruleset
@ 2026-02-08 23:54 Tingmao Wang
  2026-02-09  9:47 ` Günther Noack
  2026-02-09 17:28 ` Mickaël Salaün
  0 siblings, 2 replies; 3+ messages in thread
From: Tingmao Wang @ 2026-02-08 23:54 UTC (permalink / raw)
  To: Mickaël Salaün
  Cc: Tingmao Wang, Günther Noack, linux-security-module

For a domain, this array stores the access masks for each layer (of
which there are num_layers of them).  For an unmerged ruleset, we have
one "layer", and one element in this array.  This annotation serves as
useful documentation.

This also removes a comment saying that num_layers = 0 for unmerged
rulesets, which is incorrect (it is 1).

Signed-off-by: Tingmao Wang <m@maowtm.org>
---

I'm not sure if I should add a Fixes tag, but if I should had, it would
be ae271c1b14 ("landlock: Add ruleset and domain management").

 security/landlock/ruleset.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/security/landlock/ruleset.h b/security/landlock/ruleset.h
index 9d6dc632684c..7005840ac641 100644
--- a/security/landlock/ruleset.h
+++ b/security/landlock/ruleset.h
@@ -168,8 +168,7 @@ struct landlock_ruleset {
 			/**
 			 * @num_layers: Number of layers that are used in this
 			 * ruleset.  This enables to check that all the layers
-			 * allow an access request.  A value of 0 identifies a
-			 * non-merged ruleset (i.e. not a domain).
+			 * allow an access request.
 			 */
 			u32 num_layers;
 			/**
@@ -184,7 +183,8 @@ struct landlock_ruleset {
 			 * layers are set once and never changed for the
 			 * lifetime of the ruleset.
 			 */
-			struct access_masks access_masks[];
+			struct access_masks
+				access_masks[] __counted_by(num_layers);
 		};
 	};
 };

base-commit: f179e1859c711214412876c57f56f9b0cfb13264
-- 
2.53.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] landlock: Add counted_by and fix comment in landlock_ruleset
  2026-02-08 23:54 [PATCH] landlock: Add counted_by and fix comment in landlock_ruleset Tingmao Wang
@ 2026-02-09  9:47 ` Günther Noack
  2026-02-09 17:28 ` Mickaël Salaün
  1 sibling, 0 replies; 3+ messages in thread
From: Günther Noack @ 2026-02-09  9:47 UTC (permalink / raw)
  To: Tingmao Wang; +Cc: Mickaël Salaün, linux-security-module

On Sun, Feb 08, 2026 at 11:54:48PM +0000, Tingmao Wang wrote:
> For a domain, this array stores the access masks for each layer (of
> which there are num_layers of them).  For an unmerged ruleset, we have
> one "layer", and one element in this array.  This annotation serves as
> useful documentation.
> 
> This also removes a comment saying that num_layers = 0 for unmerged
> rulesets, which is incorrect (it is 1).
> 
> Signed-off-by: Tingmao Wang <m@maowtm.org>

Reviewed-by: Günther Noack <gnoack@google.com>

Thank you for fixing this! We should use these bounds check macros
wherever we can, IMHO.  Removing the remark about num_layers=0 is also
correct.

—Günther

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] landlock: Add counted_by and fix comment in landlock_ruleset
  2026-02-08 23:54 [PATCH] landlock: Add counted_by and fix comment in landlock_ruleset Tingmao Wang
  2026-02-09  9:47 ` Günther Noack
@ 2026-02-09 17:28 ` Mickaël Salaün
  1 sibling, 0 replies; 3+ messages in thread
From: Mickaël Salaün @ 2026-02-09 17:28 UTC (permalink / raw)
  To: Tingmao Wang; +Cc: Günther Noack, linux-security-module

Thanks!

On Sun, Feb 08, 2026 at 11:54:48PM +0000, Tingmao Wang wrote:
> For a domain, this array stores the access masks for each layer (of
> which there are num_layers of them).  For an unmerged ruleset, we have
> one "layer", and one element in this array.  This annotation serves as
> useful documentation.
> 
> This also removes a comment saying that num_layers = 0 for unmerged
> rulesets, which is incorrect (it is 1).
> 
> Signed-off-by: Tingmao Wang <m@maowtm.org>
> ---
> 
> I'm not sure if I should add a Fixes tag, but if I should had, it would
> be ae271c1b14 ("landlock: Add ruleset and domain management").
> 
>  security/landlock/ruleset.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/security/landlock/ruleset.h b/security/landlock/ruleset.h
> index 9d6dc632684c..7005840ac641 100644
> --- a/security/landlock/ruleset.h
> +++ b/security/landlock/ruleset.h
> @@ -168,8 +168,7 @@ struct landlock_ruleset {
>  			/**
>  			 * @num_layers: Number of layers that are used in this
>  			 * ruleset.  This enables to check that all the layers
> -			 * allow an access request.  A value of 0 identifies a
> -			 * non-merged ruleset (i.e. not a domain).
> +			 * allow an access request.
>  			 */
>  			u32 num_layers;
>  			/**
> @@ -184,7 +183,8 @@ struct landlock_ruleset {
>  			 * layers are set once and never changed for the
>  			 * lifetime of the ruleset.
>  			 */
> -			struct access_masks access_masks[];
> +			struct access_masks
> +				access_masks[] __counted_by(num_layers);
>  		};
>  	};
>  };
> 
> base-commit: f179e1859c711214412876c57f56f9b0cfb13264
> -- 
> 2.53.0
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-02-09 17:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-08 23:54 [PATCH] landlock: Add counted_by and fix comment in landlock_ruleset Tingmao Wang
2026-02-09  9:47 ` Günther Noack
2026-02-09 17:28 ` Mickaël Salaün

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox