Commit graph

194 commits

Author SHA1 Message Date
Chih-Hung Hsieh
92dacd1ef9 Merge "Use -Werror in system/sepolicy" am: 0d2303be0c am: b03597d1b4
am: 52313b4ce8

Change-Id: I724e29b61036248d06aeadd604084857b5a2936a
2017-10-19 23:34:17 +00:00
Treehugger Robot
0d2303be0c Merge "Use -Werror in system/sepolicy" 2017-10-19 22:53:57 +00:00
William Roberts
71ebf07cfd Merge "fc_sort: rectify with upstream" am: adef499d29 am: 9b1affaa07
am: 6091bbc363

Change-Id: I5e16838c9b81d23b113dc0d0cadf74419d279d38
2017-10-19 19:35:23 +00:00
William Roberts
1cf1064baa fc_sort: rectify with upstream
Code review of:
  - https://android-review.googlesource.com/#/c/platform/system/sepolicy/+/512420/

had some comments. These were addressed and upstreamed here:
  - 65620e0f94

Bring these changes back into the AOSP tree.

Test: verify that output sorted device files did not change hashes when built.

Change-Id: I7f07d3f74923cf731e853629034469784fc669f7
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2017-10-19 16:04:24 +00:00
Chih-Hung Hsieh
038e322f3b Use -Werror in system/sepolicy
Bug: 66996870
Test: build with WITH_TIDY=1
Change-Id: I5df432c6d2f7ee19db89f44fbe3adec2bbcc0b41
2017-10-18 16:19:42 -07:00
William Roberts
ce6c74327e Merge "fc_sort: update to latest" am: f54c8ea95c am: c73fb57045
am: 2f22694a6b

Change-Id: Ia78d8ac42c7986a6a64a575cf47b386a5f1f045b
2017-10-18 00:08:53 +00:00
Keun Soo Yim
5f6fc9c9be package sepolicy-analyze as part of VTS
am: 67b2da4431

Change-Id: I1bbf9b95f0c38fd5f20412e4afb2251ed2c3948e
2017-10-17 03:52:11 +00:00
Keun Soo Yim
67b2da4431 package sepolicy-analyze as part of VTS
Bug: 67848572
Test: mma
Change-Id: I75520b6aa19e44854129697b3c3e375427356e6a
2017-10-16 14:21:07 -07:00
William Roberts
9a6b240b1f fc_sort: update to latest
Update to commit:
  - 5490639ac9

This solves all reported clang analyzer issues and is inline with upstream.

Test: veerify that md5sum of output files do not change.

Change-Id: I942145b8f9748c8ecd185f730c94d57cb77f5acc
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2017-10-16 10:04:46 -07:00
Dan Cashman
91d398d802 Sync internal master and AOSP sepolicy.
Bug: 37916906
Test: Builds 'n' boots.
Change-Id: Ia1d86264446ebecc1ca79f32f11354921bc77668
Merged-In: I208ec6a864127a059fb389417a9c6b259d7474cb
2017-09-26 14:38:47 -07:00
Jeffrey Vander Stoep
59005d3761 Merge "Fix possible memory leak warning." am: 3b24ce5090 am: dfdb96280e
am: dfea667d3f

Change-Id: Ic835bf45ab8a2334bdeec6540678d73dddfffa6d
2017-09-20 03:41:13 +00:00
Luis A. Lozano
635e3eccfb Fix possible memory leak warning.
Static analyzer complains the memory pointed by list in bcurrent is not
deallocated before returning. But since this code is in "main" routine,
we don't care about the deallocation. Just ignore the warning.

Bug: b/27101951
Test: Verified warning is gone.
Change-Id: I58d784b61a5ad30d1406bd7c6b28c5713abf2b34
2017-08-22 18:24:56 -07:00
Yifan Hong
43473a00e1 Merge "Make sepolicy-analyze for GTS." into oc-mr1-dev
am: 7c55e171de

Change-Id: Iff2eb18c5898ae5d05c00a3c888d98286b36374a
2017-08-17 01:01:28 +00:00
Yifan Hong
9ffea2f94b Make sepolicy-analyze for GTS.
Test: gts-tradefed run gts-dev --module=GtsSecurityHostTestCases
Bug: 64127136
Change-Id: Ib50294488bb1a5d46faed00d6954db64648fed20
2017-08-15 15:26:07 -07:00
Manoj Gupta
508db351a1 Merge "Fix static analyzer warnings."
am: 4b547a1516

Change-Id: Id5b85ec29220cdbc15aab72ddf4dfbd2d4ef2fc7
2017-08-02 02:47:37 +00:00
Manoj Gupta
3cdd4a4b0d Fix static analyzer warnings.
Fix the following warnings:

system/sepolicy/tools/sepolicy-analyze/neverallow.c:346:9: warning:
Potential leak of memory pointed to by '__s1'
system/sepolicy/tools/sepolicy-analyze/neverallow.c:346:9: warning:
Potential leak of memory pointed to by 'id'
system/sepolicy/tools/sepolicy-analyze/neverallow.c:364:13: warning:
Potential leak of memory pointed to by 'classperms'
system/sepolicy/tools/sepolicy-analyze/neverallow.c:364:13: warning:
Potential leak of memory pointed to by 'node'

Bug: b/27101951
Test:Warnings are gone.
Change-Id: Ib9b2e0b9f19950b4b764d438ee58340e6c022ef5
2017-08-01 15:46:44 -07:00
Andreas Gampe
d1e5758596 Merge "fc_sort: Fix leaks" am: 7f4b2ad584 am: acbf2ad328
am: 274c4e3352

Change-Id: Ic46f83ae348c57ad306748d03456e62c9a4600d4
2017-05-01 23:40:57 +00:00
Treehugger Robot
7f4b2ad584 Merge "fc_sort: Fix leaks" 2017-05-01 23:30:26 +00:00
Andreas Gampe
a1ccbd3d67 Sepolicy-Analyze: Plug leak am: ee8b67dfd9 am: 4a318ad697
am: 4c1385a6d4

Change-Id: I4da23806c532acfaaa1535ee87b25383a99723d7
2017-04-28 18:36:36 +00:00
Andreas Gampe
c32d7bae15 fc_sort: Fix leaks
Use the getline API correctly: keep a single buffer as long as
possible, and let the callee handle re-allocation. Move the final
free out of the loop.

Release the head of the linked list.

Bug: 37757586
Test: ASAN_OPTIONS= SANITIZE_HOST=address mmma system/sepolicy
Change-Id: I42424acba7cd68c1b9a7a43e916a421ac3e253f7
2017-04-28 10:37:55 -07:00
Andreas Gampe
ee8b67dfd9 Sepolicy-Analyze: Plug leak
Destroy the policy before exiting (for successful = expected runs).

Bug: 37757759
Test: ASAN_OPTIONS= SANITIZE_HOST=address m
Change-Id: I67e35fbede696ec020a53b69a6cef9f374fae167
2017-04-27 18:16:26 -07:00
Alex Klyubin
16fcbe8f17 Merge "Do not warn about empty typesets in neverallows" into oc-dev
am: 26564ce754

Change-Id: I8961e581bad56f118c112f6b1e6d2ba11a81ccf6
2017-04-26 00:41:44 +00:00
Alex Klyubin
c60d3ea164 Do not warn about empty typesets in neverallows
Empty typeset is not an issue in neverallow rules. The reason is that
it's completly normal for scontext or tcontext of neverallow rules to
evaluate to an empty type set. For example, there are neverallow rules
whose purpose is to test that all types with particular powers are
associated with a particular attribute:
  neverallow {
    untrusted_app_all
    -untrusted_app
    -untrusted_app_25
  } domain:process fork;

Test: sepolicy-analyze neverallow -w -n \
          'neverallow {} {}:binder call;'
      produces empty output instead of "Warning!  Empty type set"
Bug: 37357742
Change-Id: Id61b4fe22fafaf0522d8769dd4e23dfde6cd9f45
2017-04-25 14:25:04 -07:00
Dan Cashman
c787f54766 sepolicy-analyze: Add ability to list all attributes. am: 9d46f9b4f0 am: fdb9c018cd
am: c45e9b9afb

Change-Id: I6af916d823b983581c5f7b33858364af6b2e4456
2017-04-18 22:20:46 +00:00
Dan Cashman
9d46f9b4f0 sepolicy-analyze: Add ability to list all attributes.
This could be useful in diffs between policy versions.

Bug: 37357742
Test: sepolicy-analyze lists all attributes in precompiled_policy.
Change-Id: I6532a93d4102cf9cb12b73ee8ed86ece368f9131
2017-04-18 11:08:43 -07:00
Sandeep Patil
9a3a6a81df sepolicy_version: change current version to NN.m format
The sepolicy version takes SDK_INT.<minor> format. Make sure our
'current' policy version reflects the format and make it '100000.0'.
This ensures any vendor.img compiled with this will never work with
a production framework image either.

Make version_policy replace the '.' in version by '_' so secilc is
happy too.

This unblocks libvintf from giving out a runtme API to check vendor's
sepolicy version. The PLAT_PUBLIC_SEPOLICY_CURRENT_VERSION will
eventually be picked up from the build system.

(cherry-pick of commit 42f95984b5)

Bug: 35217573
Test: Build and boot sailfish.
      Boot sailfish with sepolicy compilation on device.
Signed-off-by: Sandeep Patil <sspatil@google.com>

Change-Id: Ic8b6687c4e71227bf9090018999149cd9e11d63b
2017-04-11 10:16:24 -07:00
Sandeep Patil
42f95984b5 sepolicy_version: change current version to NN.m format
The sepolicy version takes SDK_INT.<minor> format. Make sure our
'current' policy version reflects the format and make it '100000.0'.
This ensures any vendor.img compiled with this will never work with
a production framework image either.

Make version_policy replace the '.' in version by '_' so secilc is
happy too.

This unblocks libvintf from giving out a runtme API to check vendor's
sepolicy version. The PLAT_PUBLIC_SEPOLICY_CURRENT_VERSION will
eventually be picked up from the build system.

Bug: 35217573
Test: Build and boot sailfish.
      Boot sailfish with sepolicy compilation on device.
Signed-off-by: Sandeep Patil <sspatil@google.com>

Change-Id: Ic8b6687c4e71227bf9090018999149cd9e11d63b
2017-04-07 14:18:48 -07:00
Martijn Coenen
d48d54a3a1 Modify checkfc to check (vnd|hw)service_manager_type.
added checkfc options 'l' and 'v' to verify hwservice_manager_type
and vndservice_manager_type on service context files, respectively.

The checkfc call to verify the new hwservice_contexts files will
be added together with hwservicemanager ACL CLs later.

Bug: 34454312
Bug: 36052864
Test: device boots, works
Change-Id: Ie3b56da30be47c95a6b05d1bc5e5805acb809783
2017-04-06 17:25:07 -07:00
Dan Cashman
3a68bd169b Add reverse-attribute mapping to sepolicy-analyze.
sepolicy-analyze allows users to see all types that have a given
attribute, but not the reverse case: all attributes of a given type.
Add a '--reverse' option which enables this, but keeps the previous
interface.

Usage: sepolicy-analyze sepolicy attribute -r init

Bug: 36508258
Test: Build and run against current policy.

(cherry picked from commit d444ebedac)

Change-Id: I9813ebf61d50fb5abbc8e52be4cf62751979bbd4
2017-04-06 09:46:38 -07:00
Dan Cashman
d444ebedac Add reverse-attribute mapping to sepolicy-analyze.
sepolicy-analyze allows users to see all types that have a given
attribute, but not the reverse case: all attributes of a given type.
Add a '--reverse' option which enables this, but keeps the previous
interface.

Usage: sepolicy-analyze sepolicy attribute -r init

Bug: 36508258
Test: Build and run against current policy.
Change-Id: Ice6893cf7aa2ec4706a7411645a8e0a8a3ad01eb
2017-03-31 08:40:26 -07:00
Chad Brubaker
a782a81627 Add new untrusted_v2_app domain
untrusted_v2_app is basically a refinement of untrusted_app with legacy
capabilities removed and potentially backwards incompatible changes.

This is not currently hooked up to anything.

Bug: 33350220
Test: builds
Change-Id: Ic9fad57476bc2b6022b1eaca8667bf6d844753c2
2017-02-21 12:39:55 -08:00
Michael Peck
f54b3622c7 Add minTargetSdkVersion input selector to seapp_contexts
This new input selector allows phasing in new security policies by
giving app developers an opportunity to make any needed compatibility
changes before updating each app's targetSdkVersion.

When all else is equal, matching entries with higher
minTargetSdkVersion= values are preferred over entries with lower
minTargetSdkVersion= values.

Test: Marlin builds and boots. Apps targeting targetSdkVersion<=25
run in untrusted_app_25 domain. Apps targeting the current development
build >=26 run in the untrusted_app domain with fewer permissions. No
new denials observed during testing.
Bug: 34115651
Change-Id: I14bf4f51dbe26cb9bd3f62ad0b281085441d9806
2017-02-14 13:03:12 -08:00
Nick Kralevich
16b7f0a14c Block files without trailing newlines
Add a pre-submit check to ensure that files have a newline character at
the end.

Please see https://android.googlesource.com/platform/tools/repohooks/
for documentation on how PREUPLOAD hooks work.

Test: created a change and watched the presubmit check reject it.
Change-Id: Id0528cb1bd6fa9c4483ba43720839832f4fec34d
2016-12-12 08:18:01 -08:00
dcashman
2e00e6373f sepolicy: add version_policy tool and version non-platform policy.
In order to support platform changes without simultaneous updates from
non-platform components, the platform and non-platform policies must be
split.  In order to provide a guarantee that policy written for
non-platform objects continues to provide the same access, all types
exposed to non-platform policy are versioned by converting them and the
policy using them into attributes.

This change performs that split, the subsequent versioning and also
generates a mapping file to glue the different policy components
together.

Test: Device boots and runs.
Bug: 31369363
Change-Id: Ibfd3eb077bd9b8e2ff3b2e6a0ca87e44d78b1317
2016-12-06 08:56:02 -08:00
Treehugger Robot
ce3b2a41a5 Merge "fc_sort: cleanup warnings caught by clang tidy / static analyzer." 2016-10-24 19:03:57 +00:00
William Roberts
f7d6bb3f71 check_seapp: correct output on invalid policy file
If in invalid policy file is loaded check_seapp outputs:

Error: Could not lod policy file to db: Success!

The "Success" value is from errno, which is not manipulated
by libsepol. Also, load should have an a in it!

Hardcode the error message to:

Error: Could not load policy file to db: invalid input file!

Test: That when providing an invalid sepolicy binary, that the output
message is correct.
Change-Id: Iaf1f85eeb217d484997ee1367d91d461c1195bf4
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-10-19 22:03:41 +00:00
Rahul Chaudhry
e1682c71a1 check_seapp: cleanup warning caught by clang tidy / static analyzer.
check_seapp.c:993:6: warning: Passed-by-value struct argument contains
uninitialized data (e.g., field: 'data')

Bug: 26936282
Test: WITH_TIDY=1 WITH_STATIC_ANALYZER=1 mm
Change-Id: I3fc2ca8f862356628864f2a37b8d39222c8d658a
2016-10-12 12:27:29 -07:00
Rahul Chaudhry
66dd3ca6ce fc_sort: cleanup warnings caught by clang tidy / static analyzer.
Value stored to 'i' is never read.
Variable 'j' is never used.

Bug: 26936282
Test: WITH_TIDY=1 WITH_STATIC_ANALYZER=1 mm
Change-Id: I8dd266e639d089efd1fb1e1e0fca3899cf2a1553
2016-10-12 12:19:48 -07:00
Chad Brubaker
06cf31eb63 Rename autoplay_app to ephemeral_app
Test: Builds and boots
Change-Id: I3db64e12f0390c6940f5745eae83ce7efa7d65a9
2016-10-07 09:52:31 -07:00
Janis Danisevskis
3e4632943d fix lax service context lookup
Inform checkfc about new service label backend.

Test: bullhead builds

Bug: 31353148
Change-Id: I499da36108e67483a4f9a18fd8cc7c8f13419abd
2016-09-30 10:18:00 +01:00
bowgotsai
a6c215bcaf Clean up LOCAL_C_INCLUDES
It should be specified by LOCAL_EXPORT_C_INCLUDE_DIRS from the imported
libraries.

Change-Id: I5b01ac24763a75984227d77671def6561325b7cc
2016-09-23 09:21:25 +08:00
Janis Danisevskis
750d797b1c Port from pcre to pcre2 (Fix wrong merge decision)
Ports check_seapp to pcre2.

Change-Id: If3faac5b911765a66eab074f7da2511624c3fc97
2016-08-22 11:12:53 +01:00
Chih-hung Hsieh
b077a75646 Merge "Fix misc-macro-parentheses warnings." am: d62aa0b1a3
am: ebb3dc9ea0

* commit 'ebb3dc9ea0c29b2b56fcf9fae99d254c3a14359f':
  Fix misc-macro-parentheses warnings.

Change-Id: Id9658183b6cec0e5725c800d8939e57bf181c9e4
2016-05-16 16:23:46 +00:00
Chih-Hung Hsieh
33500c91e3 Fix misc-macro-parentheses warnings.
Add parentheses around macro arguments used beside binary operators.
Use NOLINT comment to suppress false clang-tidy warnings.

Bug: 28705665
Change-Id: Idc7474c43da52a1ca6a690b56d8f637767adbb88
2016-05-11 14:59:45 -07:00
dcashman
48a29397d2 Add cts artifact tag for use in CTS tests.
Bug: 21266225
Change-Id: I649c2ae36340d1f2b3db478e90e125c473b47b6e
2016-03-30 08:54:55 -07:00
William Roberts
d7eedeb89c checkseapp: remove .data = NULL assignments
Remove the .data=NULL assignments that were pushing the
static keymap mapping horizontal.

(cherry picked from commit 29adea51ed)

Change-Id: I2e6e78930ac8d1d8b9bd61d9dedb59f4859ea13c
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-02-10 19:37:20 +00:00
William Roberts
0593e848fa checkseapp: remove data types form static map
Data type tracking is no longer needed now that per
key validation routines are supported.

(cherry picked from commit c92dae9807)

Change-Id: I2f1d0d5b1713e0477996479b0f279a58f43f15c7
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-02-10 19:37:05 +00:00
William Roberts
7bbdaefc7f checkseapp: generalize input validation
Input validation was hard-coded into a validation routine
that would check against type and key names in a scattered,
order dependent conditional code block.

This makes it harder than it should be to add new key value
pairs and types into checkseapp.

To correct this, we add a validation callback into the
static mapping. If the validation callback is set, the
existing validation routine will call this for input
validation. On failure, a validation specific error message
is returned to be displayed.

(cherry picked from commit 696a66ba20)

Change-Id: I92cf1cdf4ddbcfae19168b621f47169a3cf551ac
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-02-10 19:36:48 +00:00
William Roberts
d5c3e50009 checkseapp: update error message output
Change the final error message to be consistent with the others.

From:
Error: reading /home/wcrobert/workspace/aosp/external/sepolicy/seapp_contexts, line 82, name domain, value system_server

To:
Error: Reading file: "/home/wcrobert/workspace/aosp/external/sepolicy/seapp_contexts" line: 82 name: "domain" value: "system_server"

(cherry picked from commit efebf97e23)

Change-Id: Idf791d28fbba95fbeed8b9ccec9a296eea33afb9
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-02-10 19:36:21 +00:00
William Roberts
ffd053ba93 checkseapp: declare internal function as static
(cherry picked from commit 25528cf4a5)

Change-Id: Ic4dc59650ca849b950cb145fedafdf4fc250f009
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-02-10 19:24:00 +00:00
William Roberts
29adea51ed checkseapp: remove .data = NULL assignments
Remove the .data=NULL assignments that were pushing the
static keymap mapping horizontal.

Change-Id: I2e6e78930ac8d1d8b9bd61d9dedb59f4859ea13c
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-01-29 15:12:58 -08:00
William Roberts
c92dae9807 checkseapp: remove data types form static map
Data type tracking is no longer needed now that per
key validation routines are supported.

Change-Id: I2f1d0d5b1713e0477996479b0f279a58f43f15c7
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-01-29 11:05:57 -08:00
William Roberts
696a66ba20 checkseapp: generalize input validation
Input validation was hard-coded into a validation routine
that would check against type and key names in a scattered,
order dependent conditional code block.

This makes it harder than it should be to add new key value
pairs and types into checkseapp.

To correct this, we add a validation callback into the
static mapping. If the validation callback is set, the
existing validation routine will call this for input
validation. On failure, a validation specific error message
is returned to be displayed.

Change-Id: I92cf1cdf4ddbcfae19168b621f47169a3cf551ac
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-01-29 10:53:16 -08:00
William Roberts
efebf97e23 checkseapp: update error message output
Change the final error message to be consistent with the others.

From:
Error: reading /home/wcrobert/workspace/aosp/external/sepolicy/seapp_contexts, line 82, name domain, value system_server

To:
Error: Reading file: "/home/wcrobert/workspace/aosp/external/sepolicy/seapp_contexts" line: 82 name: "domain" value: "system_server"

Change-Id: Idf791d28fbba95fbeed8b9ccec9a296eea33afb9
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-01-29 10:51:00 -08:00
William Roberts
25528cf4a5 checkseapp: declare internal function as static
Change-Id: Ic4dc59650ca849b950cb145fedafdf4fc250f009
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-01-29 10:51:00 -08:00
Jeffrey Vander Stoep
7a29402717 Merge changes from topic \'fc_sort-2\' am: 87a73f199a
am: af77ab6b13

* commit 'af77ab6b136b0c4d44e912bbd2b98f958f7ceb45':
  fc_sort: initial commit
  checkfc: do not die on 0 length fc's
2016-01-15 19:41:30 +00:00
William Roberts
49693f1b4d fc_sort: initial commit
Ordering matters in fc files; the last match wins. In builds where
many BOARD_SEPOLICY_DIRS are set, the order of that list becomes
increasingly important in order to maintain a cohesive built
file_contexts.

To correct this, we sort the device specific file_contexts entries
with the upstream fc_sort tool.

Change-Id: I3775eae11bfa5905cad0d02a0bf26c76ac03437c
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-01-14 17:39:07 -08:00
William Roberts
922b4e9522 checkfc: do not die on 0 length fc's
Checkfc was treating 0 size fc files as a fatal error.
An empty fc file should be treated as "nothing to check"
so long as the -e option is passed.

We add this option, so we don't allow empty file_context
files to pass CTS checking.

Change-Id: Ibca6bd948a13389e10c605d613acc48c5504443e
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-01-14 17:39:07 -08:00
Jeffrey Vander Stoep
b9053767ab Merge "Revert "fc_sort: initial commit"" am: 5de7574a59
am: 62871e5874

* commit '62871e5874e6b1663c732c7f2a2b2d6b36604534':
  Revert "fc_sort: initial commit"
2016-01-15 01:12:54 +00:00
Jeffrey Vander Stoep
5de7574a59 Merge "Revert "fc_sort: initial commit"" 2016-01-14 23:30:56 +00:00
Jeffrey Vander Stoep
b1fb7e4037 Revert "fc_sort: initial commit"
Breaks builds with no device specific policy.

Bug: 26568553
This reverts commit 29d146887e.

Change-Id: If9254d4ad3f104a96325beedebc05dd22664084a
2016-01-14 23:28:51 +00:00
William Roberts
2f9fbf53e9 fc_sort: add NOTICE file am: c68a277f5e
am: bc88ec944a

* commit 'bc88ec944a0e6f22983fa31803b75d99ea791735':
  fc_sort: add NOTICE file
2016-01-14 20:54:01 +00:00
Jeffrey Vander Stoep
a654d9f3aa Merge "fc_sort: initial commit" am: 2dea4525f3
am: faddabe6f5

* commit 'faddabe6f58f30f81938b928597ee7a792c34984':
  fc_sort: initial commit
2016-01-14 20:19:47 +00:00
William Roberts
c68a277f5e fc_sort: add NOTICE file
Change-Id: I0e63f90cafc5b1ca9cc112e852e172046b16a17e
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-01-14 10:45:45 -08:00
William Roberts
29d146887e fc_sort: initial commit
Ordering matters in fc files; the last match wins. In builds where
many BOARD_SEPOLICY_DIRS are set, the order of that list becomes
increasingly important in order to maintain a cohesive built
file_contexts.

To correct this, we sort the device specific file_contexts entries
with the upstream fc_sort tool.

Change-Id: Id79cc6f434c41179d5c0d0d739c4718918b0b1dc
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-01-07 10:11:52 -08:00
Jeffrey Vander Stoep
e927937f2d Merge "checkfc: add attribute test" am: d48773ab3e
am: c435b7590b

* commit 'c435b7590bd7d7f0594d48976fe931d1f6c07f32':
  checkfc: add attribute test
2015-12-16 16:35:36 +00:00
William Roberts
ad3cb39e54 checkfc: add attribute test
Enable checkfc to check *_contexts against a set of valid attributes
which must be associated with all types in the contexts file that
is being checked.

Since it's imperative that checkfc knows which file its checking to
choose the proper attribute set, the -s option is introduced to
indicate the service_contexts file. The property_contexts file continues
to use the existing -p and file_contexts requires no specification, aka
it's the default.

Failure examples:
file_contexts:
Error: type "init" is not of set: "fs_type, dev_type, file_type"

service_contexts:
Error: type "init_exec" is not of set: "service_manager_type"

property_contexts:
Error: type "bluetooth_service" is not of set: "property_type"

Change-Id: I62077e4d0760858a9459e753e14dfd209868080f
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2015-12-14 23:37:10 +00:00
Jeff Vander Stoep
400d3ac140 Add autoplay_app domain
Initial check in of empty autoplay_app.te policy file.

Create isAutoPlayApp input selector. Give this selector high precedence -
only below isSystemServer.

Add neverallow rule disallowing an app context with isAutoPlayApp=true from
running in a domain other than autoplay_app.

Change-Id: I1d06669d2f1acf953e50867dfa2b264ccaee29a4
2015-11-09 13:43:55 -08:00
Jeff Vander Stoep
ee9c0b5fb6 Add priv_app domain to global seapp_context
Assign priviliged apps not signed with the platform key to the priv_app
domain.

Bug: 22033466
Change-Id: Idf7fbe7adbdc326835a179b554f96951b69395bc
2015-10-14 21:23:54 +00:00
Stephen Smalley
13b6b7e88f checkfc: add support for comparing two file_contexts files.
Extend checkfc to support comparing two file_contexts or
file_contexts.bin files.  This is for use by the CTS
SELinuxHostTest to compare the AOSP general_file_contexts
with the device file_contexts.bin file.

Depends on I0fe63e0c7f11ae067b5aac2f468f7842e5d76986.

Change-Id: I2fff2f8cf87690a76219ddf4cf38939650f34782
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-08-12 18:37:02 +00:00
William Roberts
81e1f90cd1 check_seapp: add support for "neverallow" checks
Introduce "neverallow" rules for seapp_contexts. A neverallow rule is
similar to the existing key-value-pair entries but the line begins
with "neverallow". A neverallow violation is detected when all keys,
both inputs and outputs are matched. The neverallow rules value
parameter (not the key) can contain regular expressions to assist in
matching. Neverallow rules are never output to the generated
seapp_contexts file.

Also, unless -o is specified, checkseapp runs in silent mode and
outputs nothing. Specifying - as an argument to -o outputs to stdout.

Sample Output:
Error: Rule in File "external/sepolicy/seapp_contexts" on line 87: "user=fake domain=system_app type=app_data_file" violates neverallow in File "external/sepolicy/seapp_contexts" on line 57: "user=((?!system).)* domain=system_app"

Change-Id: Ia4dcbf02feb774f2e201bb0c5d4ce385274d8b8d
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2015-06-25 23:53:46 +00:00
William Roberts
7d65b547d3 check_seapp: mac build memory leak
rule_map_free() took as a parameter a boolean menu rule_map_switch
that was used to determine if it should free the key pointer that
is also in the table. On GLIBC variants, calls to hdestroy do not
free the key pointer, on NON-GLIBC variants, it does. The original
patch was meant to correct this, however, it always passes "destroy"
as the rule_map_switch. On GLIBC variants this is fine, however on
NON-GLIBC variants, that free was compiled out, and the free() was
handled by hdestroy. In cases of failure where the rule_map was not
in the htable, those key's were not properly free'd.

Change-Id: Ifdf616e09862bca642a4d31bf0cb266168170e50
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2015-06-23 12:25:35 -07:00
William Roberts
f26b6d427c drop unused option -s
Change-Id: I00aa4eeaf569c8108a7b6aab190be68e53b46597
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2015-06-23 10:23:01 -07:00
William Roberts
8d3a1b558e correct all error messages
When an error occured it was erroneously being indicated that he
file was the output file, not the input file.

Before:
Error: Could not find selinux type "fake_app" on line: 51 in file: out/target/product/flo/obj/ETC/seapp_contexts_intermediates/seapp_contexts
Error: Could not validate
Error: reading out/target/product/flo/obj/ETC/seapp_contexts_intermediates/seapp_contexts.tmp, line 51, name levelFrom, value user

After:
Error: Could not find selinux type "fake_app" on line: 51 in file: out/target/product/flo/obj/ETC/seapp_contexts_intermediates/seapp_contexts.tmp
Error: Could not validate
Error: reading out/target/product/flo/obj/ETC/seapp_contexts_intermediates/seapp_contexts.tmp, line 51, name levelFrom, value user

Change-Id: Ib0e01f1f0ef563a2a150a0a3b4012e6e15d736bb
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2015-06-19 09:14:40 -07:00
William Roberts
773d412665 check_seapp: Correct output on duplicate entries
If a duplicate entry is found, rule_map_cmp() incorrectly
assumes that the lengths of the key value pairs should be
equal, when this is not true. The duplicate detection is
done on the input parameters, thus the lengths can be
different. This resulted in a duplicate error string
message of "do not match", instead of "match on all inputs".

Also, the file name printed that contained the error was
the output file, not the input file that contained it.

Change-Id: I9b3f99fa4aa3454849de55f18b198b0b56e44320
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2015-06-11 17:21:06 -07:00
dcashman
96136d847d sepolicy-analyze: use headers from common selinux project.
Point to external/selinux/libsepol instead of external/libsepol.

Change-Id: I09c33a4cbd7b4cd3ef2341c042259b96c0b59372
2015-06-10 10:42:41 -07:00
Jeff Vander Stoep
53b480137f tools: use headers from common selinux project
Point to external/selinux/libsepol instead of external/libsepol

Change-Id: If6dc1e9261f397d801ba2376ab60c5dc5b5d86e4
2015-06-09 12:56:26 -07:00
dcashman
28acbeab18 Fix sepolicy-analyze libc++.so loading issue w/CTS.
Addresses the following error when running CTS on master:
junit.framework.AssertionFailedError: The following errors were encountered when validating the SELinuxneverallow rule:
neverallow { appdomain -bluetooth } self:capability *;
/tmp/SELinuxHostTest5593810182495331783.tmp: error while loading shared libraries: libc++.so: cannot open shared object file: No such file or directory

Also indicate that none of the sepolicy tools need c++ std lib.

(cherry-pick of 0cdb0517be696c0dc6882d289eedd45bf2da918c now made possible by
addition of commit: 28b72eddd54cb1287dd7daae853e8e4b78fa17eb)

Bug: 19617220
Change-Id: I2c5b7ab1ddeb0e02cbaad2b7d5430a0974524a89
2015-05-12 11:06:44 -07:00
Dan Albert
0d3bf4beac Revert "Fix sepolicy-analyze libc++.so loading issue w/CTS."
This is causing more harm than good. We'll just make these all link
libc++ again and work out the CTS issues if they still exist.

Bug: 19778891

This reverts commit 3812cf58cb.

Change-Id: Iaea8f6acb147da4275633a760ccb32951db7f8b6
2015-03-17 11:41:04 -07:00
Dan Albert
f0852340af Revert "Don't use address sanitizer for selinux tools."
This is causing more harm than good. We'll just make these all link
libc++ again (another revert) and work out the CTS issues if they still
exist.

Bug: 19778891

This reverts commit a5113a1500.

Change-Id: I35a4c93dae4abb66e3525451d5ce01e33a540895
2015-03-17 17:38:55 +00:00
Dan Albert
a5113a1500 Don't use address sanitizer for selinux tools.
Address sanitizer requires using libc++ (apparently). We removed
libc++ from these projects since they were C and the SDK/CTS was not
able to find libc++.

If we're interested in continuing to use ASAN on these tools
(probably), we should turn libc++ back on once we're sure CTS won't
die.

Bug: 19778891
Change-Id: I3c1913171a15396ead73277ec1186fead730f66d
2015-03-16 17:39:40 -07:00
dcashman
3812cf58cb Fix sepolicy-analyze libc++.so loading issue w/CTS.
Addresses the following error when running CTS on master:
junit.framework.AssertionFailedError: The following errors were encountered when validating the SELinuxneverallow rule:
neverallow { appdomain -bluetooth } self:capability *;
/tmp/SELinuxHostTest5593810182495331783.tmp: error while loading shared libraries: libc++.so: cannot open shared object file: No such file or directory

Also indicate that none of the sepolicy tools need c++ std lib.

Bug: 19617220

Change-Id: I713b3cbd1220655413d399c7cd2b0b50459a5485
2015-03-16 13:07:46 -07:00
Stephen Smalley
0233cd800e sepolicy-analyze: Add attribute command.
Add an attribute command to sepolicy-analyze for displaying the list
of types associated with an attribute in a policy.  This is for use
by CTS to check what domains and types are associated with certain
attributes such as mlstrustedsubject and mlstrustedobject.

Change-Id: Ie19361c02feb1ad14ce36862c6aace9e66c422bb
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-03-13 12:22:39 -04:00
Stephen Smalley
d155914479 sepolicy-analyze: Change booleans command to be more test-friendly.
Instead of displaying the boolean count, display a list of booleans
defined in the policy, if any.  This makes sepolicy-analyze booleans
consistent with sepolicy-analyze permissive and allows automated tests
to simply check whether there was any output at all.

Change-Id: I221b60d94e6e7f6d80399bf0833887af3747fe83
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-03-12 10:01:49 -04:00
Stephen Smalley
a7b2c5f4ab sepolicy-analyze: Implement booleans test.
Implement the booleans test in sepolicy-analyze so
that we can move the no-booleans check from the
SELinuxTest to the SELinuxHostTest along with the
other policy checks.

Change-Id: I95d7ad34da10c354470f43734d34a6ec631a7b4e
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-03-11 17:03:42 -04:00
Stephen Smalley
a02dbf4ee3 am 884ee2a6: checkseapp, seapp_contexts: drop sebool= support.
* commit '884ee2a61cc78ddaaf54b812932730045dd155c3':
  checkseapp, seapp_contexts:  drop sebool= support.
2015-02-24 00:39:50 +00:00
Stephen Smalley
afc841af8d am 534fb071: checkseapp: Detect duplicate keys in seapp_contexts entries.
* commit '534fb0711d95615a77af23ffe643e8b720a527e6':
  checkseapp:  Detect duplicate keys in seapp_contexts entries.
2015-02-24 00:39:49 +00:00
Stephen Smalley
884ee2a61c checkseapp, seapp_contexts: drop sebool= support.
SELinux policy booleans are prohibited in AOSP, so we can drop the
support for the sebool= input selector.

Change-Id: I5ae31247b2f68d90f6ae4c8830458f22c4ffc854
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-02-24 00:36:24 +00:00
Stephen Smalley
534fb0711d checkseapp: Detect duplicate keys in seapp_contexts entries.
Presently it ignores duplicate keys in seapp_contexts entries, e.g.
if you were to specify:

user=system seinfo=platform user=bluetooth domain=system_app type=system_app_data_file

checkseapp would ignore the duplicate and libselinux would end up using
the last value defined for the key in each line.

Change-Id: I18cadb0c1bf5a907e6fc6513df65aafed91d76fe
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-02-24 00:35:23 +00:00
Nick Kralevich
29d2a05b78 am c6a0feb4: Merge "checkseapp: Detect duplicate entries within seapp_contexts."
* commit 'c6a0feb44d3f9bb1f30671dad298040c594a2fe6':
  checkseapp:  Detect duplicate entries within seapp_contexts.
2015-02-24 00:05:53 +00:00
Stephen Smalley
0b820042e4 checkseapp: Detect duplicate entries within seapp_contexts.
Presently it only detects complete duplicates if you specify -s (strict),
which is not used in the external/sepolicy Makefile, and it allows
overriding earlier entries that have the same input selectors (e.g.
user=, seinfo=) with different values for the output selectors (e.g.
domain=, type=).  Thus, a device/<vendor>/<board>/sepolicy/seapp_contexts
file can override the external/sepolicy definitions, and even a single
seapp_contexts file can contain duplicated or conflicting definitions.

Make it always check strictly, and prohibit either duplicates on the
input selectors (i.e. overrides) or complete duplicates (redundant).

Change-Id: Id1e38133cbe31b796253101cfe3b111d1826bc8c
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-02-13 14:58:31 -05:00
dcashman
96550ed453 am 6b111e47: am 3b0988c5: Merge "Adjust sepolicy-analyze to reflect libsepol changes."
* commit '6b111e4761bf960e9f0010a7e9320eab83ca052e':
  Adjust sepolicy-analyze to reflect libsepol changes.
2015-01-13 23:26:10 +00:00
dcashman
0de2b45f63 Adjust sepolicy-analyze to reflect libsepol changes.
Commit dc0ab516f11d8e2c413315e733e25a41ba468e4f changed the libsepol
structures on which sepolicy-analyze relies so that it could be compiled
as a C++ library.  Reflect this change in sepolicy-analyze.

Change-Id: I7da601767c3a4ebed7274e33304d8b589a9115fe
2014-12-22 15:31:38 -08:00
dcashman
264dc2a8b3 resolved conflicts for merge of 598b87c2 to lmp-mr1-dev-plus-aosp
Change-Id: If652f7e81a2589647a7d0d697b2130f8bf32c513
2014-12-02 14:10:09 -08:00
William Roberts
47c1461156 Fix sepolicy-analyze build with different toolchains
host C: sepolicy-analyze <= external/sepolicy/tools/sepolicy-analyze/sepolicy-analyze.c
external/sepolicy/tools/sepolicy-analyze/sepolicy-analyze.c: In function 'usage':
external/sepolicy/tools/sepolicy-analyze/sepolicy-analyze.c:30:5: error: 'for' loop initial declarations are only allowed in C99 mode
external/sepolicy/tools/sepolicy-analyze/sepolicy-analyze.c:30:5: note: use option -std=c99 or -std=gnu99 to compile your code
make: *** [out/host/linux-x86/obj/EXECUTABLES/sepolicy-analyze_intermediates/sepolicy-analyze.o] Error 1

Change-Id: I9222e447b032d051c251c9718e2b8d5ffb9e9c35
2014-12-01 11:45:54 -08:00
Dan Albert
460c3f1630 resolved conflicts in merge of 3fa92bed to lmp-mr1-dev-plus-aosp
Change-Id: I5630bddc1dd2f5ce9d9f6091903c0cf6cafc38ca
2014-11-20 18:26:58 -08:00
Narayan Kamath
f639e96b2b Undo idiotic build fix.
Just remove unused variables instead of making them refer to
the wrong statics.

Change-Id: I314bfe91b7912f7d8c9cba7dd55a76d72c879a51
2014-11-20 12:07:33 +00:00
Narayan Kamath
012dd73460 Fix build.
Introduced by the merge conflict resolution for
3a1eb33be6.

Change-Id: Iddbc9e4d83c513d7003102f881793b5b7945566c
2014-11-20 11:44:54 +00:00
dcashman
3fa92beda7 Accept command-line input for neverallow-check.
Also, divide each sepolicy-analyze function into its own component for simplified
command-line parsing and potentially eventual modularization.
Bug: 18005561

Cherry-pick from: https://android-review.googlesource.com/#/c/111626/

Change-Id: I751a99feffe820308ec58514fdba4cdef184d964
2014-11-19 15:44:14 -08:00
dcashman
fe0d6cb8f7 resolved conflicts for merge of 3a1eb33b to lmp-mr1-dev-plus-aosp
Change-Id: I5cdc157157b6ed382e4827406bce7406fc2c3e3a
2014-11-19 14:07:41 -08:00