From: James Carter <jwcart2@tycho.nsa.gov>
To: Steve Lawrence <slawrence@tresys.com>,
SELinux List <selinux@tycho.nsa.gov>
Subject: Re: [PATCH 1/2] libsepol: with pp to CIL, only associate declared roleattributes with in-scope types
Date: Fri, 29 May 2015 09:43:34 -0400 [thread overview]
Message-ID: <55686D06.30506@tycho.nsa.gov> (raw)
In-Reply-To: <55677751.4090405@tycho.nsa.gov>
On 05/28/2015 04:15 PM, James Carter wrote:
> On 05/28/2015 03:08 PM, James Carter wrote:
>> On 05/22/2015 01:34 PM, Steve Lawrence wrote:
>>> When a roleattribute is in a declared scope, CIL roletype statements are
>>> generated for all types associated with it. This incorrectly includes
>>> types that are associated with the roleattribute in optional blocks,
>>> which can result in CIL resolution failures if the optional block is
>>> turned off due to a missing type. So, change the roletype CIL statement
>>> generation with roleattributes to mimic the behavior of roles, ensuring
>>> declared roleattributes are only associated with in-scope types.
>>>
>>> Signed-off-by: Steve Lawrence <slawrence@tresys.com>
>>> Reported-by: Miroslav Grepl <mgrepl@redhat.com>
>>> ---
>>> libsepol/src/module_to_cil.c | 4 +++-
>>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/libsepol/src/module_to_cil.c b/libsepol/src/module_to_cil.c
>>> index 8d16d3e..1ded21d 100644
>>> --- a/libsepol/src/module_to_cil.c
>>> +++ b/libsepol/src/module_to_cil.c
>>> @@ -2091,7 +2091,9 @@ static int role_to_cil(int indent, struct policydb *pdb,
>>> struct avrule_block *UN
>>>
>>>
>>> for (i = 0; i < num_types; i++) {
>>> - cil_println(indent, "(roletype %s %s)", key, types[i]);
>>> + if (is_id_in_scope(pdb, decl_stack, types[i], SYM_TYPES)) {
>>> + cil_println(indent, "(roletype %s %s)", key, types[i]);
>>> + }
>>> }
>>>
>>> break;
>>>
>>
>> This breaks generating CIL from a policy.conf, or, more likely, exposes a
>> problem in what I did to make that work.
>>
>> A roletype rule will not appear in the generated CIL policy, if
>> 1) It is in an optional block
>> 2) It is for a role attribute that is in the required block of the optional.
>>
>> The policydb to CIL code is called after policy linking, so I would have thought
>> that everything should work. I am still looking at this.
>>
>
> Actually, it doesn't matter whether or not the role attribute is in a require
> block. The determining factor is whether there is any role rule (CIL roletype
> rule) outside of an optional block. If there is, then all of the roletype rules
> for that role attribute will be in the CIL policy. If not, then none of them
> will be.
>
I apparently did not have enough caffeine yesterday. I now see that everything
was working exactly as it should. When converting a policy.conf to CIL, two
roletype rules were being generated for these rules. This patch correctly
eliminates one of them.
--
James Carter <jwcart2@tycho.nsa.gov>
National Security Agency
next prev parent reply other threads:[~2015-05-29 13:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-22 17:34 [PATCH 1/2] libsepol: with pp to CIL, only associate declared roleattributes with in-scope types Steve Lawrence
2015-05-22 17:34 ` [PATCH 2/2] libsepol: with pp to CIL, always write auditadm_r and secadm_r roles to the base module Steve Lawrence
2015-05-25 10:45 ` Miroslav Grepl
2015-05-29 13:57 ` James Carter
2015-05-28 19:08 ` [PATCH 1/2] libsepol: with pp to CIL, only associate declared roleattributes with in-scope types James Carter
2015-05-28 20:15 ` James Carter
2015-05-29 13:43 ` James Carter [this message]
2015-05-29 13:56 ` James Carter
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=55686D06.30506@tycho.nsa.gov \
--to=jwcart2@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
--cc=slawrence@tresys.com \
/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.