Commit graph

5185 commits

Author SHA1 Message Date
Thiébaud Weksteen
25fd00bf4e Move android_platform.c to android_seapp.c
Change-Id: If9c4f99a5c24d8698f8030e9ee0af8e74f42e5bd
2022-10-19 10:08:24 +11:00
Thiébaud Weksteen
d2180211b9 Trim down android_device.c
Change-Id: Ida1d455f7e2ea567ee0ff381a9bd5391a665bd2a
2022-10-19 10:08:24 +11:00
Thiébaud Weksteen
c8b3ae636f Define and use path_alts_t
The context file locations are represented using a 2-dimension array of
paths. Use a struct to simplify the syntax.

Bug: 234313751
Test: m
Change-Id: Iaf62955d1c142f4210215cecbee427e91031516e
2022-10-19 10:07:59 +11:00
Christian Göttsche
3f11c7d19c libsepol/cil: restore error on context rule conflicts
Commit bc26ddc59c ("libsepol/cil: Limit the amount of reporting for
context rule conflicts") reworked the processing of context rule
conflicts to limit the number of written conflicting statements to
increase readability of the printed error message.  It forgot to set the
return value, signaling a context conflict, in the case the logging
level is higher than warning (e.g. in semodule(8), which defaults to
error).

Reported-by: Milos Malik <mmalik@redhat.com> [1]
Fixes: bc26ddc59c ("libsepol/cil: Limit the amount of reporting for context rule conflicts")

[1]: https://lore.kernel.org/selinux/87y1u1rkoo.fsf@redhat.com/

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-10-13 11:24:00 -04:00
Christian Göttsche
fa5b0504d8 libselinux: support objname in compute_create
Support passing an optional object name to compute_create for name
based type transitions.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-10-13 11:23:41 -04:00
Paul Moore
a0a216ff7d docs: provide a top level LICENSE file
Provide a top level LICENSE file explaining how multiple the SELinux
userspace is released under multiple different licenses.  Also ensure
that all the different license files share a consistent file name,
LICENSE, to make it easier for people to identify the license files.

This is to help meet the OpenSSF Best Practices requirements.

Signed-off-by: Paul Moore <paul@paul-moore.com>
2022-10-05 08:20:38 -04:00
Paul Moore
4e562fa1ff docs: add Paul Moore's GPG fingerprint
Signed-off-by: Paul Moore <paul@paul-moore.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-10-05 08:16:51 -04:00
Matt Sheets
01b5ef48dc libsemanage: Allow user to set SYSCONFDIR
This change will allow a user to set the location of their
sysconfdir, defaulted to /etc, if they are installing into
nonstandard locations.

Signed-off-by: Matt Sheets <masheets@linux.microsoft.com>
Reviewed-by: Daniel Burgener <dburgener@linux.microsoft.com>
2022-10-05 08:15:00 -04:00
Dominick Grift
a21e8bee06 secilc/doc: classmap is also allowed in permissionx
Signed-off-by: Dominick Grift <dominick.grift@defensec.nl>
2022-10-05 08:14:11 -04:00
Vit Mojzis
5b5056b1b4 Update translations
Source: https://translate.fedoraproject.org/projects/selinux/

Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
2022-10-05 08:13:26 -04:00
Thiébaud Weksteen
12b4861e66 Remove android_common.h
This header file was used for all imports of android.c and
android_platform.c. Move the include directives to the source files
instead, to follow the include-what-you-use rule.

Bug: 234313751
Test: m
Change-Id: I362a722b2a3e7cd204772d8e37fa9b893184e1ce
2022-10-03 16:11:42 +11:00
Jiyong Park
7709493129 Merge "Annotate symbols correctly" am: 5f3411ec65 am: 055c4b7296 am: e8741de875 am: ef8f67b417
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2229044

Change-Id: I05caeaa437d7ce99161f4ec6553ecfe7fd24dcfb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-28 04:23:56 +00:00
Jiyong Park
ef8f67b417 Merge "Annotate symbols correctly" am: 5f3411ec65 am: 055c4b7296 am: e8741de875
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2229044

Change-Id: If1a84be22d7646aba20db0ef1911dc4e1b5d4711
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-28 03:42:48 +00:00
Jiyong Park
e8741de875 Merge "Annotate symbols correctly" am: 5f3411ec65 am: 055c4b7296
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2229044

Change-Id: I6e35759a8419c50c6592a375fc0e8063cf71e943
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-28 02:57:41 +00:00
Jiyong Park
055c4b7296 Merge "Annotate symbols correctly" am: 5f3411ec65
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2229044

Change-Id: I3c095c4d64b2137012b15ac9f97e4015b97918de
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-28 01:59:46 +00:00
Jiyong Park
5f3411ec65 Merge "Annotate symbols correctly" 2022-09-28 01:22:45 +00:00
Thiébaud Weksteen
e387e9b9a9 Reland unit tests for service contexts backend am: f53ffd8708 am: b27ca31bcd am: 92240add98 am: 1eb7b353a2
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2229000

Change-Id: I748ab3ede64a3d972631c05cf93e2be473f7925c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-28 00:16:07 +00:00
Thiébaud Weksteen
1eb7b353a2 Reland unit tests for service contexts backend am: f53ffd8708 am: b27ca31bcd am: 92240add98
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2229000

Change-Id: Ib83b57375a655081b73003823c585e195541a457
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-27 23:49:50 +00:00
Thiébaud Weksteen
92240add98 Reland unit tests for service contexts backend am: f53ffd8708 am: b27ca31bcd
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2229000

Change-Id: I16d33c350062a740e3c3710403f6909465f3c2e3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-27 23:19:18 +00:00
Thiébaud Weksteen
b27ca31bcd Reland unit tests for service contexts backend am: f53ffd8708
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2229000

Change-Id: Ice44c1e54b76d44595414cc9771c4a45ea2e3622
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-27 22:48:52 +00:00
Thiébaud Weksteen
f53ffd8708 Reland unit tests for service contexts backend
A compilation option ANDROID_UNIT_TESTING is introduced to skip the
implicit search for /sys/fs/selinux when libselinux is first
initialized. The label functions of libselinux are used as-is (instead
of a mock or fake).

Expose the context_handle function internally so it may be called within
the unit tests.

Bug: 234313751
Test: atest --host libselinux_test
Change-Id: Ifd7f4857c959a6c7d397682ba9913dc1d1cea591
2022-09-27 14:21:35 +10:00
Jiyong Park
6d1bbcddc6 Annotate symbols correctly
Currently, tagging a symbol with #apex (# systemapi or # llndk) is not
required when the symbol is in a non-NDK library. However, this is
considered dangerous because such a symbol will automatically be
promoted to NDK APIs when the library is promoted to an NDK library.
When that happens, the native API council won't be able to notice the
promotion because promoting a non-NDK library into an NDK library
doesn't require an update of the map.txt file, but Android.bp only.

To prevent that, we should mandate those tags for Mainline APIs
regardless of whether the library the API belongs to is an NDK library
or not.

Upcoming changes in build/soong will enforce this. This change is to
prepare for the enforcement.

Note that this is a build-time only change. There's no behavior change
at runtime.

Bug: 184712170
Test: m
Change-Id: I168fbdcf0a2a9b4e987a5410db941c0b4e4d9c35
2022-09-26 22:15:00 +09:00
Thiébaud Weksteen
0fed5250b6 Reland refactoring of sources in Android.bp am: 5cfe912553 am: 906e656994 am: 029261e331 am: 0d5bfb5030
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2222602

Change-Id: Ie52217e0eb9d423334f9be84d142bd89a0f279f7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-26 02:32:17 +00:00
Thiébaud Weksteen
0d5bfb5030 Reland refactoring of sources in Android.bp am: 5cfe912553 am: 906e656994 am: 029261e331
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2222602

Change-Id: I6c0b067edd28d4c652d9b7c0b88398cef72c038d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-26 02:00:33 +00:00
Thiébaud Weksteen
029261e331 Reland refactoring of sources in Android.bp am: 5cfe912553 am: 906e656994
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2222602

Change-Id: I1f8d20c47cc72802f464eb506345ed2b0d87fbba
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-26 01:21:23 +00:00
Thiébaud Weksteen
906e656994 Reland refactoring of sources in Android.bp am: 5cfe912553
Original change: https://android-review.googlesource.com/c/platform/external/selinux/+/2222602

Change-Id: Ib557a788f66b14548a82967837689514f467b1b8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-09-26 00:49:25 +00:00
Thiébaud Weksteen
5cfe912553 Reland refactoring of sources in Android.bp
Move sources files to the default libselinux rule so that other binaries
may reuse the same defaults (i.e., unittests). The majority of sources
can be compiled for the host.

Bug: 234313751
Test: local build for aosp_bramble-userdebug
Test: TH
Change-Id: I0b76bf79ceabd6096ab4ef03f0c8648d0636a310
2022-09-20 13:22:24 +10:00
bauen1
02bdee369c secilc/docs: disable pandoc default css for html docs
Some time ago pandoc started shipping a default css file for html, while
that is nice, it limits the max-width of the body element to 36em. We
have a lot of tables, code examples, etc... in the manual that are too
big for that, requiring constant scrolling.

See https://github.com/jgm/pandoc/blob/master/data/templates/styles.html
for the default used.

While some styling, perhaps even dark/light mode support in the CSS
would be nice, I didn't manage to find a simple way to achieve this, so
for now just disable the CSS.

Expand the arguments for pandoc in the Makefile for better readability.

Signed-off-by: Jonathan Hettwer (bauen1) <j2468h@gmail.com>
2022-09-01 09:27:17 -04:00
bauen1
198ca56a3a secilc/docs: fix syntax highlighting
It appears that a recent version of pandoc (or the library it uses)
changed where the lists are found in the XML or became more strict.

Move the lists to the right location in the document.

Signed-off-by: Jonathan Hettwer (bauen1) <j2468h@gmail.com>
2022-09-01 09:27:11 -04:00
Juraj Marcin
c916f0884b checkpolicy: avoid passing NULL pointer to memset()
Function `class_perm_node_init()` is called with `dest_perms` before it
is checked that its allocation succeeded. If the allocation fails, then
a NULL pointer is passed to `memset()` inside the
`class_perm_node_init()` function.

Signed-off-by: Juraj Marcin <juraj@jurajmarcin.com>
2022-09-01 09:27:01 -04:00
Juraj Marcin
eca72d8e47 libsepol: fix missing double quotes in typetransition CIL rule
CIL Reference Guide defines typetransition rule with double quotes
around object name, but those are not present in the format string.

This patch fixes this issue, so the CIL output produced by
sepol_kernel_policydb_to_cil() is in the correct format.

Signed-off-by: Juraj Marcin <juraj@jurajmarcin.com>
2022-09-01 09:26:56 -04:00
Christian Göttsche
c2d58b378b Ignore egg-info directories and clean them
Test .gitignore and make clean distclean
    error: missing .gitignore entry for libselinux/src/selinux.egg-info/
    error: missing .gitignore entry for python/sepolicy/sepolicy.egg-info/
    Error: Process completed with exit code 1.

    error: "make clean distclean" did not remove libselinux/src/selinux.egg-info/PKG-INFO
    error: "make clean distclean" did not remove libselinux/src/selinux.egg-info/SOURCES.txt
    error: "make clean distclean" did not remove libselinux/src/selinux.egg-info/dependency_links.txt
    error: "make clean distclean" did not remove libselinux/src/selinux.egg-info/top_level.txt
    error: "make clean distclean" did not remove python/sepolicy/sepolicy.egg-info/PKG-INFO
    error: "make clean distclean" did not remove python/sepolicy/sepolicy.egg-info/SOURCES.txt
    error: "make clean distclean" did not remove python/sepolicy/sepolicy.egg-info/dependency_links.txt
    error: "make clean distclean" did not remove python/sepolicy/sepolicy.egg-info/top_level.txt
    Error: Process completed with exit code 1.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-15 08:51:01 -04:00
Christian Göttsche
f304db813e scripts: ignore Flake8 tag E275
./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/build/lib/sepolicy/__init__.py:453:15: E275 missing whitespace after keyword
    ./python/sepolicy/build/lib/sepolicy/generate.py:1349:28: E275 missing whitespace after keyword
    ./python/sepolicy/build/lib/sepolicy/generate.py:1351:28: E275 missing whitespace after keyword
    ./python/sepolicy/build/lib/sepolicy/gui.py:638:24: E275 missing whitespace after keyword
    ./python/sepolicy/build/lib/sepolicy/gui.py:863:23: E275 missing whitespace after keyword
    ./python/sepolicy/build/lib/sepolicy/gui.py:2177:16: E275 missing whitespace after keyword
    ./python/sepolicy/sepolicy/__init__.py:453:15: E275 missing whitespace after keyword
    ./python/sepolicy/sepolicy/generate.py:1349:28: E275 missing whitespace after keyword
    ./python/sepolicy/sepolicy/generate.py:1351: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: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-15 08:50:18 -04:00
Christian Göttsche
178ae166e8 scripts/ci: use F36 image instead of F34
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-15 08:47:45 -04:00
Christian Göttsche
73b9106dae ci: bump versions in GitHub Actions
* Move from deprecated actions/setup-ruby to ruby/setup-ruby.
* Bump python and ruby upper versions.
* Bump Reference Policy version
* Do not install recommend packages and output package resolution
* Bump to macOS 12

  macOS 10 is deprecated since 5/31/22 [1].
  VirtualBox and Vagrant seems to be supported [2][3].

[1]: https://github.com/actions/virtual-environments/issues/5583
[2]: https://github.com/actions/virtual-environments/pull/5594
[3]: https://github.com/actions/virtual-environments/pull/5854

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-15 08:47:31 -04:00
Christian Göttsche
b5b3afbaed restorecond: use strict function prototype for definition
Clang 15 starts to complain about non strict function definitions:

    user.c:172:10: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    int start() {
             ^
              void

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Reviewed-by: Daniel Burgener <dburgener@linux.microsoft.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-15 08:46:56 -04:00
Christian Göttsche
2a9c619b5f checkpolicy: use strict function prototype for definitions
Clang 15 starts to complain about non strict function definitions:

    policy_define.c:4907:30: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    int define_devicetree_context()
                                 ^
                                  void
    policy_define.c:5298:29: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    int define_ipv4_node_context()
                                ^
                                 void

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Reviewed-by: Daniel Burgener <dburgener@linux.microsoft.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-15 08:46:41 -04:00
Christian Göttsche
142372522c libselinux: avoid newline in avc message
Do not add a final newline to the avc log message as it will be treated
as a part of the tclass field in final audit record:

    {
        "AUDIT_FIELD_EXE" : "/usr/bin/dbus-broker",
        "_UID" : "104",
        "_AUDIT_SESSION" : "4294967295",
        "_TRANSPORT" : "audit",
        "__REALTIME_TIMESTAMP" : "1659975331468531",
        "_AUDIT_TYPE" : "1107",
        "AUDIT_FIELD_SCONTEXT" : "system_u:system_r:systemd_t:s0",
        "_AUDIT_LOGINUID" : "4294967295",
        "_SELINUX_CONTEXT" : "system_u:system_r:system_dbusd_t:s0-s0:c0.c1023",
        "AUDIT_FIELD_SAUID" : "104",
        "MESSAGE" : "USER_AVC pid=1538 uid=104 auid=4294967295 ses=4294967295 subj=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 msg='avc:  granted  { send_msg } for  scontext=system_u:system_r:systemd_t:s0 tcontext=system_u:system_r:systemd_logind_t:s0 tclass=dbus\n exe=\"/usr/bin/dbus-broker\" sauid=104 hostname=? addr=? terminal=?'",
        "AUDIT_FIELD_TCONTEXT" : "system_u:system_r:systemd_logind_t:s0",
        "_SOURCE_REALTIME_TIMESTAMP" : "1659975331462000",
        "__MONOTONIC_TIMESTAMP" : "207995768",
        "AUDIT_FIELD_TCLASS" : "dbus\n",
        "AUDIT_FIELD_TERMINAL" : "?",
        "_PID" : "1538",
        "SYSLOG_FACILITY" : "4",
        "_BOOT_ID" : "3921464b65f64fb4a7c037dee97cd6ad",
        "SYSLOG_IDENTIFIER" : "audit",
        "_MACHINE_ID" : "5d78c28f10d54c0fb7b6fd1acc6af8ff",
        "_AUDIT_TYPE_NAME" : "USER_AVC",
        "__CURSOR" : "s=84589ce96ff8400189fc515ff892674a;i=c38e;b=3921464b65f64fb4a7c037dee97cd6ad;m=c65c378;t=5e5bd1ff7d4f3;x=c22e610fc9b00b10",
        "AUDIT_FIELD_ADDR" : "?",
        "AUDIT_FIELD_HOSTNAME" : "?",
        "_AUDIT_ID" : "1075",
        "_HOSTNAME" : "debianBullseye"
    }

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-15 08:45:09 -04:00
Christian Göttsche
1e3c557425 libsepol: refactor ebitmap conversion in link.c
Refactor the ebitmap conversions in link.c into its own function.

Do not log an OOM message twice on type_set_or_convert() failure.

Drop the now unused state parameter from type_set_or_convert() and
type_set_convert().

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-09 09:52:48 -04:00
Christian Göttsche
d2d24b9331 libsepol: more strict validation
Validate that

  - each constraint has at least one expression
  - classes reference a valid common class identifier
  - the role flavor is either ROLE or ATTRIB
  - types reference a valid primary identifier
  - types refer to a raw type, not an attribute, as bounds
  - extended permissions in avtabs have a valid specifier
  - type av rules refer to a raw type (e.g. type_transition)
  - conditionals have at least one expression
  - the state and flags of conditionals are valid
  - filename transitions have at least one datum
  - low ports are not bigger than high ones in port ocontexts
  - genfs declarations refer to a valid class identifier
  - genfs declarations contains a filesystem name
  - filename transitions refer to a raw type
  - permissive types are raw ones
  - the range transition hashmap is valid
  - the type-attribute-maps are valid

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-09 09:52:44 -04:00
Christian Göttsche
858f660831 libsepol: rename parameter name
Do not use `bool` as a parameter name, for future C version support.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-09 09:52:40 -04:00
Christian Göttsche
9e6f8ed70e libsepol: operate on const pointers during validation
The actual policy should not be modified during validation, thus use
const pointers.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-09 09:52:37 -04:00
Christian Göttsche
d192e4d937 libsepol: support const avtab_t pointer in avtab_map()
The access vector table itself is not modified in avtab_map() thus
support passing a const pointer.

Logically the content might be changed by the passed callback, but C
does not support transitive const-ness well, and C also does not support
function overloading, e.g. like for strchr(3).

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-09 09:52:34 -04:00
Christian Göttsche
938530171b libsepol: rename validate_policydb to policydb_validate
Most global functions operating on a policy database use policydb as
prefix.

Since this function is not exported there should not be any external
use.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-09 09:52:31 -04:00
Christian Göttsche
fc7bb9f05a libsepol: skip superfluous memset calls in ebitmap operations
The three members of struct ebitmap_node are all unconditionally
initialized.  Hinder compilers to optimize malloc() and memset() into
calloc(), which might be slightly slower.  Especially affects
ebitmap_or().

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-09 09:52:28 -04:00
Christian Göttsche
f174045525 libsepol: optimize ebitmap_xor
Iterate on nodes instead of single bits to save node resolution for each
single bit.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-09 09:52:25 -04:00
Christian Göttsche
efcd008148 libsepol: optimize ebitmap_and
Iterate on nodes instead of single bits to save node resolution for each
single bit.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-09 09:52:22 -04:00
Christian Göttsche
12a8a00bf2 libsepol: optimize ebitmap_not
Iterate on nodes instead of single bits to save node resolution for each
single bit.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-09 09:52:19 -04:00
Christian Göttsche
bc8f7b502b libsepol/cil: use ebitmap_init_range
Especially in the case of __cil_permissionx_expr_range_to_bitmap_helper()
it substitutes hundreds of thousand of calls to ebitmap_set_bit() during
semodule(8) on a policy widely using extended permissions.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-09 09:52:15 -04:00
Christian Göttsche
6f9e682c15 libsepol: add ebitmap_init_range
Add an initializer for ebitmaps that sets all bits in a given range to
save node traversals for each bit to set, compared to calling
ebitmap_init() followed by iterating ebitmap_set_bit().

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
2022-08-09 09:52:13 -04:00