Commit graph

766 commits

Author SHA1 Message Date
Dan Cashman
6cef90d0ee Merge remote-tracking branch 'aosp/upstream-master' into mymerge
am: 8f76b0cd3e

Change-Id: Ia92454d490cc9d14ecd7f07462550955fa12f1e5
2017-09-20 00:28:55 +00:00
Dan Cashman
8f76b0cd3e Merge remote-tracking branch 'aosp/upstream-master' into mymerge
Test: Builds.
Change-Id: I5069d965a008bb9b27a6652794ea76131949f35f
2017-09-19 14:25:41 -07:00
Yifan Hong
fa0823f66a Merge "Fix libselinux_vendor private header dependencies."
am: bf3627db98

Change-Id: I89c9f62c744d8582ff07f6d0052ed5e2a04c26b9
2017-09-11 21:23:41 +00:00
Treehugger Robot
bf3627db98 Merge "Fix libselinux_vendor private header dependencies." 2017-09-11 20:48:49 +00:00
Martijn Coenen
742d0341ad Don't load nonplat_service_contexts on full-treble.
am: 57fdb1f490

Change-Id: Ic964603c3efff7a7127454cd4c1310721834cea9
2017-09-11 03:12:20 +00:00
Yifan Hong
1e5bced8e3 Fix libselinux_vendor private header dependencies.
Do not include private/android_filesystem_config.h
for libselinux_vendor.

Test: mma -j
Test: BOARD_VNDK_VERSION=current mma -j

Bug: 33241851

Change-Id: I4f4328dceaa8609d1891b4b7129669ad7040865a
Merged-In: I4f4328dceaa8609d1891b4b7129669ad7040865a
2017-09-06 10:35:40 -07:00
Martijn Coenen
57fdb1f490 Don't load nonplat_service_contexts on full-treble.
On full Treble devices, servicemanager should only
host services served from processes on /system; don't load
nonplat_service_contexts.

Bug: 36866029
Test: builds, boot Taimen, boot Sailfish
Change-Id: Ia093c4c6b342335e35648db35e340e2df54fdcf3
Merged-In: Ia093c4c6b342335e35648db35e340e2df54fdcf3
(cherry picked from commit e3ab0e6086)
2017-09-04 15:25:14 +08:00
Stephen Smalley
53bb2a11c2 checkpolicy,libselinux,libsepol,policycoreutils: Update my email address
Update my email address since epoch.ncsc.mil no longer exists.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2017-08-17 14:17:12 -04:00
Dan Cashman
3f0188ace1 Merge remote-tracking branch 'aosp/upstream-master' into mymerge am: 706ddd16f3 am: 252a2d8491
am: 9a15d4fc09

Change-Id: I3799a8a8d953ebd70ba0e70a3d957fe7de6d462b
2017-08-08 16:15:20 +00:00
Dan Cashman
252a2d8491 Merge remote-tracking branch 'aosp/upstream-master' into mymerge
am: 706ddd16f3

Change-Id: Id7b2cc66a458099db4da93373b6ef02d124e7ee4
2017-08-08 16:09:21 +00:00
Dan Cashman
706ddd16f3 Merge remote-tracking branch 'aosp/upstream-master' into mymerge
Bug: 63861738
Test: Builds 'n' boots
Change-Id: Idfb333d4cc1568dd2273f74731f12d52a413c07b
2017-08-07 17:00:18 -07:00
Stephen Smalley
1bac758bf6 Update VERSION files for 2.7 release.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2017-08-04 09:31:00 -04:00
Stephen Smalley
dfda6a5b2c Update VERSION files for 2.7-rc6
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2017-07-28 15:43:47 -04:00
Tom Cherry
00548bd9b6 libselinux: fix thread safety issues with lookup_common()
There are two problems with lookup_common() and therefore
selabel_lookup() and related functions that this patch fixes:

1) A race with the lazy compilation of regexes.  Since the struct
regex_data is allocated and assigned immediately to the parent struct
spec, it's possible for a second thread to see that this pointer is
non-NULL before the regex compilation has finished.  This typically
results in a -1 return from selabel_lookup() with ENOENT as errno.

This is fixed by adding synchronization in compile_regex().

2) A race with PCRE2 regex_match().  A struct pcre2_match_data is
created once and used for all regex matches for a given regex.  This
is problematic if two threads are attempting to evaluate the same
regex simultaneously.  This typically results in a successful return
from selabel_lookup() but with an erroneous selabel.

This is fixed by adding a pthread_mutex within regex_match() for
PCRE2.  Note, on my system, creating new matchdata takes roughly an
order of magnitude more time than locking a non-contended
pthread_mutex.  I don't believe programs will have enough contention
on this lock to justify that cost.

Bug: 63861738
Test: ueventd unit tests
Change-Id: I13bf782d81d0a0b896d444e396f307ad0dbacb6a
2017-07-26 16:23:04 -04:00
Stephen Smalley
9f1730fa39 Update VERSION files for 2.7-rc5
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2017-07-18 12:01:26 -04:00
Jeff Vander Stoep
1c0809536f Fix bad merge
Change 1df580a30 incorrectly modified the file_contexts file name.
Fix it.

Bug: 63636472
Test: dimitrysh to test
Change-Id: I669d1f627eb9e52b8090da14976f10e151739902
(cherry picked from commit c62f2ae838)
2017-07-13 13:30:17 -07:00
Yifan Hong
c1c42e03ce Fix libselinux => liblog dependencies
am: 8a7da2c85b

Change-Id: I6b4ef64281179208f8649b736248f15ae2ba4a13
2017-07-10 21:49:35 +00:00
Yifan Hong
3fc5ae6721 NO PARTIAL RERUN Fix libselinux => liblog dependencies
LOG_EVENT_STRING is not defined for liblog.vendor. Don't use it
for libselinux_vendor.

Test: mma -j
Test: BOARD_VNDK_VERSION=current mma -j

Bug: 63034227
Merged-In: Ibb653dac74da1ad678ccd5fabba97ab9bd0f0c38
(cherry picked from commit 09dff7c3a5)

Change-Id: Ia4cd612333c35b375c03dd68d586e6f167eb26c2
2017-07-10 21:43:49 +00:00
Yifan Hong
91311f1e7f Export dummy functions for libselinux_vendor
The following functions are exported in libselinux_vendor, but
simply returns an error:

selinux_android_prop_context_handle
selinux_android_restorecon

Bug: 62886649
Test: BOARD_VNDK_VERSION=current m libselinux_vendor -j
Test: m libselinux_vendor -j
Test: device boots
Change-Id: If42b6cb1bf9ffb3dd04f557279efdc37e1ac259a
Merged-In: If42b6cb1bf9ffb3dd04f557279efdc37e1ac259a
(cherry picked from commit 1e8760189d)
2017-07-10 21:16:26 +00:00
Yifan Hong
8a7da2c85b Fix libselinux => liblog dependencies
LOG_EVENT_STRING is not defined for liblog.vendor. Don't use it
for libselinux_vendor.

Test: mma -j
Test: BOARD_VNDK_VERSION=current mma -j

Bug: 63034227
Change-Id: Ibb653dac74da1ad678ccd5fabba97ab9bd0f0c38
(cherry picked from commit 09dff7c3a5)
2017-07-10 11:50:29 -07:00
Yifan Hong
030fd08a36 Export dummy functions for libselinux_vendor
The following functions are exported in libselinux_vendor, but
simply returns an error:

selinux_android_prop_context_handle
selinux_android_restorecon

Bug: 62886649
Test: BOARD_VNDK_VERSION=current m libselinux_vendor -j
Test: m libselinux_vendor -j
Test: device boots
Change-Id: If42b6cb1bf9ffb3dd04f557279efdc37e1ac259a
Merged-In: If42b6cb1bf9ffb3dd04f557279efdc37e1ac259a
(cherry picked from commit 1e8760189d)
2017-07-10 11:50:17 -07:00
Jeff Vander Stoep
26b3d92303 sefcontext_compile: migrate to soong
Bug: 37512442
Test: build and boot Marlin.
Test: "bpfmt -w Android.bp"

(cherry-pick from commit 16e4a8dab3)

Change-Id: I0c7b31ad55a89b5d94b0b9a76eacdf5c99869561
Merged-In: Ib5a0aa8eb29457e3191bad12229a0a4171daa6b6
2017-07-10 10:49:44 -07:00
Sandeep Patil
1df99aee99 move file_context APIs out of libselinux_vendor
Also make sure label_file.c is compiled in all targets that libselinux
is built for.

Bug: 37343404
Bug: 37919668
Test: Build and boot

(cherry-pick from commit 554b7e4e82)

Change-Id: I19183fa192afb29ea75f40c0abf1e684b5550d2a
Merged-In: I49259c6cd6543329fe399fc92e07f16dc54c6395
2017-07-10 10:49:39 -07:00
Sandeep Patil
367917eca1 Do not use PCRE2 in libselinux_vendor
Also make sure regex.c is compiled for all targets that libselinux is
built for.

Bug: 37919668
Bug: 37343404
Test: Build and boot

(cherry-pick from commit a1b5897b8b)

Change-Id: I7eaf2733cdc0f8c72239fa6186e21bacc18b6d2f
Merged-In: Ie73cf85aeffcccb1a8bd1fcfafdd555678f9badc
2017-07-10 10:49:33 -07:00
Sandeep Patil
1df580a30c move selinux policy loading APIs to platform libselinux
Bug: 37919668
Bug: 37343404
Test: build and boot

(cherry-pick from commit 43d548e365)

Change-Id: I43779180fdd00f430de0557860c6264543b018d6
Merged-In: If0de84db4052c86350001de11fc804d9daca1630
2017-07-10 10:49:27 -07:00
Sandeep Patil
b61eb368a0 refactor: move common parts of libselinux builds into defaults
Bug: 37343404
Bug: 37919668
Test: Build and boot

(cherry-picked from commit 51428ba055)

Change-Id: I5e94788cac0c1574a74d75d9bd10589a760c4782
Merged-In: If42d24d381839c2a39f8cff3fc82ce5d3073eeb7
2017-07-10 10:49:22 -07:00
Vijay Venkatraman
7dd9343d85 Add libselinux_vendor
Removed dependency on libpackageparser
Retained dependency on libpcre2

android_seapp.c = non-vendor functions
android.c = functions common to vendor and non-vendor

exported_vendor.map contains map for libselinux_vendor

(cherry-picked from commit cc1666de05)

Bug: 37343404
Test: Build vndservicemanager, libselinux.so and libselinux_vendor.so
Verify normal boot on sailfish and pass CTS Security

Change-Id: I3421d73b0f51bd714b5889fc3eef5b161dea9bac
Merged-In: I0ffc621ceb53b3531df458611f1322ebecd2da20
2017-07-10 10:49:16 -07:00
Jeff Vander Stoep
fe47ca9315 resolve merge conflicts of 7e29d177 to stage-aosp-master
Test: build
Merged-In: If42b6cb1bf9ffb3dd04f557279efdc37e1ac259a
Change-Id: Ic30cc01f0abc26347d3747b51d1998f7815fea99
2017-07-10 00:17:43 +00:00
Jeff Vander Stoep
170cc72748 sefcontext_compile: migrate to soong
Bug: 37512442
Test: build and boot Marlin.
Test: "bpfmt -w Android.bp"

(cherry-pick from commit 16e4a8dab3)

Change-Id: I0c7b31ad55a89b5d94b0b9a76eacdf5c99869561
Merged-In: Ib5a0aa8eb29457e3191bad12229a0a4171daa6b6
2017-07-07 18:13:03 -07:00
Sandeep Patil
3a5f579d2d move file_context APIs out of libselinux_vendor
Also make sure label_file.c is compiled in all targets that libselinux
is built for.

Bug: 37343404
Bug: 37919668
Test: Build and boot

(cherry-pick from commit 554b7e4e82)

Change-Id: I19183fa192afb29ea75f40c0abf1e684b5550d2a
Merged-In: I49259c6cd6543329fe399fc92e07f16dc54c6395
2017-07-07 18:13:03 -07:00
Sandeep Patil
f1c7dca201 Do not use PCRE2 in libselinux_vendor
Also make sure regex.c is compiled for all targets that libselinux is
built for.

Bug: 37919668
Bug: 37343404
Test: Build and boot

(cherry-pick from commit a1b5897b8b)

Change-Id: I7eaf2733cdc0f8c72239fa6186e21bacc18b6d2f
Merged-In: Ie73cf85aeffcccb1a8bd1fcfafdd555678f9badc
2017-07-07 18:13:03 -07:00
Sandeep Patil
c102ca6452 move selinux policy loading APIs to platform libselinux
Bug: 37919668
Bug: 37343404
Test: build and boot

(cherry-pick from commit 43d548e365)

Change-Id: I43779180fdd00f430de0557860c6264543b018d6
Merged-In: If0de84db4052c86350001de11fc804d9daca1630
2017-07-07 18:13:03 -07:00
Sandeep Patil
64f6e81078 refactor: move common parts of libselinux builds into defaults
Bug: 37343404
Bug: 37919668
Test: Build and boot

(cherry-picked from commit 51428ba055)

Change-Id: I5e94788cac0c1574a74d75d9bd10589a760c4782
Merged-In: If42d24d381839c2a39f8cff3fc82ce5d3073eeb7
2017-07-07 18:13:02 -07:00
Vijay Venkatraman
96f9b254cd Add libselinux_vendor
Removed dependency on libpackageparser
Retained dependency on libpcre2

android_seapp.c = non-vendor functions
android.c = functions common to vendor and non-vendor

exported_vendor.map contains map for libselinux_vendor

(cherry-picked from commit cc1666de05)

Bug: 37343404
Test: Build vndservicemanager, libselinux.so and libselinux_vendor.so
Verify normal boot on sailfish and pass CTS Security

Change-Id: I3421d73b0f51bd714b5889fc3eef5b161dea9bac
Merged-In: I0ffc621ceb53b3531df458611f1322ebecd2da20
2017-07-07 18:12:36 -07:00
Yifan Hong
7e29d17754 Export dummy functions for libselinux_vendor
The following functions are exported in libselinux_vendor, but
simply returns an error:

selinux_android_prop_context_handle
selinux_android_restorecon

Bug: 62886649
Test: BOARD_VNDK_VERSION=current m libselinux_vendor -j
Test: m libselinux_vendor -j
Test: device boots
Change-Id: If42b6cb1bf9ffb3dd04f557279efdc37e1ac259a
Merged-In: If42b6cb1bf9ffb3dd04f557279efdc37e1ac259a
(cherry picked from commit 1e8760189d)
2017-07-07 17:22:11 +00:00
Martijn Coenen
4b5cfdcd0a Add a method to load vendor_service_context only.
This is used by vndservicemanager, which will only
have access to the vndservice_contexts on the vendor
partition.

Bug: 36052864
Test: vndservicemanager can load the context

(cherry-pick from commit 69e45cdfee)

Change-Id: I26ebf40906d6c56a3cfa4a20b731e101614fe6e6
Merged-In: Ifd5caa4f74236184ef970ce39a8be227c50b48d4
2017-07-06 14:56:19 -07:00
Sandeep Patil
1006dc84a0 Do not use PCRE2 in libselinux_vendor
Also make sure regex.c is compiled for all targets that libselinux is
built for.

Bug: 37919668
Bug: 37343404
Test: Build and boot

(cherry-pick from commit a1b5897b8b)

Change-Id: Ie73cf85aeffcccb1a8bd1fcfafdd555678f9badc
Merged-In: I6bcced2d3675899cf976ad3cd30e591539d2aaa1
2017-07-06 14:56:18 -07:00
Sandeep Patil
73c8059639 move file_context APIs out of libselinux_vendor
Also make sure label_file.c is compiled in all targets that libselinux
is built for.

Bug: 37343404
Bug: 37919668
Test: Build and boot

(cherry-pick from commit 554b7e4e82)

Change-Id: I49259c6cd6543329fe399fc92e07f16dc54c6395
Merged-In: I7e06ad6cad13d157ba1fb6bfd23ce9ceddf3ba79
2017-07-06 14:55:39 -07:00
Sandeep Patil
5ec3b433ee move selinux policy loading APIs to platform libselinux
Bug: 37919668
Bug: 37343404
Test: build and boot

(cherry-pick from commit 43d548e365)

Change-Id: If0de84db4052c86350001de11fc804d9daca1630
Merged-In: I3dd56e786ca25c314b5c6880587445e496db39a9
2017-07-06 14:55:39 -07:00
Sandeep Patil
f5addf2232 refactor: move common parts of libselinux builds into defaults
Bug: 37343404
Bug: 37919668
Test: Build and boot

(cherry-picked from commit 51428ba055)

Change-Id: If42d24d381839c2a39f8cff3fc82ce5d3073eeb7
Merged-In: I375a4a2926326a5f733f4a49348e1ffae086ffd6
2017-07-06 14:55:29 -07:00
Vijay Venkatraman
1c8c58625d Add libselinux_vendor
Removed dependency on libpackageparser
Retained dependency on libpcre2

android_seapp.c = non-vendor functions
android.c = functions common to vendor and non-vendor

exported_vendor.map contains map for libselinux_vendor

(cherry-picked from commit cc1666de05)

Bug: 37343404
Test: Build vndservicemanager, libselinux.so and libselinux_vendor.so
Verify normal boot on sailfish and pass CTS Security
Merged-In: I020b1333ad4628b831c94a27f07d880f73dbde7a

Change-Id: I0ffc621ceb53b3531df458611f1322ebecd2da20
2017-07-06 09:31:54 -07:00
Stephen Smalley
83fbc0979d Update VERSION files for 2.7-rc4 release.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2017-06-30 13:41:33 -04:00
Stephen Smalley
2d1a6c63c6 libselinux,libsemanage: fix RUBYLIBS definition
The RUBYLIBS definition introduced by commit f5b9bc2a06
("libselinux,libsemanage: link Ruby wrappers with -lruby") did
not work on Debian.  Fix it based on a patch by Nicolas Iooss.

Reported-by: Laurent Bigonville <bigon@debian.org>
Suggested-by: Nicolas Iooss <nicolas.iooss@m4x.org>
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2017-06-28 09:35:57 -04:00
Stephen Smalley
6fab7923ce Update VERSION files for 2.7-rc3 release.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2017-06-23 13:01:45 -04:00
Patrick Steinhardt
ca07a2ad46 libselinux: avoid redefining _FORTIFY_SOURCE
Two makefiles of ours pass `-D_FORTIFY_SOURCE=2` directly to the
preprocessor. While this does not pose any problems when the value has
not been previously set, it can break the build if it is part of the
standard build flags.

The issue can easily be fixed by instead defining `_FORTIFY_SOURCE`
without specifying a concrete value. In this case, gcc will not error
out and simply keep using the previously defined value. On the other
hand, if no value has been defined, we will now compile with
`_FORTIFY_SOURCE=1`. From feature_test_macros(7):

    If _FORTIFY_SOURCE is set to 1, with compiler optimization level 1
    (gcc -O1) and above, checks that shouldn't change the behavior of
    conforming programs are performed.  With _FORTIFY_SOURCE set to 2,
    some more checking is added, but some conforming programs might
    fail.

While this leaves us with less checks for buffer overflows, it will only
enable checks that should not change behaviour of conforming programs.
With _FORTIFY_SOURCE=2, the compiler may even unintentionally change
behaviour of conforming programs. So in fact, one could even argue that
we should only be setting the value to 1 anyway to avoid surprising side
effects.

So this patch changes our CFLAGS to only pass `-D_FORTIFY_SOURCE`
without any concrete value, fixing the build issue.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2017-06-22 16:44:07 -04:00
Stephen Smalley
7b5699bfd7 Fix BINDIR/SBINDIR/... variables in Makefiles
As reported by Nicolas Iooss, there are still some inconsistencies
in the definitions and usage of Makefile variables related to bin
and sbin directories. Since we need to still support non-usrmerge
systems, we cannot completely synchronize them, but we can eliminate
unnecessary differences, remove unused variables, and drop the
USRSBINDIR variables.

Before:
$ find . -name Makefile -exec cat {} + |grep '^[A-Z_]*BINDIR' |sort -u
BINDIR=$(PREFIX)/bin
BINDIR ?= $(PREFIX)/bin
BINDIR ?= $(PREFIX)/sbin
SBINDIR ?= $(DESTDIR)/sbin
SBINDIR ?= $(PREFIX)/sbin
USRSBINDIR ?= $(PREFIX)/sbin

After:
$ find . -name Makefile -exec cat {} + | grep '^[A-Z_]*BINDIR' | sort -u
BINDIR ?= $(PREFIX)/bin
SBINDIR ?= $(DESTDIR)/sbin
SBINDIR ?= $(PREFIX)/sbin

This does not change the actual install location of any file.
It does drop the legacy symlink from /usr/sbin/load_policy to
/sbin/load_policy; packagers can create that separately if
desired.

Reported-by: Nicolas Iooss <nicolas.iooss@m4x.org>
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2017-06-20 12:18:26 -04:00
Jason Zaman
297877ab88 libselinux utils: override LD{FLAGS, LIBS} for libselinux.so in Makefile
the utils dir link to libselinux.so which was just built, if LDFLAGS or
LDLIBS were specificed on the make commandline then the search path is
not appended. Add the override directive to fix this.

Gentoo-Bug: https://bugs.gentoo.org/621762

Signed-off-by: Jason Zaman <jason@perfinion.com>
2017-06-19 11:23:06 -04:00
Stephen Smalley
08d4b030ea Update VERSION files for 2.7-rc2 release.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2017-06-16 12:50:03 -04:00
Jeff Vander Stoep
fc9e362950 Move non-treble devices to split file_contexts
am: 6ef44cbece

Change-Id: Ia60185a553c4240b5e3b592af91ef6f57aa6a3ef
2017-06-12 22:14:26 +00:00
Jeff Vander Stoep
6ef44cbece Move non-treble devices to split file_contexts
Bug: 38502071
Test: build and boot non-Treble Bullhead, run CTS tests below
Test: build and boot Treble Marlin, run CTS tests below
Test: cts-tradefed run singleCommand cts --skip-device-info \
    --skip-preconditions --skip-connectivity-check --abi arm64-v8a \
    --module CtsSecurityHostTestCases \
    -t android.security.cts.SELinuxHostTest#testAospFileContexts
Test: cts-tradefed run singleCommand cts --skip-device-info \
    --skip-preconditions --skip-connectivity-check --abi arm64-v8a \
    --module CtsSecurityHostTestCases \
    -t android.security.cts.SELinuxHostTest#testValidFileContexts
Change-Id: I8d37fa1b4f71af113b9751c65292a2e94d62b3d4
Merged-In: Ia3792e5e8c8d9ef7177d6e309a1e0df54bbf75a5
2017-06-10 04:16:10 +00:00