[apparmor] [patch] Fix dfa minimization
John Johansen
john.johansen at canonical.com
Fri Jan 3 23:49:53 UTC 2014
On 01/03/2014 02:49 PM, Steve Beattie wrote:
> On Tue, Dec 24, 2013 at 01:05:47PM -0800, John Johansen wrote:
>> On 12/24/2013 09:06 AM, Tyler Hicks wrote:
>>> I have to admit to not being very familiar with this area of the parser.
>>> The changes look sane to me, but I don't really understand everything
>>> that is going on.
>>>
>> right, I am going to hold off on committing this until I have a few
>> more tests to help verify every thing
>
> For the record, this causes a failure in the regression tests, in the
> query_label test, due to generating a profile that the kernel won't
> accept. Specifically, the following profile fails to load:
>
> /home/ubuntu/bzr/apparmor/tests/regression/apparmor/query_label {
> file,
> audit deny dbus,
> }
>
> Initial examination indicates that the patch is messing up the binary
> blob element alignments for some unknown reason; it may be triggering
> a latent bug in the parser.
>
Right so this is a bug in the policy generation (or unpack) depending on
how you look at it. Basically thanks to some one in the past (no not me)
our dfa must be on an 8 byte alignment with in the policy wrapper. This
is something we could and may fix in the unpack but likely won't because
well it does make the unpack more perform a little better, and well older
kernel unpack routines still expect the alignment.
Anyways what follows is a hexdump of the generated policy. With the
different parts broken out. There are 2 dfas (policy and older file) and
it is the second dfa that is out of alignment.
The aadfa blob wrapper should be making sure that the start of the actual
dfa is in alignment but this is not happening. In this example
00000000 04 08 00 76 65 72 73 69 6f 6e 00 02 05 00 00 00 |...version......|
00000010 04 08 00 70 72 6f 66 69 6c 65 00 07 05 40 00 2f |...profile... at ./|
00000020 68 6f 6d 65 2f 75 62 75 6e 74 75 2f 62 7a 72 2f |home/ubuntu/bzr/|
00000030 61 70 70 61 72 6d 6f 72 2f 74 65 73 74 73 2f 72 |apparmor/tests/r|
00000040 65 67 72 65 73 73 69 6f 6e 2f 61 70 70 61 72 6d |egression/apparm|
00000050 6f 72 2f 71 75 65 72 79 5f 6c 61 62 65 6c 00 04 |or/query_label..|
00000060 06 00 66 6c 61 67 73 00 07 02 00 00 00 00 02 00 |..flags.........|
00000070 00 00 00 02 00 00 00 00 08 02 00 00 00 00 02 00 |................|
00000080 00 00 00 02 00 00 00 00 02 00 00 00 00 04 07 00 |................|
00000090 63 61 70 73 36 34 00 07 02 00 00 00 00 02 00 00 |caps64..........|
000000a0 00 00 02 00 00 00 00 02 00 00 00 00 08 04 09 00 |................|
000000b0 70 6f 6c 69 63 79 64 62 00 07
begin of policy dfa blob wrapper
000000b0 04 06 00 61 61 64 |policydb.....aad|
000000c0 66 61 00 06
size of the following blob (in little endian) so 0x80
000000c0 80 00 00 00
begin of actual policy dfa, notice alignment on 8 byte boundry
000000c0 1b 5e 78 3d 00 00 00 18 |fa.......^x=....|
000000d0 00 00 00 80 00 00 6e 6f 74 66 6c 65 78 00 00 00 |......notflex...|
000000e0 00 01 00 04 00 00 00 00 00 00 00 01 00 00 00 00 |................|
000000f0 00 07 00 04 00 00 00 00 00 00 00 01 00 00 00 00 |................|
00000100 00 02 00 04 00 00 00 00 00 00 00 02 00 00 00 00 |................|
00000110 00 00 00 00 00 00 00 00 00 04 00 02 00 00 00 00 |................|
00000120 00 00 00 02 00 00 00 00 00 08 00 02 00 00 00 00 |................|
00000130 00 00 00 02 00 00 00 00 00 03 00 02 00 00 00 00 |................|
00000140 00 00 00 02 00 00 00 00 08
dfa blob wrapper
00000140 04 06 00 61 61 64 66 |............aadf|
00000150 61 00 06
size of the following blob (in little endian) so 0x4c8
00000150 c8 04 00 00
begin of file dfa, notice alignment. NOT on 8 byte boundry
1b 5e 78 3d 00 00 00 18 00 |a.......^x=.....|
00000160 00 04 c8 00 00 6e 6f 74 66 6c 65 78 00 00 00 00 |.....notflex....|
00000170 01 00 04 00 00 00 00 00 00 00 06 00 00 00 00 00 |................|
00000180 00 00 00 00 9f c2 7f 00 00 00 00 00 00 00 00 00 |................|
00000190 04 00 30 00 00 00 00 00 07 00 04 00 00 00 00 00 |..0.............|
000001a0 00 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001c0 02 00 04 00 00 00 00 00 00 00 06 00 00 00 00 00 |................|
000001d0 00 00 00 00 00 00 01 00 00 00 01 00 00 00 02 00 |................|
000001e0 00 00 00 00 00 00 00 00 04 00 02 00 00 00 00 00 |................|
000001f0 00 00 06 00 00 00 00 00 02 00 00 00 05 00 05 00 |................|
00000200 08 00 02 00 00 00 00 00 00 01 02 00 00 00 03 00 |................|
00000210 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000260 00 00 00 00 00 00 00 00 00 00 02 00 04 00 00 00 |................|
00000270 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000410 03 00 02 00 00 00 00 00 00 01 02 00 00 00 02 00 |................|
00000420 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000470 00 00 00 00 00 00 00 00 00 00 01 00 03 00 04 00 |................|
00000480 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000610 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
end of container
00000610 08 |................|
00000620
More information about the AppArmor
mailing list