From: Ondrej Mosnacek <omosnace@redhat.com>
To: Paul Moore <paul@paul-moore.com>
Cc: SElinux list <selinux@vger.kernel.org>,
Stephen Smalley <sds@tycho.nsa.gov>
Subject: Re: [PATCH v2 3/5] selinux: convert cond_av_list to array
Date: Mon, 3 Feb 2020 10:13:08 +0100 [thread overview]
Message-ID: <CAFqZXNtO+_6BKG-CbaKmbcgSLgsBygH-4WQVgfiaWKFNay00sg@mail.gmail.com> (raw)
In-Reply-To: <CAHC9VhRaZ+OjcoM8=3xvDofVvnGV+4j0Y6i+gYjR6RU=zqTCjA@mail.gmail.com>
On Fri, Jan 31, 2020 at 5:17 AM Paul Moore <paul@paul-moore.com> wrote:
>
> On Fri, Jan 17, 2020 at 3:58 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> > Since it is fixed-size after allocation and we know the size beforehand,
> > using a plain old array is simpler and more efficient.
> >
> > Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> > Reviewed-by: Stephen Smalley <sds@tycho.nsa.gov>
> > ---
> > security/selinux/ss/conditional.c | 125 ++++++++++++------------------
> > security/selinux/ss/conditional.h | 8 +-
> > 2 files changed, 53 insertions(+), 80 deletions(-)
>
> ...
>
> > diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c
> > index c8a02c9b23ee..b847fd2a6a51 100644
> > --- a/security/selinux/ss/conditional.c
> > +++ b/security/selinux/ss/conditional.c
> > @@ -255,19 +249,17 @@ err:
> >
> > struct cond_insertf_data {
> > struct policydb *p;
> > + struct avtab_node **dst;
> > struct cond_av_list *other;
> > - struct cond_av_list *head;
> > - struct cond_av_list *tail;
> > };
> >
> > static int cond_insertf(struct avtab *a, struct avtab_key *k, struct avtab_datum *d, void *ptr)
> > {
> > struct cond_insertf_data *data = ptr;
> > struct policydb *p = data->p;
> > - struct cond_av_list *other = data->other, *list, *cur;
> > struct avtab_node *node_ptr;
> > - u8 found;
> > - int rc = -EINVAL;
> > + u32 i;
> > + bool found;
> >
> > /*
> > * For type rules we have to make certain there aren't any
> > @@ -277,7 +269,7 @@ static int cond_insertf(struct avtab *a, struct avtab_key *k, struct avtab_datum
> > if (k->specified & AVTAB_TYPE) {
> > if (avtab_search(&p->te_avtab, k)) {
> > pr_err("SELinux: type rule already exists outside of a conditional.\n");
> > - goto err;
> > + return -EINVAL;
> > }
> > /*
> > * If we are reading the false list other will be a pointer to
> > @@ -287,29 +279,29 @@ static int cond_insertf(struct avtab *a, struct avtab_key *k, struct avtab_datum
> > * If we are reading the true list (other == NULL) there shouldn't
> > * be any other entries.
> > */
> > - if (other) {
> > + if (data->other) {
> > node_ptr = avtab_search_node(&p->te_cond_avtab, k);
> > if (node_ptr) {
> > if (avtab_search_node_next(node_ptr, k->specified)) {
> > pr_err("SELinux: too many conflicting type rules.\n");
> > - goto err;
> > + return -EINVAL;
> > }
> > - found = 0;
> > - for (cur = other; cur; cur = cur->next) {
> > - if (cur->node == node_ptr) {
> > - found = 1;
> > + found = false;
> > + for (i = 0; i < data->other->len; i++) {
> > + if (data->other->nodes[i] == node_ptr) {
> > + found = true;
> > break;
> > }
> > }
>
> Can you explain why you got rid of the "other" variable in this
> function? It seems like it would be nice in the loop above.
It's probably a result of incremental edits... I agree it looks a bit
nicer with it and it also makes the diff simpler. I'll put it back in
v3.
--
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.
next prev parent reply other threads:[~2020-02-03 9:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-17 8:58 [PATCH v2 0/5] selinux: Assorted simplifications and cleanups Ondrej Mosnacek
2020-01-17 8:58 ` [PATCH v2 1/5] selinux: simplify evaluate_cond_node() Ondrej Mosnacek
2020-01-17 19:37 ` Stephen Smalley
2020-01-31 3:47 ` Paul Moore
2020-01-17 8:58 ` [PATCH v2 2/5] selinux: convert cond_list to array Ondrej Mosnacek
2020-01-17 19:38 ` Stephen Smalley
2020-01-31 4:05 ` Paul Moore
2020-02-03 9:05 ` Ondrej Mosnacek
2020-01-17 8:58 ` [PATCH v2 3/5] selinux: convert cond_av_list " Ondrej Mosnacek
2020-01-31 4:17 ` Paul Moore
2020-02-03 9:13 ` Ondrej Mosnacek [this message]
2020-01-17 8:58 ` [PATCH v2 4/5] selinux: convert cond_expr " Ondrej Mosnacek
2020-01-31 4:22 ` Paul Moore
2020-01-17 8:58 ` [PATCH v2 5/5] selinux: generalize evaluate_cond_node() Ondrej Mosnacek
2020-01-17 19:39 ` Stephen Smalley
2020-01-31 4:24 ` Paul Moore
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=CAFqZXNtO+_6BKG-CbaKmbcgSLgsBygH-4WQVgfiaWKFNay00sg@mail.gmail.com \
--to=omosnace@redhat.com \
--cc=paul@paul-moore.com \
--cc=sds@tycho.nsa.gov \
--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).