summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2015-08-27am d59496a0: (-s ours) am 2ef4270c: Merge "libselinux: fail hard on invalid ↵Nick Kralevich
file_contexts entries" * commit 'd59496a015f53251171cb19b300fec25d755fe41':
2015-08-27am 80fe5f15: (-s ours) am 82216295: libselinux: fail hard on invalid ↵Stephen Smalley
property_contexts entries * commit '80fe5f150070262ef6e36f2910215457e89dc8a1':
2015-08-27am 09fbb966: (-s ours) am be86166f: restorecon: do not set ↵William Roberts
security.restorecon_last on ramfs and tmpfs * commit '09fbb9669af14fd9bb97234ec518f8ac91819368':
2015-08-27am dc022606: (-s ours) am 6d0b91bb: libselinux: Enhance spec file supportRichard Haines
* commit 'dc022606befb80fd6c8a10312b79cedbc40dddab':
2015-08-24am 91b7d911: Set SELABEL_OPT_BASEONLY to stop additional file checksRichard Haines
* commit '91b7d911c51f972f127972bc5c529310387fba8b': Set SELABEL_OPT_BASEONLY to stop additional file checks
2015-08-24am 91b7d911: Set SELABEL_OPT_BASEONLY to stop additional file checksRichard Haines
* commit '91b7d911c51f972f127972bc5c529310387fba8b': Set SELABEL_OPT_BASEONLY to stop additional file checks
2015-08-24Set SELABEL_OPT_BASEONLY to stop additional file checksRichard Haines
Stop checking for the homedirs and local file_contexts files as they do not exist on Android and therefore always fail. Change-Id: Idba7ea4757073f428ce2a3e02e63796fdde71cdb Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
2015-08-13am 95736e8c: Merge changes from topic \'file_contexts.bin\'Nick Kralevich
* commit '95736e8c6bd7a1e1717cf8abe10f6af910b7e429': libselinux: support context validation on file_contexts.bin libselinux: test for file_contexts.bin format libselinux: add selabel_cmp interface and label_file backend libselinux: switch to file_contexts.bin libselinux: support specifying file_contexts.bin file path libselinux: support file_contexts.bin without file_contexts
2015-08-13am 95736e8c: Merge changes from topic \'file_contexts.bin\'Nick Kralevich
* commit '95736e8c6bd7a1e1717cf8abe10f6af910b7e429': libselinux: support context validation on file_contexts.bin libselinux: test for file_contexts.bin format libselinux: add selabel_cmp interface and label_file backend libselinux: switch to file_contexts.bin libselinux: support specifying file_contexts.bin file path libselinux: support file_contexts.bin without file_contexts
2015-08-12Merge changes from topic 'file_contexts.bin'android-m-preview-2Nick Kralevich
* changes: libselinux: support context validation on file_contexts.bin libselinux: test for file_contexts.bin format libselinux: add selabel_cmp interface and label_file backend libselinux: switch to file_contexts.bin libselinux: support specifying file_contexts.bin file path libselinux: support file_contexts.bin without file_contexts
2015-08-08am 2ef4270c: Merge "libselinux: fail hard on invalid file_contexts entries"Nick Kralevich
* commit '2ef4270c9ba60b895ad9b9b9155fca9af5cc07a4': libselinux: fail hard on invalid file_contexts entries
2015-08-08am 2ef4270c: Merge "libselinux: fail hard on invalid file_contexts entries"Nick Kralevich
* commit '2ef4270c9ba60b895ad9b9b9155fca9af5cc07a4': libselinux: fail hard on invalid file_contexts entries
2015-08-08Merge "libselinux: fail hard on invalid file_contexts entries"Nick Kralevich
2015-08-08am 82216295: libselinux: fail hard on invalid property_contexts entriesStephen Smalley
* commit '82216295fac4bb483624e7870b42ac9e95fc7889': libselinux: fail hard on invalid property_contexts entries
2015-08-08am 82216295: libselinux: fail hard on invalid property_contexts entriesStephen Smalley
* commit '82216295fac4bb483624e7870b42ac9e95fc7889': libselinux: fail hard on invalid property_contexts entries
2015-08-06libselinux: fail hard on invalid property_contexts entriesStephen Smalley
Fail hard on any error during property_contexts (or service_contexts) processing. We want to catch any such errors early and not proceed with a potentially mislabeled system. Also remove some obsoleted tests for NULL; they were necessary in earlier versions of the code where we were copying the strings at this point, but no longer. Change-Id: I98b8f88996d2ad385ad9ea13682eb11611d665ff Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-08-06libselinux: fail hard on invalid file_contexts entriesStephen Smalley
Fail hard on any error during file_contexts processing. We want to catch any such errors early and not proceed with a potentially mislabeled system. This was the original logic but was loosened long ago to more gracefully handle user error in Linux distributions (a single typo could lead to not being able to label anything, even if the relevant entry for the files in question was correct). However, in Android, file_contexts is not modified at runtime and we want to fully validate it at build, so we want to fail hard in these cases, and in modern Linux, file_contexts is modified using tools (semanage, semodule) and a library (libsemanage) that should already be fully validating values before adding entries, and that trigger a setfiles -c validation (equivalent to Android checkfc) before committing the transaction. Change-Id: If98dc462b7132c34d5a1ae0a2634fda3779227c3 Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-08-06libselinux: support context validation on file_contexts.binStephen Smalley
If file_contexts.bin was opened with SELABEL_OPT_VALIDATE set, then we should validate contexts in the same manner as with file_contexts. Change-Id: I08c1ba91c694c5483aa838833ff9d704aceca235 Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-08-05libselinux: test for file_contexts.bin formatStephen Smalley
Check to see if the file whose path is passed to selabel_open() starts with the file_contexts.bin magic number, and if so, automatically treat it as a file_contexts.bin file. This allows one to open file_contexts.bin formatted files without necessarily having a .bin file suffix. This removes the need for the previously added .bin file suffix test. Change-Id: I6a0cb303954cc6fa24c437ccc794104859eac24b Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-08-05libselinux: add selabel_cmp interface and label_file backendStephen Smalley
Add a selabel_cmp() interface for comparing two label configurations, and implement it for the file backend (i.e. for file_contexts). This allows comparing two file_contexts configurations to see if the first is a subset of, equal/identical to, a superset of, or incomparable to the second. The motivating use case is to allow comparing two file_contexts.bin files in Android CTS to confirm that a device file_contexts.bin file contains all of the entries in the AOSP general file_contexts. Change-Id: I0fe63e0c7f11ae067b5aac2f468f7842e5d76986 Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-08-04libselinux: switch to file_contexts.binStephen Smalley
Switch the libselinux android code to load file_contexts.bin rather than file_contexts. While the label_file backend already looks for the .bin file even if the caller only asked for the text file, the Android-specific code in libselinux also directly opens the path in order to compute the hash to compare and store in the security.restorecon_last xattr, and it directly calls access(2) on the path to confirm that all the expected policy files exist before using any /data/security policy. So we need to change it here as well. Depends on I75a781100082c23536f70ce3603f7de42408b5ba Change-Id: I43806d564b83d57f05f5c36c8eba7b1ff4831b04 Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-08-04libselinux: support specifying file_contexts.bin file pathStephen Smalley
At present, the label_file backend expects to be provided the path to the text file_contexts file and always appends the .bin suffix when checking for the binary file_contexts.bin file. If one attempts to directly specify the path to a file_contexts.bin file to selabel_open(), it will fail as the code will append a second .bin suffix to it. Check to see if the file path already has a .bin suffix and do not append it in that case. Change-Id: Id560d093440a2aba99cef28c20133b35feebf950 Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-08-04libselinux: support file_contexts.bin without file_contextsStephen Smalley
Change the label_file backend in libselinux to support systems that only have file_contexts.bin files installed and do not ship a file_contexts file at all. Only fail if neither file can be loaded. Change-Id: I15660f4b3e4c5cb8ae0ec1498c74d6fcbb9a0400 Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-07-23am be86166f: restorecon: do not set security.restorecon_last on ramfs and tmpfsWilliam Roberts
* commit 'be86166f7e4f49cb0cb0c97a368377b4d781998a': restorecon: do not set security.restorecon_last on ramfs and tmpfs
2015-07-22am be86166f: restorecon: do not set security.restorecon_last on ramfs and tmpfsWilliam Roberts
* commit 'be86166f7e4f49cb0cb0c97a368377b4d781998a': restorecon: do not set security.restorecon_last on ramfs and tmpfs
2015-07-20libselinux: use /proc/thread-self when availableStephen Smalley
commit 3430519109c0423a49b9350aa8444beec798d5a7 upstream. Linux 3.17 introduced a /proc/thread-self symlink that can be used to reference the proc files of the current thread without needing to use gettid(2). Use this symlink when it exists, falling back to using gettid(2) when it does not. This is generally beneficial, but was specifically motivated by https://github.com/systemd/systemd/issues/475. [This also ports the openattr helper function from upstream commit 1d403326aecd92dfa0120cfd2e9c3c52a2a3cdf1 but does not bring in the set*con cache.] Change-Id: I19bd680784ce9a7e6bb6ddf4bbaa94fb664a42c7 Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2015-07-20restorecon: do not set security.restorecon_last on ramfs and tmpfsWilliam Roberts
When setting the last value for restorecon, it should skip over the ramfs and tmpfs, as setting last on non-persistent file systems makes no sense. Notably, this avoids triggering a CAP_SYS_ADMIN capability check and a SELinux setattr permission check to the file when applying restorecon to ramfs or tmpfs filesystems. Change-Id: I7e7ebaa9d62c7bc6a5587cc9c472dcb4a7a49513 Signed-off-by: William Roberts <william.c.roberts@intel.com>
2015-07-09am 6d0b91bb: libselinux: Enhance spec file supportRichard Haines
* commit '6d0b91bbb1ef05d2506f64cf37492e988063952b': libselinux: Enhance spec file support
2015-07-09am 6d0b91bb: libselinux: Enhance spec file supportRichard Haines
* commit '6d0b91bbb1ef05d2506f64cf37492e988063952b': libselinux: Enhance spec file support
2015-07-07libselinux: Enhance spec file supportRichard Haines
This file labeling update brings libselinux into line with upstream selinux except for minor changes to support MacOS X and Bionic. Update file labeling to support a PCRE formatted binary file_contexts file. The file is generated on the host using sefcontext_compile. Should the bin file not be present (because the build process has not been implemented yet) or corrupt, the load process will fallback to the text file. Using the current emulator file_contexts file containing 321 lines (64 of which are blank or comments), the binary file loads approximately 50% faster than the text file. The processing of text spec files (file_contexts and property_contexts) now uses the read_spec_entries function instead of sscanf. To test the file_contexts.bin functionality requires an update to external/sepolicy/Android.mk to build the binary file for the device and also adding a 'file_contexts.bin' entry to the build/target/product/embedded.mk file under the SELinux PRODUCT_PACKAGES. These updates are available in the appropriate projects. Major changes in V2: label_file.c - Move process_line function to label_file.h as this is also used by utils/sefcontext_compile.c. sefcontext_compile.c - Update to use common process_line code. Now frees all malloc'ed memory, checked by valgrind. Major changes in V3: label_file.c - Improve error handling in process_file function. sefcontext_compile.c - Add callback to ignore validation. Fixed error paths to free/close memory, checked by valgrind. label_file.h - Revert validation check now added callback to sefcontext_compile.c. Changes in V4: label_file.c - linux/limits.h not supported on MacOS - change to limits.h. Improve error handling in process_file function. sefcontext_compile.c - linux/limits.h not spported on MacOS - change to limits.h. Improve error handling in process_file function. Changes in V5: sefcontext_compile.c - Change callbacks so this can build on Android and selinux upstream with no changes. label_android_property.c and label_internal.h - Minor formatting changes to bring into line with selinux upstream. Changes in V6: sefcontext_compile.c - Revert to V3 callback now the problem has been fixed by upstream commit e88914849490c3fc17b0e5ed67387e47f2701d3c ("libselinux: build sefcontext_compile with static libselinux") that also hid read_spec_entries function as this is not intended as a public interface for shared library users. label_android_property.c - More minor formatting changes to bring into line with selinux upstream. Changes in V7: Android.mk - Add darwin support label_file.c - In process_file set rc for getline and correct fopen to upstream. sefcontext_compile.c - In process_file set rc for getline. Change in V8: Android.mk - Remove LOCAL_CFLAGS := -Wall -Werror Changes in V9: label_file.c - Fix file labels for regexes with metachars for text file_contexts label_support.c - Fix if file_contexts not '\n' terminated If the last line of a file_contexts file is not '\n' terminated or if any line has additional isspace(3) characters at end, it gave an invalid file type error Changes in V10 Fix file labels for regexes with metachars for binary file_contexts This change adds a new entry in the binary file with the calculated prefix length that is then read when processing the file. This fix also bumps SELINUX_COMPILED_FCONTEXT_MAX_VERS. Change-Id: Ief0d3a6a5fbffc785b02d9dffb416f837000e61c
2015-06-26am 5b4ddd76: Merge "Revert "libselinux: Enhance spec file support""Jeffrey Vander Stoep
* commit '5b4ddd760ebf58a1fb63509a0e5821a9bfe708c5': Revert "libselinux: Enhance spec file support"
2015-06-26Merge "Revert "libselinux: Enhance spec file support""android-m-preview-1Jeffrey Vander Stoep
2015-06-26Revert "libselinux: Enhance spec file support"Jeffrey Vander Stoep
This reverts commit c0798527a397fecde8ad703c565204e3ef828801. There is a change in how file names are matched. Unescaped periods are no longer treated like a regex period (matching any character including an actual period). For example in devices/moto/shamu/sepolicy/file_contexts, several of the block devices have unescaped periods. These partitions do not receive their proper label, and the device fails to boot. Bug: 22104578 Change-Id: Iffc60beb24a79a80c110d4f2b0b91f3220615586
2015-06-25am 09ec61f7: Merge "libselinux: Enhance spec file support"Jeffrey Vander Stoep
* commit '09ec61f7404ec7c0a4813edc6711a23adb1ea1b2': libselinux: Enhance spec file support
2015-06-25Merge "libselinux: Enhance spec file support"Jeffrey Vander Stoep
2015-06-23libselinux: Enhance spec file supportRichard Haines
This file labeling update brings libselinux into line with upstream selinux except for minor changes to support MacOS X and Bionic. Update file labeling to support a PCRE formatted binary file_contexts file. The file is generated on the host using sefcontext_compile. Should the bin file not be present (because the build process has not been implemented yet) or corrupt, the load process will fallback to the text file. Using the current emulator file_contexts file containing 321 lines (64 of which are blank or comments), the binary file loads approximately 50% faster than the text file. The processing of text spec files (file_contexts and property_contexts) now uses the read_spec_entries function instead of sscanf. To test the file_contexts.bin functionality requires an update to external/sepolicy/Android.mk to build the binary file for the device and also adding a 'file_contexts.bin' entry to the build/target/product/embedded.mk file under the SELinux PRODUCT_PACKAGES. These updates are available in the appropriate projects. Major changes in V2: label_file.c - Move process_line function to label_file.h as this is also used by utils/sefcontext_compile.c. sefcontext_compile.c - Update to use common process_line code. Now frees all malloc'ed memory, checked by valgrind. Major changes in V3: label_file.c - Improve error handling in process_file function. sefcontext_compile.c - Add callback to ignore validation. Fixed error paths to free/close memory, checked by valgrind. label_file.h - Revert validation check now added callback to sefcontext_compile.c. Changes in V4: label_file.c - linux/limits.h not supported on MacOS - change to limits.h. Improve error handling in process_file function. sefcontext_compile.c - linux/limits.h not spported on MacOS - change to limits.h. Improve error handling in process_file function. Changes in V5: sefcontext_compile.c - Change callbacks so this can build on Android and selinux upstream with no changes. label_android_property.c and label_internal.h - Minor formatting changes to bring into line with selinux upstream. Changes in V6: sefcontext_compile.c - Revert to V3 callback now the problem has been fixed by upstream commit e88914849490c3fc17b0e5ed67387e47f2701d3c ("libselinux: build sefcontext_compile with static libselinux") that also hid read_spec_entries function as this is not intended as a public interface for shared library users. label_android_property.c - More minor formatting changes to bring into line with selinux upstream. Changes in V7: Android.mk - Add darwin support label_file.c - In process_file set rc for getline and correct fopen to upstream. sefcontext_compile.c - In process_file set rc for getline. Change in V8: Android.mk - Remove LOCAL_CFLAGS := -Wall -Werror Change-Id: I75a781100082c23536f70ce3603f7de42408b5ba Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
2015-06-15am 943ed44a: restorecon: only operate on canonical paths.dcashman
* commit '943ed44a46ed95d557bf552b57fe61280a77489c': restorecon: only operate on canonical paths.
2015-06-15am 06d45512: restorecon: only operate on canonical paths.dcashman
* commit '06d45512e2df93f65a51877a51549e522b4f2cf5': restorecon: only operate on canonical paths.
2015-06-15restorecon: only operate on canonical paths.android-cts-6.0_r9android-cts-6.0_r8android-cts-6.0_r7android-cts-6.0_r6android-cts-6.0_r5android-cts-6.0_r4android-cts-6.0_r32android-cts-6.0_r31android-cts-6.0_r30android-cts-6.0_r3android-cts-6.0_r29android-cts-6.0_r28android-cts-6.0_r27android-cts-6.0_r26android-cts-6.0_r25android-cts-6.0_r24android-cts-6.0_r23android-cts-6.0_r22android-cts-6.0_r21android-cts-6.0_r20android-cts-6.0_r2android-cts-6.0_r19android-cts-6.0_r18android-cts-6.0_r17android-cts-6.0_r16android-cts-6.0_r15android-cts-6.0_r14android-cts-6.0_r13android-cts-6.0_r12android-cts-6.0_r1android-6.0.1_r9android-6.0.1_r81android-6.0.1_r80android-6.0.1_r8android-6.0.1_r79android-6.0.1_r78android-6.0.1_r77android-6.0.1_r74android-6.0.1_r73android-6.0.1_r72android-6.0.1_r70android-6.0.1_r7android-6.0.1_r69android-6.0.1_r68android-6.0.1_r67android-6.0.1_r66android-6.0.1_r65android-6.0.1_r63android-6.0.1_r62android-6.0.1_r61android-6.0.1_r60android-6.0.1_r59android-6.0.1_r58android-6.0.1_r57android-6.0.1_r56android-6.0.1_r55android-6.0.1_r54android-6.0.1_r53android-6.0.1_r52android-6.0.1_r51android-6.0.1_r50android-6.0.1_r5android-6.0.1_r49android-6.0.1_r48android-6.0.1_r47android-6.0.1_r46android-6.0.1_r45android-6.0.1_r43android-6.0.1_r42android-6.0.1_r41android-6.0.1_r40android-6.0.1_r4android-6.0.1_r33android-6.0.1_r32android-6.0.1_r31android-6.0.1_r30android-6.0.1_r3android-6.0.1_r28android-6.0.1_r27android-6.0.1_r26android-6.0.1_r25android-6.0.1_r24android-6.0.1_r22android-6.0.1_r21android-6.0.1_r20android-6.0.1_r18android-6.0.1_r17android-6.0.1_r16android-6.0.1_r13android-6.0.1_r12android-6.0.1_r11android-6.0.1_r10android-6.0.1_r1android-6.0.0_r7android-6.0.0_r6android-6.0.0_r5android-6.0.0_r41android-6.0.0_r4android-6.0.0_r3android-6.0.0_r26android-6.0.0_r25android-6.0.0_r24android-6.0.0_r23android-6.0.0_r2android-6.0.0_r13android-6.0.0_r12android-6.0.0_r11android-6.0.0_r1marshmallow-releasemarshmallow-mr3-releasemarshmallow-mr2-releasemarshmallow-mr1-releasemarshmallow-mr1-devmarshmallow-dr1.6-releasemarshmallow-dr1.5-releasemarshmallow-dr1.5-devmarshmallow-dr-releasemarshmallow-dr-dragon-releasemarshmallow-dr-devmarshmallow-devmarshmallow-cts-releaselinaro-android-6.0dcashman
(cherry-pick of commit: 06d45512e2df93f65a51877a51549e522b4f2cf5) Bug: 21732016 Change-Id: I56c3e73a089da65bbe0f064bbdd6e8096c082db0
2015-06-15restorecon: only operate on canonical paths.dcashman
Bug: 20128916 Change-Id: I9b063e31df1056d6760a2ee96771c3d4948ee661
2015-05-14am bf0ef3a1: Merge "Revert "Add cleanspec""Jeffrey Vander Stoep
* commit 'bf0ef3a1efe7e195d1f06d628e0abe2ca8fc5b74': Revert "Add cleanspec"
2015-05-14am e9e55de9: Merge "Revert "Move host functionality to common selinux dir""Jeffrey Vander Stoep
* commit 'e9e55de98a586505bc55299421aa66904573039c': Revert "Move host functionality to common selinux dir"
2015-05-14Merge "Revert "Add cleanspec""android-m-previewJeffrey Vander Stoep
2015-05-14Merge "Revert "Move host functionality to common selinux dir""Jeffrey Vander Stoep
2015-05-14Revert "Add cleanspec"Jeffrey Vander Stoep
Reverting commit that made this change necessary: 992200ff0364edcbae2a1b279abe7af7e02596de This reverts commit f58320b85af336fab4d2d697a03fb8a8eb3a931f. Change-Id: Ie971180822a387d68183260c8ca3206bf1582679
2015-05-14Revert "Move host functionality to common selinux dir"Jeffrey Vander Stoep
This change breaks the Mac build due to no stdio_ext.h This reverts commit 992200ff0364edcbae2a1b279abe7af7e02596de. Change-Id: Ic5a20dd4ed41b325174202ce992d557fe09f23da
2015-05-14am 8e3a8126: Merge "Move host functionality to common selinux dir"Jeff Vander Stoep
* commit '8e3a81264103beeea8091ebf192822b972ff8d8a': Move host functionality to common selinux dir
2015-05-14am f58320b8: Add cleanspecJeff Vander Stoep
* commit 'f58320b85af336fab4d2d697a03fb8a8eb3a931f': Add cleanspec
2015-05-14Merge "Move host functionality to common selinux dir"Jeff Vander Stoep
2015-05-14Add cleanspecJeff Vander Stoep
Preserve incremental build after libselinux host functionality move to common selinux directory Change-Id: Ia07a9cb04a520307de8aacbc02721b4382d7fd58