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@digikod.net>
Cc: James Morris <jmorris@namei.org>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: linux-security-module@vger.kernel.org
Signed-off-by: Kees Cook <redacted>
---
security/landlock/ruleset.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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,
I guess this is a bug in GCC 4.9 (i.e. missing automatic const upgrade).
Couldn't we backport a fix to GCC 4.9 instead?
quoted hunk
^
Drop "const" from the function definition.
Cc: "Mickaël Salaün" <mic@digikod.net>
Cc: James Morris <jmorris@namei.org>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: linux-security-module@vger.kernel.org
Signed-off-by: Kees Cook <redacted>
---
security/landlock/ruleset.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
On Mon, Sep 13, 2021 at 01:19:19PM +0200, Mickaël Salaün wrote:
On 11/09/2021 00:36, Kees Cook wrote:
quoted
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,
I guess this is a bug in GCC 4.9 (i.e. missing automatic const upgrade).
Couldn't we backport a fix to GCC 4.9 instead?