[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <41224e84-2da7-3f69-0fdb-bb309ad6a3d4@schaufler-ca.com>
Date: Thu, 17 Feb 2022 14:50:25 -0800
From: Casey Schaufler <casey@...aufler-ca.com>
To: Christian Göttsche <cgzones@...glemail.com>,
selinux@...r.kernel.org
Cc: James Morris <jmorris@...ei.org>,
"Serge E. Hallyn" <serge@...lyn.com>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Paul Moore <paul@...l-moore.com>,
Xin Long <lucien.xin@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Ondrej Mosnacek <omosnace@...hat.com>,
Mickaël Salaün <mic@...ux.microsoft.com>,
Todd Kjos <tkjos@...gle.com>,
Olga Kornievskaia <kolga@...app.com>,
linux-kernel@...r.kernel.org,
linux-security-module@...r.kernel.org, llvm@...ts.linux.dev,
Casey Schaufler <casey@...aufler-ca.com>
Subject: Re: [PATCH] security: declare member holding string literal const
On 2/17/2022 6:18 AM, Christian Göttsche wrote:
> The struct security_hook_list member lsm is assigned in
> security_add_hooks() with string literals passed from the individual
> security modules. Declare the function parameter and the struct member
> const to signal their immutability.
>
> Reported by Clang [-Wwrite-strings]:
>
> security/selinux/hooks.c:7388:63: error: passing 'const char [8]' to parameter of type 'char *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
> security_add_hooks(selinux_hooks, ARRAY_SIZE(selinux_hooks), selinux);
> ^~~~~~~~~
> ./include/linux/lsm_hooks.h:1629:11: note: passing argument to parameter 'lsm' here
> char *lsm);
> ^
>
> Signed-off-by: Christian Göttsche <cgzones@...glemail.com>
Reviewed-by: Casey Schaufler <casey@...aufler-ca.com>
> ---
> include/linux/lsm_hooks.h | 4 ++--
> security/security.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
> index 419b5febc3ca..47cdf3fbecef 100644
> --- a/include/linux/lsm_hooks.h
> +++ b/include/linux/lsm_hooks.h
> @@ -1595,7 +1595,7 @@ struct security_hook_list {
> struct hlist_node list;
> struct hlist_head *head;
> union security_list_options hook;
> - char *lsm;
> + const char *lsm;
> } __randomize_layout;
>
> /*
> @@ -1630,7 +1630,7 @@ extern struct security_hook_heads security_hook_heads;
> extern char *lsm_names;
>
> extern void security_add_hooks(struct security_hook_list *hooks, int count,
> - char *lsm);
> + const char *lsm);
>
> #define LSM_FLAG_LEGACY_MAJOR BIT(0)
> #define LSM_FLAG_EXCLUSIVE BIT(1)
> diff --git a/security/security.c b/security/security.c
> index 9663ffcca4b0..a48eb3badfdd 100644
> --- a/security/security.c
> +++ b/security/security.c
> @@ -478,7 +478,7 @@ static int lsm_append(const char *new, char **result)
> * Each LSM has to register its hooks with the infrastructure.
> */
> void __init security_add_hooks(struct security_hook_list *hooks, int count,
> - char *lsm)
> + const char *lsm)
> {
> int i;
>
Powered by blists - more mailing lists