Commit graph

5402 commits

Author SHA1 Message Date
Treehugger Robot
f72b7ade28 Merge "Set AGGRESSIVE_FREE_AFTER_REGEX_MATCH" am: 2529ea6e51 am: 12017ba4ef am: 20bb1268bb
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2394772

Change-Id: Iae252e85a855aff2a24f6103bb4afb69d5302e4c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-19 13:44:50 +00:00
David Brazdil
083e1b3aa1 Merge "Make libselinux_bindgen visible to all Virtualization targets" am: 2eb09c5d74 am: 0e12e86f8c am: 97c00171be
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2387092

Change-Id: I3410f6b7a72e321a42c1904f5095aabd73834a2c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-19 13:42:08 +00:00
Treehugger Robot
20bb1268bb Merge "Set AGGRESSIVE_FREE_AFTER_REGEX_MATCH" am: 2529ea6e51 am: 12017ba4ef
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2394772

Change-Id: I044e7e7e9d3d22af4f3caac450b34a8abb8fce5a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-19 13:01:18 +00:00
David Brazdil
97c00171be Merge "Make libselinux_bindgen visible to all Virtualization targets" am: 2eb09c5d74 am: 0e12e86f8c
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2387092

Change-Id: I8952e2cc62b18d13b76275ca4480e93716951f0e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-19 13:00:47 +00:00
Treehugger Robot
12017ba4ef Merge "Set AGGRESSIVE_FREE_AFTER_REGEX_MATCH" am: 2529ea6e51
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2394772

Change-Id: Ia9cc36890133c0e6e429031971d0c035cd86f366
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-19 12:30:29 +00:00
David Brazdil
0e12e86f8c Merge "Make libselinux_bindgen visible to all Virtualization targets" am: 2eb09c5d74
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2387092

Change-Id: I02cb5fdd92c1e5f95d743492d9b590d39cbf2d58
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-19 12:30:12 +00:00
Treehugger Robot
2529ea6e51 Merge "Set AGGRESSIVE_FREE_AFTER_REGEX_MATCH" 2023-01-19 12:07:55 +00:00
David Brazdil
2eb09c5d74 Merge "Make libselinux_bindgen visible to all Virtualization targets" 2023-01-19 11:50:50 +00:00
Inseob Kim
6ffce0a0e3 Set AGGRESSIVE_FREE_AFTER_REGEX_MATCH
This is to workaround a regression on peak memory usage, due to a
behavior change of pcre2. With this patch, peak memory usage decreases
for about 4 MB.

Also verified with microdroid benchmarks that the runtime impact is
negligible.

Before this patch:

testMicrodroidBootTime[protectedVm=false]:
    avf_perf/microdroid/boot_time_average_ms: 1072.2437260666668
    avf_perf/microdroid/boot_time_max_ms: 1153.957195
    avf_perf/microdroid/boot_time_min_ms: 987.760254
    avf_perf/microdroid/boot_time_stdev_ms: 43.715968392943445
testMicrodroidBootTime[protectedVm=true]:
    avf_perf/microdroid/boot_time_average_ms: 1318.7790113333335
    avf_perf/microdroid/boot_time_max_ms: 1367.490967
    avf_perf/microdroid/boot_time_min_ms: 1239.080486
    avf_perf/microdroid/boot_time_stdev_ms: 33.82832311810135

After this patch:

testMicrodroidBootTime[protectedVm=false]:
    avf_perf/microdroid/boot_time_average_ms: 1074.9152321333336
    avf_perf/microdroid/boot_time_max_ms: 1172.233481
    avf_perf/microdroid/boot_time_min_ms: 971.020793
    avf_perf/microdroid/boot_time_stdev_ms: 45.3782260524823
testMicrodroidBootTime[protectedVm=true]:
    avf_perf/microdroid/boot_time_average_ms: 1286.4607849333333
    avf_perf/microdroid/boot_time_max_ms: 1380.643678
    avf_perf/microdroid/boot_time_min_ms: 1209.573649
    avf_perf/microdroid/boot_time_stdev_ms: 44.44544241596637

Bug: 262469329
Test: atest MicrodroidBenchmarks
Test: run device boot time test
Change-Id: Ifc1be381255c263638ea262b995bc06fa3c7bdcc
2023-01-19 10:21:29 +09:00
Inseob Kim
4ae0e084f4 Merge remote-tracking branch 'aosp/upstream-master' into HEAD am: ad990cb28b am: 156b5f8785 am: 73ca382fab
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2390532

Change-Id: I5bfc2fb2b99f4c729b68d446b47a808606ea9fe8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-16 08:40:49 +00:00
Inseob Kim
73ca382fab Merge remote-tracking branch 'aosp/upstream-master' into HEAD am: ad990cb28b am: 156b5f8785
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2390532

Change-Id: Id307003a36cf0be620e79c115f319c1b52d60a26
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-16 08:03:33 +00:00
Inseob Kim
156b5f8785 Merge remote-tracking branch 'aosp/upstream-master' into HEAD am: ad990cb28b
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2390532

Change-Id: Iff4f6ece65d3354ee03ea6272a1ba647f334566f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-01-16 07:27:38 +00:00
Inseob Kim
ad990cb28b Merge remote-tracking branch 'aosp/upstream-master' into HEAD
Bug: 262469329
Test: build and boot cuttlefish
Change-Id: Ic97540265491a501cd89f40f46bf1f97d6a753e2
2023-01-16 13:45:35 +09:00
Jason Zaman
3ccea01c69
Update VERSIONs to 3.5-rc2 for release.
Signed-off-by: Jason Zaman <jason@perfinion.com>
2023-01-15 15:40:55 -08:00
lujiev
27e1c7c8e9 checkpolicy: delete invalid spaces
Closes: https://github.com/SELinuxProject/selinux/pull/372
Signed-off-by: lujiev <572084868@qq.com>
Acked-by: Jason Zaman <jason@perfinion.com>
2023-01-15 14:52:25 -08:00
Inseob Kim
30b3e9d25f libselinux: Workaround for heap overhead of pcre
pcre's behavior is changed so that pcre2_match always allocates heap for
match_data, rather than stack, regardless of size. The heap isn't freed
until explicitly calling pcre2_match_data_free. This new behavior may
result in heap overhead, which may increase the peak memory usage about
a few megabytes. It's because regex_match is first called for regex_data
objects, and then regex_data objects are freed at once.

To workaround it, free match_data as soon as we call regex_match. It's
fine because libselinux currently doesn't use match_data, but use only
the return value.

Signed-off-by: Inseob Kim <inseob@google.com>
Acked-by: Jason Zaman <jason@perfinion.com>
2023-01-15 14:17:15 -08:00
Vit Mojzis
7506771e4b python/sepolicy: add missing booleans to man pages
get_bools should return a list of booleans that can affect given type,
but it did not handle non trivial conditional statements properly
(returning the whole conditional statement instead of a list of booleans
in the statement).

e.g. for
allow httpd_t spamc_t:process transition; [ httpd_can_check_spam && httpd_can_sendmail ]:True
get_bools used to return [("httpd_can_check_spam && httpd_can_sendmail", False)] instead of
[("httpd_can_check_spam", False), ("httpd_can_sendmail", False)]

- rename "boolean" in sepolicy rule dictionary to "booleans" to suggest
  it can contain multiple values and make sure it is populated correctly
- add "conditional" key to the rule dictionary to accommodate
  get_conditionals, which requires the whole conditional statement
- extend get_bools search to dontaudit rules so that it covers booleans
  like httpd_dontaudit_search_dirs

Note: get_bools uses security_get_boolean_active to get the boolean
      value, but the value is later used to represent the default.
      Not ideal, but I'm not aware of a way to get the actual defaults.

Fixes:
        "sepolicy manpage" generates man pages that are missing booleans
        which are included in non trivial conditional expressions
        e.g. httpd_selinux(8) does not include httpd_can_check_spam,
        httpd_tmp_exec, httpd_unified, or httpd_use_gpg

        This fix, however, also adds some not strictly related booleans
        to some man pages. e.g. use_nfs_home_dirs and
        use_samba_home_dirs are added to httpd_selinux(8)

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
Acked-by: Jason Zaman <jason@perfinion.com>
2023-01-15 14:12:34 -08:00
David Brazdil
c8c407b1a9 Make libselinux_bindgen visible to all Virtualization targets
Bug: 245727626
Test: builds
Change-Id: I0057c4a222a5247a4e83c5398e39473574b46507
2023-01-12 21:12:30 +00:00
Christian Göttsche
986a3fe27e libsepol: do not write empty class definitions
Do not write class definitions for classes without any permission and
any inherited common class.  The classes are already declared in
write_class_decl_rules_to_conf().  Skipping those empty definitions,
which are equal to the corresponding class declarations, will enable to
parse the generated policy conf file with checkpolicy, as checkpolicy
does not accept class declarations after initial sid declarations.

This will enable simple round-trip tests with checkpolicy.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2023-01-11 08:48:19 -05:00
Christian Göttsche
b32e85cf67 Correct misc typos
Found by codespell(1) and typos[1].

[1]: https://github.com/crate-ci/typos

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2023-01-11 08:45:08 -05:00
Petr Lautrbach
d0b3d89c11 sepolicy: Make generated boolean descriptions translatable
Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
Acked-by: James Carter <jwcart2@gmail.com>
2023-01-11 08:43:54 -05:00
Christian Göttsche
fa936a0a30 libsepol: reject attributes in type av rules for kernel policies
The kernel does not support type attributes as source or target in type
av rules (type_transition, type_member, type_change)[1].  Such rules
should have been expanded[2].

[1]: abe3c63144/security/selinux/ss/services.c (L1843)
[2]: 0a8c177dac/libsepol/src/expand.c (L1981)

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2023-01-11 08:43:09 -05:00
kkz
60a0d7285d sepolicy: fix a spelling mistake
Signed-off-by: zhaoshuang <zhaoshuang@uniontech.com>
Signed-off-by: zhaoshuang <izhaoshuang@163.com>
Acked-by: James Carter <jwcart2@gmail.com>
2023-01-11 08:42:11 -05:00
Jie Lu
1fe82e5cf5 policycoreutils: fix potential NULL reference in load_checks
In load_checks(), add return check for malloc() to avoid NULL reference.

Signed-off-by: Jie Lu <lujie54@huawei.com>
Acked-by: James Carter <jwcart2@gmail.com>
2023-01-11 08:40:33 -05:00
Jason Zaman
013ecfd7fa Update VERSIONs to 3.5-rc1 for release.
Signed-off-by: Jason Zaman <jason@perfinion.com>
2022-12-22 13:10:26 -08:00
Jason Zaman
d1e3170556 python: Ignore installed when installing to DESTDIR
When installing to a destdir with pip install --prefix= --root=, pip tries to
uninstall the existing root-owned package and fails

Fixes:
python3 -m pip install --prefix=/usr `test -n "/tmp/selinux-release//build-master" && echo --root /tmp/selinux-release//build-master`  .
Processing /tmp/selinux-release/selinux-master/python/sepolicy
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: sepolicy
  Building wheel for sepolicy (setup.py) ... done
  Created wheel for sepolicy: filename=sepolicy-3.4-py3-none-any.whl size=1663564 sha256=229546db123e7d84613d190d49c192291b1a4f7f2a037657b39283b04ac391a4
  Stored in directory: /tmp/pip-ephem-wheel-cache-50r2x4cn/wheels/b2/9e/63/6a6212a84d65a709923228719d065ed34e66a90c7fed01e8cf
Successfully built sepolicy
Installing collected packages: sepolicy
  Attempting uninstall: sepolicy
    Found existing installation: sepolicy 3.4
    Uninstalling sepolicy-3.4:
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: 'generate.py'
Consider using the `--user` option or check the permissions.

Signed-off-by: Jason Zaman <jason@perfinion.com>
Acked-by: Petr Lautrbach <lautrbach@redhat.com>
2022-12-22 08:59:05 -08:00
Jason Zaman
daf687247a libselinux: Ignore installed when installing python bindings to DESTDIR
When the python bindings are installed to a destdir with pip install
--prefix= --root=, pip tries to uninstall the existing root-owned
package and fails

Fixes:
running build_ext
python3 -m pip install --prefix=/usr `test -n "/tmp/selinux-release//build-master" && echo --root /tmp/selinux-release//build-master`  .
Processing /tmp/selinux-release/selinux-master/libselinux/src
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: selinux
  Building wheel for selinux (setup.py) ... done
  Created wheel for selinux: filename=selinux-3.4-cp310-cp310-linux_x86_64.whl size=725511 sha256=b35e9cdb2a6efce389eeece45446826b4ac6b41f81fdc128893f947036f27e8e
  Stored in directory: /tmp/pip-ephem-wheel-cache-kemjh99e/wheels/ca/2d/1e/d1ab52426d9add92931471cfa0d2558bcbeed89084af2388c9
Successfully built selinux
Installing collected packages: selinux
  Attempting uninstall: selinux
    Found existing installation: selinux 3.4
    Uninstalling selinux-3.4:
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '__init__.cpython-310.pyc'
Consider using the `--user` option or check the permissions.

Signed-off-by: Jason Zaman <jason@perfinion.com>
Acked-by: Petr Lautrbach <lautrbach@redhat.com>
2022-12-22 08:58:30 -08:00
Petr Lautrbach
4f9e836f98 Use pip install instead of setup.py install
Fixes:
    /usr/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.

Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-12-16 17:09:27 -05:00
James Carter
2a91411d7f Revert "Use pip install instead of setup.py install"
This reverts commit 2c3b818f5d.

An earlier version of the patch was commited by mistake.

Signed-off-by: James Carter <jwcart2@gmail.com>
2022-12-16 17:08:58 -05:00
Petr Lautrbach
7ff1d7f1c2 sepolicy: Call os.makedirs() with exist_ok=True
Since commit 7494bb1298 ("sepolicy: generate man pages in parallel")
man pages are generated in parallel and there's a race between
os.path.exists() and os.makedirs().

The check os.path.exists() is not necessary when os.makedirs() is called
with exist_ok=True.

Fixes:
/usr/bin/sepolicy manpage -a -p /__w/usr/share/man/man8/ -w -r /__w/
FileExistsError: [Errno 17] File exists: '/__w/usr/share/man/man8/'

Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-12-16 16:43:48 -05:00
Petr Lautrbach
98c637c4cc python: Fix detection of sepolicy.glade location
Commit c08cf24f39 ("python: Remove dependency on the Python module
distutils") replace usage of distutils.sysconfig by sysconfig but it was
forgotten on the fact that the later provide a different api.

Fixes:
    self.code_path = sysconfig.get_python_lib(plat_specific=False) + "/sepolicy/"
                     ^^^^^^^^^^^^^^^^^^^^^^^^
    AttributeError: module 'sysconfig' has no attribute 'get_python_lib'

Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-12-16 16:43:41 -05:00
Petr Lautrbach
a9517c3896 sepolicy: Switch main selection menu to GtkPopover
Fixes: https://github.com/SELinuxProject/selinux/issues/206

Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-12-16 16:43:17 -05:00
Jie Lu
4c47f92758 libselinux:add check for malloc
Add return check for regex_data_create() to avoid NULL reference of regex_data

(gdb) bt
 #0  0x00007fbde5caec14 in pthread_mutex_init () from /usr/lib64/libc.so.6
 #1  0x00007fbde5e3a489 in regex_data_create () at regex.c:260
 #2  0x00007fbde5e3a4af in regex_prepare_data (regex=regex@entry=0x7fbde4613770, pattern_string=pattern_string@entry=0x563c6799a820 "^/home$", errordata=errordata@entry=0x7ffeb83fa950) at regex.c:76
 #3  0x00007fbde5e32fe6 in compile_regex (errbuf=0x0, spec=0x7fbde4613748) at label_file.h:407
 #4  lookup_all (key=0x563c679974e5 "/var/log/kadmind.log", type=<optimized out>, partial=partial@entry=false, match_count=match_count@entry=0x0, rec=<optimized out>, rec=<optimized out>)
     at label_file.c:949
 #5  0x00007fbde5e33350 in lookup (rec=<optimized out>, key=<optimized out>, type=<optimized out>) at label_file.c:1092
 #6  0x00007fbde5e31878 in selabel_lookup_common (rec=0x563c67998cc0, translating=1, key=<optimized out>, type=<optimized out>) at label.c:167

Signed-off-by: Jie Lu <lujie54@huawei.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-12-16 16:32:04 -05:00
Vit Mojzis
c84b977b17 libsemanage: Use more conscious language
https://inclusivenaming.org/word-lists/tier-1/

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-12-16 16:30:19 -05:00
Vit Mojzis
1d33c911f5 checkpolicy: Improve error message for type bounds
Make the error message consistent with other occurrences of the
same issue:
https://github.com/SELinuxProject/selinux/blob/master/checkpolicy/module_compiler.c#L243
https://github.com/SELinuxProject/selinux/blob/master/checkpolicy/module_compiler.c#L488

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-12-16 16:29:55 -05:00
Petr Lautrbach
2c3b818f5d Use pip install instead of setup.py install
Fixes:
    /usr/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.

Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-11-28 09:23:11 -05:00
Jie Lu
001af27a6d libselinux: fix some memory issues in db_init
1. check the return of strdup to avoid a potential NULL reference.
2. make sure line_buf is freed.

Signed-off-by: Jie Lu <lujie54@huawei.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-11-28 09:22:31 -05:00
Thiébaud Weksteen
9685af3fe9 Use Bionic strlcpy when available am: f8c13e3158 am: f2bdb13a20 am: 3d2b54fdab
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2319272

Change-Id: I668d6ebff0a236a80eeade1acae05ca865095727
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-28 10:22:12 +00:00
Thiébaud Weksteen
3d2b54fdab Use Bionic strlcpy when available am: f8c13e3158 am: f2bdb13a20
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2319272

Change-Id: I86a7a31546e55e00d3a81d846632ef284b133376
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-28 09:50:04 +00:00
Thiébaud Weksteen
f2bdb13a20 Use Bionic strlcpy when available am: f8c13e3158
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2319272

Change-Id: I804193e0d741bb3d9ce596bf5d516a581bbed134
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-28 09:24:13 +00:00
Thiébaud Weksteen
f8c13e3158 Use Bionic strlcpy when available
Bionic provides its own version of strlcpy. Ignore the re-definition
from SELinux for devices.

Bug: 260539369
Test: lunch sdk && m sdk
Change-Id: Icb9d8678c29562ab7b73d7a0f14a233fd71dfefd
2022-11-28 17:57:14 +11:00
Thiébaud Weksteen
f2de7cd729 Fix build after upstream merge am: 4d132a10b0 am: 26f9657eff am: 1b76d48225
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2301558

Change-Id: I5ae37ff00fc150f0e4ba0e9d31cd37fc2aba636f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-28 03:52:08 +00:00
Thiébaud Weksteen
f2e762650c Merge remote-tracking branch 'aosp/upstream-master' into rebase_20221110 am: a5d093d150 am: c381fba26f am: da615b45aa
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2301557

Change-Id: Ie7243e8a8c2dfaa05d71f575ea95f1d98a307071
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-28 03:52:06 +00:00
Thiébaud Weksteen
1b76d48225 Fix build after upstream merge am: 4d132a10b0 am: 26f9657eff
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2301558

Change-Id: Icbbd957d9459284d43ae10acf184a93f6727fa9e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-28 02:49:58 +00:00
Thiébaud Weksteen
da615b45aa Merge remote-tracking branch 'aosp/upstream-master' into rebase_20221110 am: a5d093d150 am: c381fba26f
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2301557

Change-Id: I01dcb0326f557b2f93f5f94c7a327d725b4f7763
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-28 02:49:56 +00:00
Thiébaud Weksteen
26f9657eff Fix build after upstream merge am: 4d132a10b0
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2301558

Change-Id: I0e216d5db594642482bb3e9cb725aaf24a7e103a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-28 01:54:04 +00:00
Thiébaud Weksteen
c381fba26f Merge remote-tracking branch 'aosp/upstream-master' into rebase_20221110 am: a5d093d150
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2301557

Change-Id: If0ccd085c8dae52569511fee521aa0dc8d5d00b3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-11-28 01:54:03 +00:00
Thiébaud Weksteen
4d132a10b0 Fix build after upstream merge
- Reference renamed file: COPYING -> LICENSE in Android.bp
- Fix constext_str calls now returning const char *
- Comment out cil_write_src_info_node which is not used on Android
- Include new selinux_internal.c source file

Bug: 253327909
Test: build and boot on bramble
Test: sediff between current and new policy; no change
Change-Id: I506479befb3c0b99136cd842b2a77a6a8bea18ed
2022-11-25 14:10:15 +11:00
Petr Lautrbach
fb7f35495f Fix E275 missing whitespace after keyword
Fixes:
  ./gui/polgengui.py:484:18: E275 missing whitespace after keyword
  ./gui/polgengui.py:530:18: E275 missing whitespace after keyword
  ./python/sepolgen/src/sepolgen/policygen.py:327:19: E275 missing whitespace after keyword
  ./python/sepolgen/src/sepolgen/policygen.py:329:11: E275 missing whitespace after keyword
  ./python/sepolicy/sepolicy/__init__.py:453:15: E275 missing whitespace after keyword
  ./python/sepolicy/sepolicy/generate.py:1351:28: E275 missing whitespace after keyword
  ./python/sepolicy/sepolicy/generate.py:1353:28: E275 missing whitespace after keyword
  ./python/sepolicy/sepolicy/gui.py:638:24: E275 missing whitespace after keyword
  ./python/sepolicy/sepolicy/gui.py:863:23: E275 missing whitespace after keyword
  ./python/sepolicy/sepolicy/gui.py:2177:16: E275 missing whitespace after keyword
  ./sandbox/sandbox:114:7: E275 missing whitespace after keyword
  ./sandbox/sandbox:134:11: E275 missing whitespace after keyword
  ./sandbox/sandbox:136:7: E275 missing whitespace after keyword

Signed-off-by: Petr Lautrbach <lautrbach@redhat.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-11-23 08:29:59 -05:00
Petr Lautrbach
25d7941aee fixfiles: Unmount temporary bind mounts on SIGINT
`fixfiles -M relabel` temporary bind mounts file systems before
relabeling, but it left the / directory mounted in /tmp/tmp.XXXX when a
user hit CTRL-C. It means that if the user run `fixfiles -M relabel`
again and answered Y to clean out /tmp directory, it would remove all
data from mounted fs.

This patch changes the location where `fixfiles` mounts fs to /run, uses
private mount namespace via unshare and adds a handler for exit signals
which tries to umount fs mounted by `fixfiles`.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2125355

Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
Tested-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-11-23 08:28:23 -05:00