On Fri, Feb 18, 2022 at 8:13 AM Paul Moore <paul@xxxxxxxxxxxxxx> wrote: > > On Thu, Feb 17, 2022 at 9:21 AM Christian Göttsche > <cgzones@xxxxxxxxxxxxxx> wrote: > > > > diff --git a/security/selinux/include/initial_sid_to_string.h b/security/selinux/include/initial_sid_to_string.h > > index 5d332aeb8b6c..915283cd89bd 100644 > > --- a/security/selinux/include/initial_sid_to_string.h > > +++ b/security/selinux/include/initial_sid_to_string.h > > @@ -1,5 +1,12 @@ > > /* SPDX-License-Identifier: GPL-2.0 */ > > -static const char *initial_sid_to_string[] = > > + > > +#ifdef __SELINUX_GENHEADERS__ > > +# define const_qual > > +#else > > +# define const_qual const > > +#endif > > + > > +static const char *const_qual initial_sid_to_string[] = > > { > > NULL, > > "kernel", > > Thanks for this Christian. I generally like when we can const'ify > things like this, but I'm not excited about the const_qual hack on > core SELinux kernel code to satisfy genheaders.c. I understand why it > is needed, but I would rather clutter the genheaders.c code than the > core SELinux kernel code. If we can't cast away the const'ification > in genheaders.c could we simply allocate duplicate arrays in > genheaders.c and store the transformed strings into the new arrays? Note: casting off const is UB. I've had to fix multiple bugs where clang will drop writes to variables declared const but had const'ness casted away. -- Thanks, ~Nick Desaulniers