Commit Graph

146 Commits

Author SHA1 Message Date
Jeff Vander Stoep
be6489d1bf tools/build_policies.sh make tool executable
chmod +x

Test: build all sepolicy targets.
Change-Id: I9e47b78667e4a213c31ecce0e37fe7f84abd9655
2018-01-30 10:08:34 -08:00
Joel Galenson
c17c5abe22 Add a script to build multiple SELinux targets.
This script will build the SELinux policy for multiple targets in parallel.

To use it, run:
./build_policies.sh <Android root directory> <output directory> [specific targets to build]

If you do not pass any individual targets, it will build all targets it can find.

It will print out the list of failing targets.  You can open up the corresponding log file in the output directory to see the exact errors.

This script is still a work in progress.  It currently cannot discover all build targets (it misses ones "lunch" does not list).

Bug: 33463570
Test: Ran script to build multiple targets with and without failures.
Change-Id: Iee8ccf4da38e5eb7ce2034431613fe10c65696ab
2018-01-29 15:48:15 -08:00
Jaekyun Seok
e49714542e Whitelist exported platform properties
This CL lists all the exported platform properties in
private/exported_property_contexts.

Additionally accessing core_property_type from vendor components is
restricted.
Instead public_readable_property_type is used to allow vendor components
to read exported platform properties, and accessibility from
vendor_init is also specified explicitly.

Note that whitelisting would be applied only if
PRODUCT_COMPATIBLE_PROPERTY is set on.

Bug: 38146102
Test: tested on walleye with PRODUCT_COMPATIBLE_PROPERTY=true
Change-Id: I304ba428cc4ca82668fec2ddeb17c971e7ec065e
2018-01-10 16:15:25 +00:00
Xin Li
c667a0ed64 Merge commit 'd9664064dd09ae254aa3e6ce28fec5fde68c1fb6' into HEAD
Change-Id: Icec8dfff5cff17cf1b557882db62b148a7218b98
2017-11-14 11:46:58 -08:00
Treehugger Robot
0d2303be0c Merge "Use -Werror in system/sepolicy" 2017-10-19 22:53:57 +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