linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Mickaël Salaün" <mic@digikod.net>
To: Kees Cook <keescook@chromium.org>
Cc: James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] landlock: Drop "const" argument qualifier to avoid GCC 4.9 warnings
Date: Mon, 13 Sep 2021 13:19:19 +0200	[thread overview]
Message-ID: <b269cdc1-a4f0-d614-f026-dc0f7c455da0@digikod.net> (raw)
In-Reply-To: <20210910223613.3225685-1-keescook@chromium.org>


On 11/09/2021 00:36, Kees Cook wrote:
> 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?

>             ^
> 
> 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 <keescook@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)[],

The "const layers" is not an issue, it should not be removed.

>  		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)[],

Same here for the second const.

>  		size_t num_layers)
>  {
>  	struct rb_node **walker_node;
> 

  reply	other threads:[~2021-09-13 11:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10 22:36 [PATCH] landlock: Drop "const" argument qualifier to avoid GCC 4.9 warnings Kees Cook
2021-09-13 11:19 ` Mickaël Salaün [this message]
2021-09-13 16:16   ` Kees Cook

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=b269cdc1-a4f0-d614-f026-dc0f7c455da0@digikod.net \
    --to=mic@digikod.net \
    --cc=jmorris@namei.org \
    --cc=keescook@chromium.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=serge@hallyn.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).