Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3451696rdb; Wed, 13 Sep 2023 12:24:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEcpVuYB/YIlPHSG4zBO5dmvPMNGRLKsdho90VE/rTbqHDGC6SAxjSQVjoyPIgmYlKVwX+ X-Received: by 2002:a17:903:22c2:b0:1c0:b82a:b0d9 with SMTP id y2-20020a17090322c200b001c0b82ab0d9mr4074889plg.29.1694633066664; Wed, 13 Sep 2023 12:24:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694633066; cv=none; d=google.com; s=arc-20160816; b=UNSlux8e/USci2urNCD3A3yWvWEwbTse85+zWhZQiK9m3tu/3LlGTro/4KXtzVmJDC 0Sq1RptU2hNIhTKLS5OMUiukrSxu8gW52POb1X2ov7vmDU+rYNHZfYmMq0sdoXUxA0Ea FYvwTnWowROJY97psWfz5osBGq4XhQEkl7g04HL0e0dFtPR/y4xBSIvqrzBMRWJ+D9sJ AZQEgPovqJKzzgU1iB9flx6rTGInlUl/d15smFq4CHpdDM2FyU4wAAa18wiym10W3rWT vepyqmOkxOD2B7od6Ls1no4wSQozeDGk3QwPmlHwGQtG+59NwnmYpA3v/qNAzPNAfVCa 3V0g== 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=D6p7tbPnNvlpg9xblNmKJQDZftsfkQOleUTpRaGHhOQ=; fh=PYlolE1cvQqiuldd9qR+ZJ7jbk7kLT1ABIDgfBi2bgM=; b=wb3pAGPU+jFKO6uhhAFMhundrkqt3f/szNiw0UmgBoUtDHqAehwvG+HRSiSg/EOp8v K8qZ2M04cAM9nm3NjD+TOZxfhuQEPon7w4unsPb5inyoteZxS48DRJX6YRPSXdk+s7aO 97nkRU+xk+Wm8y+NzGA4PeqqXTQoyg8AiboDohTJt+iato6ewOxndDQr5HK6I4K6Ykrw +VtYds6t/yfEEHQB7vdnTP6YnbKMVEknyfeM2Avc4CdzFoQcY9NzlB3/tWyPQ23c8jIZ ZwkG+cyi2A+x6kDEY00F3KBuFp2RyHrBJXHMkcQgOEPlyO1qIGAfXgPQvS5KRQb9cZRN 28Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b="D/zZMzn3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id jy7-20020a17090342c700b001b9c61c221bsi10297187plb.565.2023.09.13.12.24.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 12:24:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b="D/zZMzn3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 73A268062917; Wed, 13 Sep 2023 11:08:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229664AbjIMSIH (ORCPT + 99 others); Wed, 13 Sep 2023 14:08:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbjIMSIG (ORCPT ); Wed, 13 Sep 2023 14:08:06 -0400 Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C0EB19B6 for ; Wed, 13 Sep 2023 11:08:02 -0700 (PDT) Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-59b9d255037so1098017b3.2 for ; Wed, 13 Sep 2023 11:08:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1694628482; x=1695233282; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=D6p7tbPnNvlpg9xblNmKJQDZftsfkQOleUTpRaGHhOQ=; b=D/zZMzn3quzXBOp7hhi+83UVtfEZE+amUwPJvrNUHSb6mmbzOWlx2jNfDhPiSkbn5Q rAmXnPZIwzVaTNb3buy0+7xfPn+7alGqdG1Zxo1BYACF21E8SVi6dpGpgHqtyAAus4p6 mONWdR+fDPqDAFnFLI10xZkOREUOlSRJlQBO0+xd/yGTDEVjPxT/X91pqSwUf0TFIxV+ VOeNzjK/KLqVWqJDwmCw2OGH80OBQWxuJFl6P/D09HE0r+c6kPBdQEJCwU2ahHLDmOXJ FpSIVKvJAbvMq7XmU2bH6SBRhFDEALmzF30CjFXAMlURGCkn/oLMdofIsbshBT2KvX63 xTUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694628482; x=1695233282; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D6p7tbPnNvlpg9xblNmKJQDZftsfkQOleUTpRaGHhOQ=; b=J46ckd+5UIqAmd11GMdmjpKxFUUCsIoH8P4sJMHKR2pDVoG7VgyFotLv7y8WhWNvs2 bmTLsB8882ZYIuSxiRJsi5Vk4TRztXpw2ISAkuFr+ZiKbpQQmKD+IH6d6IEAZOfx8bl/ XzGhmgDh7CyfN2KOFoacR0PDBHtboMCPo3o8HwyoUieKoupm6Suqvso+qKTrITRKx/rQ Cj989eOn7StowOGL3RXUJT7R7h2n+In3fUx31QimaNVDOyIYIpQSaa1A03hTKfTBwU+G tH+WXZyxbvrTjCxyzXOXGgmQzw/yj2reLf1Y8nx8CvOgm3ocARwLOqtADwGqmIHEOxGm Du6g== X-Gm-Message-State: AOJu0YxLTTZPvvYwWON8D7ej678Knh0DYZyZ4u1XCrZshn2yWtlkvZJy XovigtbfbJ4mC8HWiLDN3zEw8CVF8yF58oQb0Uzi X-Received: by 2002:a0d:cb15:0:b0:59b:5275:800a with SMTP id n21-20020a0dcb15000000b0059b5275800amr3432151ywd.2.1694628481746; Wed, 13 Sep 2023 11:08:01 -0700 (PDT) MIME-Version: 1.0 References: <20230818151220.166215-1-cgzones@googlemail.com> In-Reply-To: From: Paul Moore Date: Wed, 13 Sep 2023 14:07:51 -0400 Message-ID: Subject: Re: [PATCH 2/6] selinux: dump statistics for more hash tables To: Stephen Smalley Cc: =?UTF-8?Q?Christian_G=C3=B6ttsche?= , selinux@vger.kernel.org, Eric Paris , Ondrej Mosnacek , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 13 Sep 2023 11:08:07 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email On Wed, Sep 13, 2023 at 2:03=E2=80=AFPM Stephen Smalley wrote: > On Wed, Sep 13, 2023 at 12:12=E2=80=AFPM Paul Moore = wrote: > > On Thu, Sep 7, 2023 at 1:42=E2=80=AFPM Stephen Smalley > > wrote: > > > On Fri, Aug 18, 2023 at 11:12=E2=80=AFAM Christian G=C3=B6ttsche > > > wrote: > > > > > > > > Dump in the SELinux debug configuration the statistics for the > > > > conditional rules avtab, the role transition, and class and common > > > > permission hash tables. > > > > > > > > Signed-off-by: Christian G=C3=B6ttsche > > > > --- > > > > > > > diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/p= olicydb.c > > > > index 84f02d4f8093..932e383bcad6 100644 > > > > --- a/security/selinux/ss/policydb.c > > > > +++ b/security/selinux/ss/policydb.c > > > > @@ -1158,6 +1158,8 @@ static int common_read(struct policydb *p, st= ruct symtab *s, void *fp) > > > > goto bad; > > > > } > > > > > > > > + hash_eval(&comdatum->permissions.table, "common_permissions= "); > > > > + > > > > rc =3D symtab_insert(s, key, comdatum); > > > > if (rc) > > > > goto bad; > > > > @@ -1339,6 +1341,8 @@ static int class_read(struct policydb *p, str= uct symtab *s, void *fp) > > > > goto bad; > > > > } > > > > > > > > + hash_eval(&cladatum->permissions.table, "class_permissions"= ); > > > > + > > > > rc =3D read_cons_helper(p, &cladatum->constraints, ncons, 0= , fp); > > > > if (rc) > > > > goto bad; > > > > > > Do we want to embed the actual common and class keys in the output to > > > distinguish among the multiple common and class permissions tables? > > > > That seems reasonable, were you thinking of just adding it to the > > hash_eval()'s hash name string, e.g. "common_permissions[XXX]"? > > Yes, otherwise you get a bunch of common_permissions and > class_permissions lines with no way to correlate. Agreed, I was asking more to determine how you envisioned the keys in the output. Christian, instead of creating the combined string in the caller I would suggest adding a third parameter to the hash_eval() function and having hash_eval() add the extra info (if present, NULL should be acceptable) to the output. This should ensure no extra work is done when debug is disabled. --=20 paul-moore.com