[PATCH] landlock: Drop "const" argument qualifier to avoid GCC 4.9 warnings

Kees Cook keescook at chromium.org
Fri Sep 10 22:36:13 UTC 2021


When building under GCC 4.9, the compiler warns about const mismatches:

security/landlock/ruleset.c: In function 'insert_rule':
security/landlock/ruleset.c:196:34: error: passing argument 2 of 'create_rule' from incompatible pointer type [-Werror]
   new_rule = create_rule(object, &this->layers, this->num_layers,
                                  ^
security/landlock/ruleset.c:69:30: note: expected 'const struct landlock_layer ** const' but argument is of type 'struct landlock_layer (*)[]'
 static struct landlock_rule *create_rule(
                              ^
security/landlock/ruleset.c: In function 'landlock_insert_rule':
security/landlock/ruleset.c:240:38: error: passing argument 3 of 'insert_rule' from incompatible pointer type [-Werror]
  return insert_rule(ruleset, object, &layers, ARRAY_SIZE(layers));
                                      ^
security/landlock/ruleset.c:144:12: note: expected 'const struct landlock_layer ** const' but argument is of type 'struct landlock_layer (*)[1]'
 static int insert_rule(struct landlock_ruleset *const ruleset,
            ^

Drop "const" from the function definition.

Cc: "Mickaël Salaün" <mic at digikod.net>
Cc: James Morris <jmorris at namei.org>
Cc: "Serge E. Hallyn" <serge at hallyn.com>
Cc: linux-security-module at vger.kernel.org
Signed-off-by: Kees Cook <keescook at chromium.org>
---
 security/landlock/ruleset.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/security/landlock/ruleset.c b/security/landlock/ruleset.c
index ec72b9262bf3..64c37af88ee7 100644
--- a/security/landlock/ruleset.c
+++ b/security/landlock/ruleset.c
@@ -68,7 +68,7 @@ static void build_check_rule(void)
 
 static struct landlock_rule *create_rule(
 		struct landlock_object *const object,
-		const struct landlock_layer (*const layers)[],
+		struct landlock_layer (*layers)[],
 		const u32 num_layers,
 		const struct landlock_layer *const new_layer)
 {
@@ -143,7 +143,7 @@ static void build_check_ruleset(void)
  */
 static int insert_rule(struct landlock_ruleset *const ruleset,
 		struct landlock_object *const object,
-		const struct landlock_layer (*const layers)[],
+		struct landlock_layer (*layers)[],
 		size_t num_layers)
 {
 	struct rb_node **walker_node;
-- 
2.30.2



More information about the Linux-security-module-archive mailing list