Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp125487pxm; Tue, 22 Feb 2022 18:33:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJxm75ifGZE0kBS+zf2gquecZqZ2i0W3I9D0q0Cq53EBP6iO5rY/KcoM6cZn4Ymrb4vRkXMq X-Received: by 2002:a17:907:9898:b0:6cd:ed45:1123 with SMTP id ja24-20020a170907989800b006cded451123mr22146490ejc.155.1645583621413; Tue, 22 Feb 2022 18:33:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645583621; cv=none; d=google.com; s=arc-20160816; b=cCW548ghdktEOGyRBwb28CwJ8g1Pkg9cZnDoyI1UbwzRIY+apwArhO/2P9rZO2/GTT w4U/7aJTGnCFXizUSX2OXm2GYPndN6NEfqJzTkRy7vKsOifDoSDIDzs9HT1I3W3GhaQ1 hxSNJXsN/XrEu7BAbv/fQhy957tc02MRYOm/rIi2PYdwG9ZVzWfhk0UiL+YozuMBDR51 xUM96t6SRD125FjW2n0doJhR+0blrDipz7/4rFqBhwo/2hLt2FEBmVc7BLXrXr66IRhE ZzY+PLvKbLw/cd2zcZ2Odj1O2ysEEVULstJjK+0oHbhzRnaTIEw7KJG9SZr1PESSKbRO YeeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=KzvH9ZQaXdUgSyIdwCtFzNEtbBoZxdQVld6HVvqC3h0=; b=NK/GffLCUR4rBlUJ6OKiivU9FI32oLguJY2EiVUp8kABY+wNZpurxUrFV091NHYrGr /qupvD0t9klK6+gpliUwv6bqAnSeKV8v5cINbxiZILgj1z9MYfzei3JB8xGpt/jWc8n2 3UvZWeUi/3aRDD2kYeMQ6Jy6JvxWFg5jgP3imP7my/+WdMikANyIrC/hErwwqqatGUDi x0AxpINN4UZijDqR2Nu6oI4IBefuie5ZPyDSt3O0ZjAoIcgDyZuzo5GT/MyNOuz11fqf W9qQ6LJLutCGKhw6WcFN++ByYp3TKuCdRTp1Dx6S3P879E5lj1l31TRknJF+53V5lAbI 4D+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20210112.gappssmtp.com header.s=20210112 header.b="S/IydQVZ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r6si15273811edd.252.2022.02.22.18.33.18; Tue, 22 Feb 2022 18:33:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore-com.20210112.gappssmtp.com header.s=20210112 header.b="S/IydQVZ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236177AbiBVXRP (ORCPT + 99 others); Tue, 22 Feb 2022 18:17:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236096AbiBVXRN (ORCPT ); Tue, 22 Feb 2022 18:17:13 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22AC48CDA9 for ; Tue, 22 Feb 2022 15:16:46 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id r13so24493322ejd.5 for ; Tue, 22 Feb 2022 15:16:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=KzvH9ZQaXdUgSyIdwCtFzNEtbBoZxdQVld6HVvqC3h0=; b=S/IydQVZc46d4zetWnmQ5U0e/PzMQNOi9DIjYeoinrNryqb/zeu17/TuDGbIX/KWpC 72p/RUQcIO43sVlxpFBZmQdfy6WJtCivMolKcubjDm1vgXMy8k/BPNGr/UPBh9C4W41h 4OMcW3ugJLilxrgRaLIAK4YLgo1M1xTJxv0gptrzQotyWQ8BVbQgyOuu/RAZGlM5Bw8P JmKxduxWoEh8ZNP3EI0O00LrNVhJlX3v4Rw2jBvCxgmBre2DuzWvIcOX5LuS+YxoHWGU YdMkjRgsLGwFaosBa6vzrp7EVsu7uc8gPip0/Bri8/5SM/66BSW/Pl4hxH3OB0jOdfoL rEiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=KzvH9ZQaXdUgSyIdwCtFzNEtbBoZxdQVld6HVvqC3h0=; b=Hb2d3BKrnh+k0LyynM3KOWiO6MZACbFGdo54Pcyy3ZcYiyUup4ZNJv7rt8G+JY9MD3 z1tv4VShGYCCGGsgv4onuZF5UAGKvoWSI1MEVU84+KAI2QmnZIJlgY1zL40+HCpS9MBd VEyiMIVjJwVA8AeTKSp8J2BSQ/GPuT2+/66n1yb7tbKCWDQEQsHrpoH8z3qeb7C4DEPP lTkKLIkFDa1kL9keK3tibqu/OFdDyjtK2qf+xOb1mGk2b7h0cDaSVQupdTM1huguUb1s J6KltsbGryP0jSDouv5+n+/D1vpP8AcE1kqP+9zxJIpD42QqA4dzv0Vq5//RqiNexnog SJhg== X-Gm-Message-State: AOAM532TWom5Zd38bbreYYWsKTf6gbZ2mQO85vY1pphsSsuFBkrXspEX RLQtLOIJz9yYXIxcEtEYM5jYcN1rmX+aOq/Eio+9 X-Received: by 2002:a17:907:2a54:b0:6d5:879d:aca4 with SMTP id fe20-20020a1709072a5400b006d5879daca4mr419389ejc.29.1645571804662; Tue, 22 Feb 2022 15:16:44 -0800 (PST) MIME-Version: 1.0 References: <20220217142133.72205-1-cgzones@googlemail.com> <20220217142133.72205-3-cgzones@googlemail.com> In-Reply-To: From: Paul Moore Date: Tue, 22 Feb 2022 18:16:33 -0500 Message-ID: Subject: Re: [PATCH 4/5] selinux: declare data arrays const To: Nick Desaulniers Cc: =?UTF-8?Q?Christian_G=C3=B6ttsche?= , selinux@vger.kernel.org, Stephen Smalley , Eric Paris , Nathan Chancellor , Ondrej Mosnacek , Jeremy Kerr , "David S. Miller" , Lakshmi Ramasubramanian , Yang Li , Austin Kim , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 18, 2022 at 12:24 PM Nick Desaulniers wrote: > On Fri, Feb 18, 2022 at 8:13 AM Paul Moore wrote: > > On Thu, Feb 17, 2022 at 9:21 AM Christian G=C3=B6ttsche > > wrote: > > > > > > diff --git a/security/selinux/include/initial_sid_to_string.h b/secur= ity/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[] =3D > > > + > > > +#ifdef __SELINUX_GENHEADERS__ > > > +# define const_qual > > > +#else > > > +# define const_qual const > > > +#endif > > > + > > > +static const char *const_qual initial_sid_to_string[] =3D > > > { > > > 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. Then let's just memcpy the array in genheaders.c. I'm okay with genheaders being a little ugly if it helps keep the core code cleaner. --=20 paul-moore.com