From: Eamon Walsh <ewalsh@tycho.nsa.gov>
To: "Christopher J. PeBenito" <cpebenito@tresys.com>
Cc: SELinux Mail List <selinux@tycho.nsa.gov>,
"sds >> Stephen Smalley" <sds@tycho.nsa.gov>,
Joshua Brindle <jbrindle@tresys.com>
Subject: Re: [PATCH 3/5] libselinux: add string<->value functions that use discovery
Date: Wed, 06 Jun 2007 20:06:46 -0400 [thread overview]
Message-ID: <46674C16.40005@tycho.nsa.gov> (raw)
In-Reply-To: <1181157090.6578.38.camel@sgc.columbia.tresys.com>
Christopher J. PeBenito wrote:
> Add new value->name, name->value functions that use object class discovery.
>
> Signed-off-by: Chris PeBenito <cpebenito@tresys.com>
>
> ---
> libselinux/src/stringrep.c | 56 +++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 56 insertions(+)
>
> Index: selinux-obj-class-discovery/libselinux/src/stringrep.c
> ===================================================================
> --- selinux-obj-class-discovery.orig/libselinux/src/stringrep.c
> +++ selinux-obj-class-discovery/libselinux/src/stringrep.c
> @@ -407,6 +407,62 @@ static const char *security_av_perm_to_s
> return NULL;
> }
>
> +security_class_t string_to_security_class(const char *s)
> +{
> + struct discover_class_node *node;
> +
> + node = get_class_cache_entry_name(s);
> + if (node == NULL) {
> + node = discover_class(s);
> +
> + if (node == NULL)
> + return 0;
> + }
> +
> + return node->value;
> +}
> +
> +access_vector_t string_to_av_perm(security_class_t tclass, const char *s)
> +{
> + struct discover_class_node *node;
> +
> + node = get_class_cache_entry_value(tclass);
> + if (node != NULL) {
> + size_t i;
> + for (i=0; i<MAXVECTORS && node->perms[i] != NULL; i++)
> + if (strcmp(node->perms[i],s) == 0)
> + return (1<<i);
I think if you fall off the end of this loop, you may want to flush the
cache and try once more. This would handle the case where the policy
was reloaded with new permission bits added to the class. This is a
pretty obscure corner case so maybe it's not worth the effort. But see
comments about netlink below.
> + }
> +
> + return 0;
Set errno to EINVAL, as mentioned earlier.
> +}
> +
> +const char *security_class_to_string(security_class_t tclass)
> +{
> + struct discover_class_node *node;
> +
> + node = get_class_cache_entry_value(tclass);
> + if (node == NULL)
> + return NULL;
> + else
> + return node->name;
> +}
> +
> +const char *security_av_perm_to_string(security_class_t tclass,
> + access_vector_t av)
> +{
> + struct discover_class_node *node;
> + size_t i;
> +
> + node = get_class_cache_entry_value(tclass);
> + if (av && node)
> + for (i = 0; i<MAXVECTORS; i++)
> + if ((1<<i) & av)
> + return node->perms[i];
Likewise here, if you hit a NULL node->perms[i] you may want to flush
the cache and try again.
Do we want to flush the cache when a netlink reload notification comes
in? I don't necessarily think that the kernel should allow a policy
reload that moves or deletes classes and permissions. But in theory
(disregarding race conditions), this patchset along with use of the
mapping support could allow a userspace object manager to keep working
across a policy reload that does move things around and/or delete unused
values.
--
Eamon Walsh <ewalsh@tycho.nsa.gov>
National Security Agency
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
next prev parent reply other threads:[~2007-06-07 0:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-06 19:11 [PATCH 3/5] libselinux: add string<->value functions that use discovery Christopher J. PeBenito
2007-06-07 0:06 ` Eamon Walsh [this message]
2007-06-07 12:19 ` Christopher J. PeBenito
2007-06-07 12:20 ` Christopher J. PeBenito
-- strict thread matches above, loose matches on Subject: below --
2007-06-07 13:40 Christopher J. PeBenito
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=46674C16.40005@tycho.nsa.gov \
--to=ewalsh@tycho.nsa.gov \
--cc=cpebenito@tresys.com \
--cc=jbrindle@tresys.com \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.