selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Smalley <stephen.smalley.work@gmail.com>
To: Ondrej Mosnacek <omosnace@redhat.com>
Cc: SElinux list <selinux@vger.kernel.org>,
	James Carter <jwcart2@gmail.com>,
	Chris PeBenito <pebenito@ieee.org>,
	Petr Lautrbach <plautrba@redhat.com>
Subject: Re: [PATCH v5 1/2] libsepol,checkpolicy: optimize storage of filename transitions
Date: Tue, 21 Jul 2020 14:22:52 -0400	[thread overview]
Message-ID: <CAEjxPJ6jiWr5ZHWLqirAmu+9R=_qECyTrXPqtKSqwMeEdHZFQg@mail.gmail.com> (raw)
In-Reply-To: <20200719103506.865962-2-omosnace@redhat.com>

On Sun, Jul 19, 2020 at 6:35 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
>
> In preparation to support a new policy format with a more optimal
> representation of filename transition rules, this patch applies an
> equivalent change from kernel commit c3a276111ea2 ("selinux: optimize
> storage of filename transitions").
>
> See the kernel commit's description [1] for the rationale behind this
> representation. This change doesn't bring any measurable difference of
> policy build performance (semodule -B) on Fedora.
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux.git/commit/?id=c3a276111ea2572399281988b3129683e2a6b60b
>
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> ---

> diff --git a/checkpolicy/policy_define.c b/checkpolicy/policy_define.c
> index c6733fa4..01a90438 100644
> --- a/checkpolicy/policy_define.c
> +++ b/checkpolicy/policy_define.c
> @@ -3388,40 +3387,21 @@ int define_filename_trans(void)
<snip>
> +                               dup_name = NULL;
> +                               rc = policydb_filetrans_insert(
> +                                       policydbp, s+1, t+1, c+1, name,
> +                                       &dup_name, otype, NULL
> +                               );
> +                               free(dup_name);

The dup_name / name_alloc handling seems rather odd.  In every caller
except one you follow the pattern above, where we set it to NULL, call
policydb_filetrans_insert, and then free it immediately.  I'm not sure
why you are doing it this way.

  reply	other threads:[~2020-07-21 18:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-19 10:35 [PATCH v5 0/2] userspace: Implement new format of filename trans rules Ondrej Mosnacek
2020-07-19 10:35 ` [PATCH v5 1/2] libsepol,checkpolicy: optimize storage of filename transitions Ondrej Mosnacek
2020-07-21 18:22   ` Stephen Smalley [this message]
2020-07-22 22:15     ` Ondrej Mosnacek
2020-07-19 10:35 ` [PATCH v5 2/2] libsepol: implement POLICYDB_VERSION_COMP_FTRANS Ondrej Mosnacek
2020-07-19 11:31 ` [PATCH v5 0/2] userspace: Implement new format of filename trans rules Ondrej Mosnacek

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='CAEjxPJ6jiWr5ZHWLqirAmu+9R=_qECyTrXPqtKSqwMeEdHZFQg@mail.gmail.com' \
    --to=stephen.smalley.work@gmail.com \
    --cc=jwcart2@gmail.com \
    --cc=omosnace@redhat.com \
    --cc=pebenito@ieee.org \
    --cc=plautrba@redhat.com \
    --cc=selinux@vger.kernel.org \
    /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).