From: Harry Ciao <qingtao.cao@windriver.com>
To: Daniel J Walsh <dwalsh@redhat.com>
Cc: Eric Paris <eparis@parisplace.org>, <cpebenito@tresys.com>,
<slawrence@tresys.com>, <selinux@tycho.nsa.gov>
Subject: Re: v0 Separate tunables from booleans
Date: Fri, 26 Aug 2011 09:17:41 +0800 [thread overview]
Message-ID: <4E56F435.1080608@windriver.com> (raw)
In-Reply-To: <4E564860.2090502@redhat.com>
Daniel J Walsh 写道:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 08/25/2011 02:17 AM, Harry Ciao wrote:
>
>> Hi Eric,
>>
>> Eric Paris 写道:
>>
>>> On Tue, Aug 23, 2011 at 6:08 AM, Harry Ciao
>>> <qingtao.cao@windriver.com> wrote:
>>>
>>>
>>>
>>>> With this patchset, the size of policy.X would drop
>>>> significantly from 600+k down to 322+k bytes(since most of
>>>> tunables are default to false, and there is no else branch of
>>>> most conditionals).
>>>>
>>>>
>>> I should point out that I think you're off by one order of
>>> magnitude. You went from a 6M policy to a 3.2M policy. But
>>> still.
>>>
>>> I decided to do a little playing with this yesterday in Fedora
>>> policy (where Dan already DRASTICALLY reduced the policy size by
>>> changing from type sets with removal to using all attributes. My
>>> numbers weren't quite as impressive as yours (and I'm not certain
>>> I did one thing correctly)
>>>
>>> Pre Patch: 2148552 bytes 89383 allow rules 193 booleans
>>> Post Patch (no policy changes) 2166328 bytes 89383 allow rules
>>> 193 booleans Post Patch WITH policy changes 2031150 bytes
>>> 79685 allow rules 4 booleans
>>>
>>> So our policy grows 0.8% with only the tools change. Our policy
>>> shrinks 5.5% with this change. So it certainly doesn't look like
>>> bad news.
>>>
>>>
>>>
>>>
>> No problem. I am using refpolicy from tresys tree and I have
>> applied my test patch to introduce a new keyword of "tunable" and
>> change tunable_policy() to use this tunable keyword rather than the
>> current "bool" keyword. Since your number of booleans has jumped
>> from 193 down to 4, you must have applied this patch correctly :-)
>>
>> Since most tunables declared by tunable_policy() would default to
>> false and most of these tunable_policy() just has one if branch,
>> then in practice none rules would ever be expanded and written to
>> raw policy for them, that's why I have witnessed a significant drop
>> from 6M to 3.22M.
>>
>> So I could only guess in Fedora policy perhaps most tunables
>> default to true, or many tunable conditionals have two branches,
>> then the logically true branch would be expanded as normal. By
>> whatever, the size of policy.X would decrease when all disabled
>> branch of rules are discarded.
>>
>>
>
> The Fedora policy has removed all calls that do stuff like
>
> allow XYZ_t { file_type -shadow_t }:file read;
>
> Which generates hundreds/thousands of rules when run though the M4
> Macro, since it writes a rule for each file_type except the shadow_t.
> Anywhere in policy that we use this construct has to be reworked and
> this shrunk the policy by 90%. Your enhancement just adds another 5%
> reduction after this change. I sent a patch to refpolicy yesterday to
> fix the coreutils interfaces that we doing something like this.
>
>
>
I don't know much about Fedora policy, but for upstream refpolicy and
toolchain my patch would contribute 45% size reduction for raw policy
and before I sent my patchset out for review I had not seen your patch.
Anyway, it would be fantastic to have your patch to further drastically
reduce the raw policy size, the whole community would benefit from each
single contributor's effort like this.
Thanks,
Harry
>>> I did have one problem with my testing however.
>>> 0002-user_ping-is-a-tunable-use-tunable_policy-for-it.patch
>>> doesn't apply to Fedora. I tried to fix it up by hand. We
>>> actually have both of the following lines inside that if
>>> (user_ping) netutils_domtrans_ping($1) allow $1 ping_t:process {
>>> signal sigkill };
>>>
>>> I turned that into: tunable_policy(`user_ping',`
>>> netutils_domtrans_traceroute($1) allow $1 traceroute_t:process {
>>> signal sigkill }; ')
>>>
>>> But that resulted in an error which I didn't bother to figure
>>> out. Maybe you can tell me what it is?
>>>
>>>
>>>
> This is happening because sepolgen does not understand the new syntax.
> It can be ignored until the new syntax is agreed upon, then sepolgen
> will need to be updated.
>
>> Sorry I have no idea what this error is. There is no "allow $1
>> ping_t/traceroute_t:process ..." rules in these two interface in
>> tresys refpolicy, but after added them exactly as yours above still
>> no error happens on my side.
>>
>> Or could you pass me your patch to netutils.if after you've adopted
>> my original patch manually?
>>
>> Thanks, Harry
>>
>>
>>
>>> /usr/share/selinux/devel/include/system/modutils.if: Syntax error
>>> on line 181095 ` [type=TICK]
>>> /usr/share/selinux/devel/include/system/modutils.if: Syntax error
>>> on line 181097 ' [type=SQUOTE]
>>>
>>> It's also very possible that it comes from sepolgen-ifgen and it
>>> is part of the fedora-ism that is setroubleshoot.....
>>>
>>> -Eric
>>>
>>>
>>>
>> -- 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.
>>
>>
>>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk5WSGAACgkQrlYvE4MpobOdrACfQj2zNMQK7ASGz0pr7OKAfa4N
> SegAn12yUMX1MhlsAW+SP53uOPXj0WRe
> =2TXI
> -----END PGP SIGNATURE-----
>
>
--
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:[~2011-08-26 1:18 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-23 10:08 v0 Separate tunables from booleans Harry Ciao
2011-08-23 10:08 ` [v0 PATCH 1/6] Indicate when boolean is indeed a tunable Harry Ciao
2011-08-23 10:08 ` [v0 PATCH 2/6] Separate tunable from boolean during compile Harry Ciao
2011-08-23 10:08 ` [v0 PATCH 3/6] Write and read TUNABLE flags in related data structures Harry Ciao
2011-08-23 10:08 ` [v0 PATCH 4/6] Permanently enable the if or else branch of a tunable during link Harry Ciao
2011-08-23 10:08 ` [v0 PATCH 5/6] Copy and check the cond_bool_datum_t.flags " Harry Ciao
2011-08-23 10:08 ` [v0 PATCH 6/6] Skip tunable identifier and cond_node_t in expansion Harry Ciao
2011-08-23 13:43 ` Daniel J Walsh
2011-08-23 13:58 ` Christopher J. PeBenito
2011-08-24 10:32 ` HarryCiao
2011-08-24 12:11 ` Christopher J. PeBenito
2011-08-24 18:00 ` Joshua Brindle
2011-08-25 10:36 ` Harry Ciao
2011-08-24 18:02 ` Joshua Brindle
2011-08-25 3:22 ` Harry Ciao
2011-08-25 4:22 ` Joshua Brindle
2011-08-25 10:38 ` Harry Ciao
2011-08-24 17:54 ` Joshua Brindle
2011-08-24 20:24 ` Daniel J Walsh
2011-08-24 20:34 ` Joshua Brindle
2011-08-24 21:04 ` Daniel J Walsh
2011-08-24 16:02 ` v0 Separate tunables from booleans Eric Paris
2011-08-25 6:17 ` Harry Ciao
2011-08-25 13:04 ` Daniel J Walsh
2011-08-25 13:35 ` James Carter
2011-08-26 14:28 ` Daniel J Walsh
2011-08-26 1:17 ` Harry Ciao [this message]
2011-08-26 2:22 ` Eric Paris
2011-08-26 12:59 ` Daniel J Walsh
2011-08-26 13:06 ` Christopher J. PeBenito
2011-08-26 13:08 ` Christopher J. PeBenito
2011-08-26 14:11 ` Christopher J. PeBenito
2011-08-24 17:38 ` Christopher J. PeBenito
2011-08-24 17:52 ` Joshua Brindle
2011-08-25 5:31 ` Harry Ciao
2011-08-25 12:56 ` Joshua Brindle
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=4E56F435.1080608@windriver.com \
--to=qingtao.cao@windriver.com \
--cc=cpebenito@tresys.com \
--cc=dwalsh@redhat.com \
--cc=eparis@parisplace.org \
--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.