Filip Skrzeczkowski [Fri, 28 Feb 2025 13:48:25 +0000 (14:48 +0100)]
Fix security_manager_set_identity with author id
Change-Id: Ia5e0712817c74704d6943eae6ed79e8d29713cea
Krzysztof Jackiewicz [Wed, 26 Feb 2025 09:56:58 +0000 (10:56 +0100)]
Simplify owner check for non-apps
Change-Id: Ieaf6b7a1b36911f9dd97680e0811ab0b716d2cae
Krzysztof Jackiewicz [Fri, 21 Feb 2025 15:38:54 +0000 (16:38 +0100)]
Set default ACL rules for directories only
Default ACL rules can be set on directories so that files and
directories created in them get the ACLs automatically.
The goal of this commit is to properly handle a rare case where an
application path is not a directory but a file.
Change-Id: Iac20c15e689b23486966649f2dc2222614942743
Krzysztof Malysa [Fri, 14 Feb 2025 16:59:07 +0000 (17:59 +0100)]
Ensure apps in the package have unique names
Change-Id: I6bf4af9657ddd37f3970148c1a3e660b510aa414
Tomasz Swierczek [Thu, 20 Feb 2025 10:35:56 +0000 (11:35 +0100)]
Release 2.0.1
* Add missing 'x' to others
* Take user from the request instead of credentials
* Fix Author's gid getter
* Fix trusted dir access
Change-Id: I3038391f92df506a06a0d3bf3ac6382e695a2319
Krzysztof Jackiewicz [Wed, 19 Feb 2025 10:25:53 +0000 (11:25 +0100)]
Add missing 'x' to others
Change-Id: I7e8f89b48c9fdcd5e31021560917bb19634b156a
Krzysztof Jackiewicz [Tue, 18 Feb 2025 17:12:26 +0000 (18:12 +0100)]
Take user from the request instead of credentials
Installation and path requests include and uid of the user on behalf of
which the request is processed. This is not always the same as the uid
of the calling process provided in Credentials.
Change-Id: I3d273770ef4d1a79e6be168e9dc6d94ecbf622af
Krzysztof Jackiewicz [Tue, 18 Feb 2025 15:01:33 +0000 (16:01 +0100)]
Fix Author's gid getter
Change-Id: If66f65ed01854c88b8229b4fe606ef7302d2107a
Krzysztof Jackiewicz [Fri, 14 Feb 2025 17:56:49 +0000 (18:56 +0100)]
Fix trusted dir access
Trusted path should not be accessible if there's no author. This may
happen if an app with trusted path is installed again without an author.
Change-Id: Ibe6506917e68b36d43cdf1ea701cf2c9c62a0e28
Tomasz Swierczek [Fri, 7 Feb 2025 09:40:51 +0000 (10:40 +0100)]
Release 2.0.0
“...reality, however utopian, is something from which
people feel the need of taking pretty frequent holidays....”
― Aldous Huxley, Brave New World
This release of security-manager intends NOT to differ at all in behaviour
on smack-enabled images.
Only one commit is related to bugfix on actual tizen branch that were done recenlty
on tizen_9.0 and tizen_8.0:
* Set HIGHEST priority to APP_CLEAN_NAMESPACE event
However, on images without smack (compiled with dev_wos GBS flag), this release
introduces UID-based sandboxing. Each app that would normally be sandbox-ed with its
unique Smack label, gets its own UID at launch (aka PUID). Like in smack-enabled
mode, hybrid apps in one package do get their individual PUIDs.
With this release (and paired cynara & security-config releases,
and also security-tests modifications to-date):
* application sandboxing works without Smack
* access control to app disk folders is done with DAC & ACLs
* privilege setup is done normally but for PUID
* cynara policy checks are configured to work based on caller's UID (PUID for apps)
As the no-smack compilation constitutes a PoC for now, there are some items not ready yet
that will be addressed in nearest future - as this release aims at unblocking modifications
of the rest of the system for the no-smack mode.
Known issues
------------
* internet & app debugging access control - used to be done with Smack, now its just permissive mode
* private sharing API between apps is not ported to use PUID and DAC yet (implementation in progress)
* not all security-tests pass in no-smack mode (work in progress on adjustment)
* migration script needs to be added IF this would get pushed to a device running previous Tizen versions
(migration of DB, ACL permissions, etc. needed).
* (not dependent on security FW): the no-smack image may not boot homescreen due to launchpad issues
* (not dependent on security FW): access to parent directory of app sandbox may be blocked & changes
in gumd may be needed (change to 755 in /etc/gumd/useradd.d/91_user-dbspace-permissions.post)
* (not dependent on security FW, mitigated here): access to /run/user/5001 for others is added
on daemon startup to allow apps access (this should be re-engineered for multiuser later)
After this release, launchpad & aul-1 & other Tizen components need to adjust themselves
to new policy configuration in the absence of Smack.
Change-Id: Ib92c84e3216b663d68f631abb8469419f860c157
Krzysztof Jackiewicz [Fri, 14 Feb 2025 16:28:42 +0000 (17:28 +0100)]
Add system_access to forbidden groups
Change-Id: Ied3b85b25b348529ea74d748719464accb6d7d64
Dariusz Michaluk [Mon, 10 Feb 2025 11:10:13 +0000 (12:10 +0100)]
Set HIGHEST priority to APP_CLEAN_NAMESPACE event
Change-Id: Id6513fd06ccdb631d0a2f550e25cc968adbf402a
Tomasz Swierczek [Fri, 14 Feb 2025 11:11:04 +0000 (12:11 +0100)]
Configure app access to /run/user/<uid> for existing users
Apps are least privileged entities in the OS and need access to that diretory.
This is a temporary solution - long term, a group would have to be created
for each real user & that user's (that UID's) path would need to be accessible
only to apps having that group. This commit is a workaround to enable further
work on no-smack images.
Change-Id: I6bd1d0df8939d47813b7f3807551b455b0b72ec1
Krzysztof Jackiewicz [Tue, 11 Feb 2025 11:45:03 +0000 (12:45 +0100)]
Use app PUID when checking path privileges
Change-Id: I6015afe994f88362f48bca2c54cbaa6564328681
Filip Skrzeczkowski [Wed, 5 Feb 2025 16:28:08 +0000 (17:28 +0100)]
Make app identification APIs work on no-smack
Change-Id: I439afdccf91f6d677661cb52fa14ff6e14be4b11
Filip Skrzeczkowski [Wed, 29 Jan 2025 19:35:09 +0000 (20:35 +0100)]
Implement security_manager_get_app_owner_uid for no-smack tizen
Test with security_manager_26_1_security_manager_get_app_owner_uid in no-smack mode.
Change-Id: I5890289df072f5113caba8231aa125a332a48dd8
Krzysztof Malysa [Fri, 7 Feb 2025 14:46:03 +0000 (15:46 +0100)]
Restore client authentication
Change-Id: I5b73fd3f5523ce8002fca6d912552c3527291f63
Krzysztof Malysa [Mon, 3 Feb 2025 15:00:33 +0000 (16:00 +0100)]
Use process UID as user for app permissions in cynara
All tests from group SECURITY_MANAGER_PREPARE_APP should work on
no-smack image. Additionally the below tests should pass:
- security_manager_01a_app_double_install_double_uninstall
- security_manager_01b_app_double_install_wrong_pkg_id
- security_manager_01c_app_uninstall_wrong_pkg_id
- security_manager_01d_app_install_complicated_dir_tree
- security_manager_02_app_install_uninstall_full
- security_manager_02a_set_process_groups
- security_manager_04b_app_install_by_root_for_app_user
- security_manager_05_drop_process_capabilities
- security_manager_06_install_app_offline
- security_manager_07a_user_add_app_install
- security_manager_07b_user_add_offline
- security_manager_08_user_double_add_double_remove
- security_manager_09a_install_many_apps_in_single_request
- security_manager_09c_update_many_apps_in_single_request_hybrid_package
- security_manager_09d_uninstall_app_from_hybrid_package
- security_manager_09e_update_app_nonhybrid_package
- security_manager_09f_update_app_hybrid_package
- security_manager_10_app_has_privilege
- security_manager_24_groups_get
- security_manager_25a_global_user_set_install_type_global
- security_manager_26_hybrid_pkg_uninstall_artifacts_check
Change-Id: I91d79f8f829de08d71b5068a82ac278813f9dba7
Krzysztof Malysa [Thu, 30 Jan 2025 14:42:16 +0000 (15:42 +0100)]
Add migrating apps installed as if in smack mode on no-smack image
Change-Id: I7b147eee82fe00dcaedf57cfbb7a5b1a973083d3
Krzysztof Malysa [Thu, 30 Jan 2025 11:32:02 +0000 (12:32 +0100)]
Adjust cynara policy to use UIDs instead of Smack labels on no-smack image
Change-Id: I7a4dbd3799e58cdb90f5f43be01869e68bb31b81
Krzysztof Jackiewicz [Wed, 22 Jan 2025 15:20:55 +0000 (16:20 +0100)]
Setup paths using DAC
Change-Id: I7841eb8807e16190d0c1b733be498775413f8af5
Krzysztof Jackiewicz [Mon, 27 Jan 2025 20:13:23 +0000 (21:13 +0100)]
Refactor smack labeling
Change-Id: Ife4a8f6cbda9261bb3b7e778feda939200582671
Krzysztof Jackiewicz [Mon, 3 Feb 2025 15:53:25 +0000 (16:53 +0100)]
Acl tests
Change-Id: Ic0f8bcf612681bba6f088d48083d68ff1f2fe8dd
Krzysztof Malysa [Wed, 12 Feb 2025 14:53:36 +0000 (15:53 +0100)]
Fix ACL helper
Change-Id: I3273fb0ccd43c61650e714dd9793557ab4fa9e03
Krzysztof Jackiewicz [Wed, 22 Jan 2025 15:20:04 +0000 (16:20 +0100)]
Add ACL helper
Change-Id: Ie21acf4a60d67242f896d89bbf16d3167e549a44
Krzysztof Jackiewicz [Mon, 27 Jan 2025 15:00:44 +0000 (16:00 +0100)]
Remove unused exec labeling code
Change-Id: I1047cccca03e686eef003da63410be3290c1ce01
Krzysztof Jackiewicz [Thu, 30 Jan 2025 13:38:43 +0000 (14:38 +0100)]
Refactor path_req
* Structure is now serializable so we can get rid of member-by-member
(de)serialization
* Change installationType type to app_install_type so that it better
reflects the actual type stored in it.
Change-Id: I33021a8cb34481b981f84bb01d6388da848bf165
Krzysztof Jackiewicz [Thu, 30 Jan 2025 09:51:19 +0000 (10:51 +0100)]
Remove permissible file logic in no-smack
Change-Id: Iceb1d9556c93f04a6f659a3c48603fa2a4f8e870
Krzysztof Jackiewicz [Wed, 22 Jan 2025 08:48:29 +0000 (09:48 +0100)]
Refactor labelPaths
Change-Id: I4a1280bb857c47435da7a00c7744cf61f41ab0c2
Krzysztof Jackiewicz [Tue, 21 Jan 2025 15:36:17 +0000 (16:36 +0100)]
Add libacl dependency
Change-Id: I9e7865e3b60014afecb21748a2304eae47875d0b
Krzysztof Jackiewicz [Tue, 21 Jan 2025 09:25:38 +0000 (10:25 +0100)]
Add gid-by-name getter
Change-Id: I0e6b2ea2777338a3599ca23eb0d1255a43fb7f01
Krzysztof Jackiewicz [Tue, 28 Jan 2025 11:24:52 +0000 (12:24 +0100)]
Disable Shared RO namespaces in no-smack
We can express the policy (RW for owners and system, RO for others)
using ACL and DAC.
Change-Id: Ia9f1951311c080e265f0d4fe4b4af5fcb9289368
Krzysztof Jackiewicz [Tue, 21 Jan 2025 08:57:49 +0000 (09:57 +0100)]
Enable proper drop check
Change-Id: I55f035dd70282ebae8c75220b8e6ad4624b84f25
Krzysztof Jackiewicz [Tue, 21 Jan 2025 08:54:33 +0000 (09:54 +0100)]
Unlock security_manager_drop_process_privileges
The following test should pass:
security_manager_05_drop_process_capabilities
Change-Id: I444ef19f189052e42efdcd08849488c71815e043
Krzysztof Jackiewicz [Tue, 21 Jan 2025 08:26:30 +0000 (09:26 +0100)]
Enable namespace setup & cleanup in no-smack
Following security-manager-tests should pass:
security_manager_101_create_namespace_test_n
security_manager_101_create_namespace_test_p
Change-Id: I73936afc1f12f26ae94e20bcae2f63ec028163f7
Krzysztof Jackiewicz [Mon, 20 Jan 2025 11:12:13 +0000 (12:12 +0100)]
Use process UId & author GId in app preparation
* Replace smack label with UId in app preparation
* Add author GId to app supplementary groups if available
* Setuid before capability drop (otherwise supplementary threads won't
be able to drop it).
* Don't wait for signal handlers to complete. Capset() should not
affect inter-thread communication.
* Require CAP_SETUID in pre-check.
* Pass process UId to cynara upon installation & deinstallation.
* Return no-smack label from label generation functions.
* Modify first free process UId and author GId lookup function to ignore
existing smack-enabled apps with lower ids. This is to allow testing on
databases containing smack-enabled apps.
* Add unit tests.
All unit tests should pass in both smack and no-smack modes.
The following security-manager-tests should pass in no-smack mode:
security_manager_100_synchronize_credentials_test
security_manager_100_synchronize_credentials_no_author_test
security_manager_190_prepare_app_threads_malloc
security_manager_300_prepare_app_recursive_threads
security_manager_400_prepare_app_with_concurrent_install
security_manager_400_prepare_app_series_with_concurrent_install_stress
Change-Id: I390e957cc60576f92bd925ff0be227fdb760648a
Krzysztof Jackiewicz [Thu, 16 Jan 2025 09:42:17 +0000 (10:42 +0100)]
Skip author hash in no-smack mode
Change-Id: If0496a4455f06759b16c2e2156f0d8eadb6b574c
Krzysztof Jackiewicz [Tue, 14 Jan 2025 14:48:24 +0000 (15:48 +0100)]
Disable smack label tests
Change-Id: I6f0309a0cff114214361b972739785094e5552ae
Krzysztof Jackiewicz [Tue, 14 Jan 2025 10:52:45 +0000 (11:52 +0100)]
Disable rules-loader test in no-smack mode
Rules loader produces no output in no-smack mode
Change-Id: I20bdd7b38545093c8a371f79be873821b311ad53
Krzysztof Jackiewicz [Wed, 8 Jan 2025 15:51:19 +0000 (16:51 +0100)]
Skip CAP_MAC_ADMIN check in no-smack mode
Change-Id: I10dfed5983d3ef1d6f03256e3bbe43fb2461c45d
Krzysztof Jackiewicz [Thu, 2 Jan 2025 14:37:39 +0000 (15:37 +0100)]
Add process UId and author GId support in no-smack mode
The process UId is an equivalent of a process smack label. Therefore,
it must follow the hybridity rules:
1. For non-hybrid apps, all apps in the package must have the same
process UId.
2. For hybrid apps, each app must have a different process UId.
To achieve that, the process UId equal to pkg_id for non-hybrid apps
and equal to app_id for hybrid apps.
The author GId is always equal to author_id.
During app installation in no-smack mode, the pkg_id, app_id and
author_id are selected as follows:
1. author_id is set to the smallest unused value starting from 20000.
2. pkg_id and app_id are set to the smallest value unused in both
pkg_id from table pkg and app_id from table app starting from 10000.
To achieve that, the StmtType::EAddApplication and
user_app_pkg_view_insert_trigger have been adjusted to accept 3
additional arguments (pkg_id, app_id and author_id). Setting them to
null in smack-enabled mode makes sqlite assign these values as before
(see https://www.sqlite.org/quirks.html#primary_keys_can_sometimes_contain_nulls).
If an app being installed in no-smack mode belongs to an existing
package or author, the corresponding "INSERT OR IGNORE" on pkg or
author table will fail, making the rest of the query reuse existing
values.
Add statements facilitating pkg_id, app_id & author_id lookup.
Bump db version to apply view change.
Add unit tests (test suite: PRIVILEGE_DB_TEST_PROCESS_UID_AUTHOR_GID).
Change-Id: I7cfaf7bc552b7ee3b1166024707f22d8af7c1a8d
Tomasz Swierczek [Wed, 5 Feb 2025 07:18:20 +0000 (08:18 +0100)]
Release 1.9.18
* Change the way we pre-load symbol for syscall by calling it
Change-Id: Iee6cf0a127c50c5dfb9b44e88fad0f86857c1334
Tomasz Swierczek [Wed, 5 Feb 2025 07:05:06 +0000 (08:05 +0100)]
Change the way we pre-load symbol for syscall by calling it
Apparently using -1 as invalid argument can fail with SIGILL
on some configurations (happened on VD side).
Change-Id: I26d1d0411c637a67888a8d1e73892171004d05a3
Tomasz Swierczek [Thu, 16 Jan 2025 12:37:01 +0000 (13:37 +0100)]
Release 1.9.17
* Fix possible issue with lazy-symbol binding
Change-Id: I813fc8f6d1e61d01937664e09a1e8ee2546391ab
Tomasz Swierczek [Thu, 16 Jan 2025 12:30:17 +0000 (13:30 +0100)]
Fix possible issue with lazy-symbol binding
It seems possible that lazy binding of the SO symbols loaded by linker can cause problems
when the SIGSETXID arrives in some thread at the precise moment that a symbol in a thread
is being lazy-initialized. By doing calls below we're ensuring that symbols used inside
our handler are already loaded - lazy symbols (or any not-loaded) should not be called inside
a handler.
Also, changed the handler to be a regular function for easier debugging in kernel team.
Change-Id: I6a293374c38f47b18af86166d8b150af55469739
Tomasz Swierczek [Thu, 9 Jan 2025 05:53:52 +0000 (06:53 +0100)]
Release 1.9.16
* Add security_manager_is_app_from_pid() function
Change-Id: Iea0b4651a91b39cf4db20f82db2b722a4113d82a
Tomasz Swierczek [Wed, 8 Jan 2025 07:15:41 +0000 (08:15 +0100)]
Add security_manager_is_app_from_pid() function
Change-Id: I53ed6e507a945e1829e851621e521417bef831b5
Krzysztof Jackiewicz [Tue, 31 Dec 2024 13:04:49 +0000 (14:04 +0100)]
Release 1.9.15
* Mark thread as dead in case of ESRCH
* Disable logging during thread sync
* Remove log from get_alive_threads()
* Put abort() in place to facilitate debugging
Change-Id: I7e56ad62b4338ddc0149bf322d155f939ecd478f
Krzysztof Jackiewicz [Tue, 31 Dec 2024 12:33:27 +0000 (13:33 +0100)]
Mark thread as dead in case of ESRCH
This may speed up the thread sync a bit
Change-Id: Ib6a9c8f11a719615227efd24da18c65b91d69bf0
Krzysztof Jackiewicz [Tue, 31 Dec 2024 10:58:40 +0000 (11:58 +0100)]
Disable logging during thread sync
Change-Id: I78e3154a6f5ae4697a461a0cbcce4affca2f50dd
Krzysztof Jackiewicz [Tue, 31 Dec 2024 10:30:50 +0000 (11:30 +0100)]
Remove log from get_alive_threads()
No allocations allowed during thread sync
Change-Id: I3e539c4572ccfba96ba798383c1eea7d0260cd44
Krzysztof Jackiewicz [Tue, 31 Dec 2024 09:36:55 +0000 (10:36 +0100)]
Put abort() in place to facilitate debugging
This way the backtrace will show us the point of failure
Change-Id: I97f70db007661b91baa757442b01c0cdc3270a5b
Dongkyun Son [Tue, 5 Nov 2024 08:28:46 +0000 (17:28 +0900)]
packaging: asan: skip Werror=stringop-overread
Change-Id: I10972a6d7bb01cc2d7e017b4d2a06189e33f674f
Signed-off-by: Dongkyun Son <dongkyun.s@samsung.com>
Tomasz Swierczek [Thu, 19 Dec 2024 08:11:52 +0000 (09:11 +0100)]
Release 1.9.14
* Change runtime Smack check in dev_wos cases to compile-time
* Add argument check to security_manager_set_identity()
Change-Id: I6ff748258a07d98c32d31f43c2b9e30a65f2dc9a
Tomasz Swierczek [Thu, 19 Dec 2024 08:01:08 +0000 (09:01 +0100)]
Change runtime Smack check in dev_wos cases to compile-time
Previous patch didn't work for PontusM smack-enabled environment.
Now this patch ensures that WITHOUT dev_wos flag, there is definitely
no difference in logic of security-manager, even in the absence of Smack
(ie. during image creation).
Change-Id: If37d9ceae8bcb5727e82f7310acff0358b820240
Jan Wojtkowski [Wed, 18 Dec 2024 11:30:04 +0000 (12:30 +0100)]
Add argument check to security_manager_set_identity()
Change-Id: Ibac8f33ae7eaef9bff7b67fdea53bc6f82591fbb
Tomasz Swierczek [Fri, 13 Dec 2024 12:53:28 +0000 (13:53 +0100)]
Release 1.9.13
* Change process_type elements with additional prefix
Change-Id: I5eb61bbc15a5aa8b8cc66ef046e2fb4f280d6605
Tomasz Swierczek [Fri, 13 Dec 2024 12:24:23 +0000 (13:24 +0100)]
Change process_type elements with additional prefix
askuser-notification couldn't be built because of ambiguity
in the APIs/enums.
Also, added missing header.
Change-Id: I1dbc4ef6cac4cdf74db200b85b790424d3b03ee4
Tomasz Swierczek [Thu, 12 Dec 2024 09:56:11 +0000 (10:56 +0100)]
Release 1.9.12
* Make security_manager_set_identity() and security_manager_self_is_app() work in dev_wos env
* Add function security_manager_set_identity()
* Add function security_manager_get_app_owner_uid()
* Silence SVACE warning
* Add function security_manager_self_is_app()
* Add security-manager permissive mode build option - dev_wos
Change-Id: I3c225668a16f500fd875a951534b4754e73bb4a2
Tomasz Swierczek [Thu, 12 Dec 2024 09:50:39 +0000 (10:50 +0100)]
Make security_manager_set_identity() and security_manager_self_is_app() work in dev_wos env
Change-Id: I42437b6db64b5beb20c06339ae8f782e15562bf4
Jan Wojtkowski [Fri, 29 Nov 2024 10:17:32 +0000 (11:17 +0100)]
Add function security_manager_set_identity()
Change-Id: Iec954c9a41cbf0547de685590685fdbf2b03e5d6
Tomasz Swierczek [Thu, 12 Dec 2024 09:32:58 +0000 (10:32 +0100)]
Add function security_manager_get_app_owner_uid()
Change-Id: Ie8281381b9c2ce509aec7ef3f5a0dbdcf7e58a1f
Tomasz Swierczek [Tue, 19 Nov 2024 09:51:05 +0000 (10:51 +0100)]
Silence SVACE warning
Change-Id: Ib9baacdbdd47f197b39c530a2b5bff75e0fc944e
Tomasz Swierczek [Mon, 25 Nov 2024 14:27:57 +0000 (15:27 +0100)]
Add function security_manager_self_is_app()
Change-Id: I03c4b947295359964578d1eb9c7e78ea2b9223ff
Tomasz Swierczek [Mon, 15 Apr 2024 14:01:29 +0000 (16:01 +0200)]
Add security-manager permissive mode build option - dev_wos
Usage: gbs <your favourite flags> --define "dev_wos 1".
If not explicitly specified, the option is disabled (switched to 0).
This option is intended only for development, not for release builds.
With this option, security-manager enters "permissive mode"
and doesn't operate on Smack or anything that may be related:
* at launching:
** doesn't change/modify/configure mount namespaces
** doesn't change/modify/configure capabilities
** doesn't change/modify/set Smack labels of app candidate threads
** does set group IDs based on privileges in the Cynara DB
* at app installation:
** doesn't change any Smack labels of files/folders
Other operations (ie. registering apps in the DB) should be performed
as usual.
rules-loader service is only checking the DB and making sure it has
all proper schema applied (DB versioning, etc.) but otherwise,
the one-shot service is not loading any Smack rules.
With this option, the application identification functions that rely
on Smack being the application identifier, that is:
security_manager_identify_app_from_socket
security_manager_identify_app_from_pid
...will return same string default_app_no_Smack_mode as the app pkg ID.
The API function:
security_manager_identify_app_from_cynara_client
...will normally parse Smack label, as its expected that cynara helpers
will be returning the string:
User::Pkg::default_app_no_Smack_mode
...as cynara client.
The API function:
security_manager_app_has_privilege
...will always return success & access granted.
This mode is intended to be used by for bring-up development
of Tizen working in container.
Change-Id: I24c15bb51f87faab3ac14b9dae5e296d682bd768
Krzysztof Jackiewicz [Mon, 9 Dec 2024 10:40:27 +0000 (11:40 +0100)]
Release 1.9.11
* Remove remaining allocations
* Properly handle disappearing threads during sync
Change-Id: I9f45d44385d0a14805301707fe5e34602f571f35
Krzysztof Jackiewicz [Mon, 9 Dec 2024 11:43:46 +0000 (12:43 +0100)]
Remove remaining allocations
Change-Id: Ibbfe3b014f32b40065db35081110806f5545d83f
Krzysztof Jackiewicz [Mon, 9 Dec 2024 10:21:25 +0000 (11:21 +0100)]
Properly handle disappearing threads during sync
Plus few minor fixes
Change-Id: I0928f0ce811e26b25e3e3f566410f2ba95054416
Krzysztof Jackiewicz [Fri, 6 Dec 2024 19:37:04 +0000 (20:37 +0100)]
Release 1.9.10
* Don't use allocations during signaling
* Initialize all resource_pid_t members
* Add negative test for generateProcessLabel
Change-Id: Iab1dbdf5dc17ba082c14db2fb65440221278673e
Krzysztof Jackiewicz [Thu, 5 Dec 2024 16:26:59 +0000 (17:26 +0100)]
Don't use allocations during signaling
This is to prevent deadlock in malloc. It may happen if a supplementary
thread is interrupted after it took an internal glibc lock in malloc()
and it waits in a signal handler for the main thread. The main thread
won't be able to allocate memory due to lock taken by supplementary
thread.
Change-Id: I218075c2c2d6befa8fafb141e0507e64b5b47406
Krzysztof Jackiewicz [Fri, 25 Oct 2024 10:22:54 +0000 (12:22 +0200)]
Initialize all resource_pid_t members
Change-Id: I819693bc3cf895c28204c07dc2ee66a50efa7aeb
Krzysztof Jackiewicz [Thu, 31 Oct 2024 14:57:13 +0000 (15:57 +0100)]
Add negative test for generateProcessLabel
Change-Id: I8864eaae630302489d64b39013b433a267d3ed29
Tomasz Swierczek [Thu, 24 Oct 2024 09:59:25 +0000 (11:59 +0200)]
Release 1.9.9
* Remove unused code
* Fix double free in label monitor
Change-Id: I68dda88fefdee0b54f8791a153d63f7f1f98c1db
Krzysztof Jackiewicz [Wed, 23 Oct 2024 13:15:08 +0000 (15:15 +0200)]
Remove unused code
Change-Id: Ib0423186dc3183ecedb519600922995d438bf2b8
Krzysztof Jackiewicz [Thu, 24 Oct 2024 08:03:39 +0000 (10:03 +0200)]
Fix double free in label monitor
The pointer passed to initialize_inotify() is already managed by a unique_ptr.
In case of initialize_inotify() failure the pointer was being passed to
security_manager_app_labels_monitor_finish() where it was wrapped in a
unique_ptr again.
Add a helper non-throwing function operating on raw app_labels_monitor pointer
for properly closing it. Use it in security_manager_app_labels_monitor_finish()
and security_manager_app_labels_monitor_init().
Change-Id: I6f3b5883fde53ba3ded7764f3121f59ace053a10
Tomasz Swierczek [Tue, 22 Oct 2024 18:31:28 +0000 (20:31 +0200)]
Release 1.9.8
* Add check if HIGHEST priority is only for PREPARE_APP call
* Add check for CAP_MAC_ADMIN inside prepare_app2 call
* Added warning logs for events priority
* Fix logic in managing EAGAIN on sending signal in client (preapre_app2)
* Introduce separate thread for highest-priority events
* Make objects used in service_impl.cpp (mostly) thread safe
* Add highest priority & use it for SecurityModuleCall::PREPARE_APP
* Rename service-thread.h to service-thread-dispatcher.h
* Fix typo
Change-Id: Iea3507f1401b1b651ec2919626ddd1b863da9e44
Tomasz Swierczek [Tue, 22 Oct 2024 18:17:17 +0000 (20:17 +0200)]
Add check if HIGHEST priority is only for PREPARE_APP call
In case client was malicious, we could get events with highest
priority that are not PREPARE_APP calls, which could lead to
ie. multiple DB transactions being done in parallel threads
which the logic (service_impl.cpp) doesn't support as of now.
This technically eliminates the need for HIGHEST priority at all,
but it can be used in the future (if ie. a thread poll will be needed)
so it was not removed.
Change-Id: I30441b041610ef770cd0a23eb0d52216c7c1a7f3
Tomasz Swierczek [Tue, 22 Oct 2024 14:52:08 +0000 (16:52 +0200)]
Add check for CAP_MAC_ADMIN inside prepare_app2 call
Apparently in some weird scenarios, the wrt-loader or other launcher
that attempts at running apps, doesn't have the caps required.
Added check just prints proper error logs.
TODO: libsmack lacks function to get relabel-self list of labels
which probably should also be checked in the future (this is why
the check for CAP_MAC_ADMIN doesn't exit when there's no capability).
Change-Id: I5eeacb5ecb84883f6a4b2097887b82708297e98f
Tomasz Swierczek [Mon, 21 Oct 2024 08:21:12 +0000 (10:21 +0200)]
Added warning logs for events priority
This will ease debugging in case when many requests are being handled.
Change-Id: I85ee91d868c1e335e569fa67153a0871ce569eb9
Tomasz Swierczek [Thu, 17 Oct 2024 14:19:37 +0000 (16:19 +0200)]
Fix logic in managing EAGAIN on sending signal in client (prepare_app2)
Previous buggy version could lead to abort in case
2nd attempt at sending a signal went okay.
Change-Id: Ia0b0001f4ed602f9f7e5d40922998b5912a2414a
Tomasz Swierczek [Thu, 17 Oct 2024 13:49:54 +0000 (15:49 +0200)]
Introduce separate thread for highest-priority events
So far, only PREPARE_APP command on server side is treated as such.
Change-Id: Ia1dde64d0eaf0758f9f8c6c5e68d3e7a289eb3bb
Tomasz Swierczek [Thu, 17 Oct 2024 09:05:14 +0000 (11:05 +0200)]
Make objects used in service_impl.cpp (mostly) thread safe
So that its easier to introduce multiple-threads into the daemon.
**Disclaimer**
--------------
(1)
privilege_db is thread safe as long as only one thread is managing RW transactions
on the DB (each API of the DB takes & releases internal mutex).
This is enough to introduce a new separate thread just for prepare_app2 functionality
that only READS data and 2nd thread (current worker) operating on everything else,
including the RW operations.
To make a thread pool operate on many RW requests, transactions would need to be
handled in different way, so that they do not intertwine & the process
makes just one transaction at a time on the shared connection to the DB.
(2)
NSMountLogic is used only on policy update, so will be used only from the
standard worker thread (not the prepare_app2 thread). If thread pool will have
to be implemented in security-manager (or more than 1 thread to handle updates),
this would have to get reviewed.
(3)
Updates of permissible file with Smack labels of apps were left untouched to be done
on one thread (worker thread).
Change-Id: Idb228c52104058dce0c2ce43322613de09b8a06f
Tomasz Swierczek [Thu, 17 Oct 2024 07:49:52 +0000 (09:49 +0200)]
Add highest priority & use it for SecurityModuleCall::PREPARE_APP
So far without its separate thread, just to have separate queues
for the top-priority events.
Change-Id: I6d52e51fd8188a18f6b9650413ee6926139bdcd9
Tomasz Swierczek [Thu, 17 Oct 2024 07:32:51 +0000 (09:32 +0200)]
Rename service-thread.h to service-thread-dispatcher.h
This file will no longer implement only one service thread.
Changed the name not to be misleading.
Change-Id: Ibbf90daaf8a399108e5caabf4627ad8646156464
Tomasz Swierczek [Wed, 16 Oct 2024 09:39:43 +0000 (11:39 +0200)]
Fix typo
Change-Id: If73a6d618e446851689cbbe77e9ceee8a7fc292c
Tomasz Swierczek [Tue, 8 Oct 2024 13:53:30 +0000 (15:53 +0200)]
Release 1.9.7
* Add robot privileges
Change-Id: I9a9ee8878025e28485fa3cef4129f6c0c0737a16
Tomasz Swierczek [Tue, 8 Oct 2024 13:51:57 +0000 (15:51 +0200)]
Add robot privileges
http://tizen.org/privilege/robot.depthsensor
http://tizen.org/privilege/robot.map.get
http://tizen.org/privilege/robot.map.set
http://tizen.org/privilege/robot.movingpart
http://tizen.org/privilege/robot.navigation.get
http://tizen.org/privilege/robot.navigation.set
http://tizen.org/privilege/robot.property.read
http://tizen.org/privilege/robot.property.write
http://tizen.org/privilege/robot.speaker
http://tizen.org/privilege/robot.wheel
Change-Id: I525b92c01cc604f05f22c2ef6f942d891ebd16b9
Krzysztof Jackiewicz [Thu, 3 Oct 2024 08:06:55 +0000 (10:06 +0200)]
Release: 1.9.6
* Revert "Fix tgkill retry logic"
* Set minimal cynara-admin version
* Optimization: batch cynara admin checks into one API call
Change-Id: I755213257aa8001b19bc67d106807349db06dc3f
Krzysztof Jackiewicz [Tue, 1 Oct 2024 10:45:24 +0000 (12:45 +0200)]
Revert "Fix tgkill retry logic"
This reverts commit
f4e8020905f10fbcb12a06060aab132d2e447f3f.
Apparently there are some failures/crashes in other modules only if the
reverted commit is used. Reverting temporarily. To be investigated
later.
Change-Id: I9bd9e6b7acff8868609e2a91823ac1e73f87ef22
Krzysztof Jackiewicz [Thu, 3 Oct 2024 08:18:22 +0000 (10:18 +0200)]
Set minimal cynara-admin version
This is necessary as we started using the new cynara-admin API.
Change-Id: I4c660d22510326539c6e114fcbcf6d05307c558e
Krzysztof Malysa [Wed, 11 Sep 2024 16:02:06 +0000 (18:02 +0200)]
Optimization: batch cynara admin checks into one API call
Although the optimization's focus is on minimizing latency under load it shows some improvements overall.
Before (on emulator):
additionalThreads 32 nConcurrentApps 1 samples 94
prepareAppCandidate [us]: min 145 max 755 avg 470 median 459 stddev 72
prepareApp [us]: min 25 424 max 76 408 avg 40 300 median 42 693 stddev 7 330
prepareAppCandidate + prepareApp [us]: min 25 868 max 76 857 avg 40 770 median 43 166 stddev 7 337
nConcurrentApps 1 samples 135
prepareAppCandidate [us]: min 146 max 1 102 avg 476 median 457 stddev 88
prepareApp [us]: min 13 769 max 26 616 avg 21 278 median 20 438 stddev 1 968
prepareAppCandidate + prepareApp [us]: min 13 916 max 27 718 avg 21 754 median 20 893 stddev 1 993
nConcurrentApps 2 samples 216
prepareAppCandidate [us]: min 317 max 1 285 avg 522 median 500 stddev 114
prepareApp [us]: min 12 992 max 34 919 avg 24 143 median 23 894 stddev 4 035
prepareAppCandidate + prepareApp [us]: min 13 598 max 35 250 avg 24 666 median 24 419 stddev 4 028
nConcurrentApps 4 samples 384
prepareAppCandidate [us]: min 85 max 4 969 avg 678 median 600 stddev 552
prepareApp [us]: min 12 682 max 49 079 avg 25 782 median 24 161 stddev 6 644
prepareAppCandidate + prepareApp [us]: min 12 824 max 49 732 avg 26 461 median 24 774 stddev 6 609
nConcurrentApps 8 samples 672
prepareAppCandidate [us]: min 77 max 4 609 avg 512 median 435 stddev 397
prepareApp [us]: min 12 260 max 59 107 avg 25 890 median 24 256 stddev 7 760
prepareAppCandidate + prepareApp [us]: min 12 378 max 59 575 avg 26 403 median 24 723 stddev 7 795
nConcurrentApps 16 samples 1168
prepareAppCandidate [us]: min 79 max 4 619 avg 317 median 220 stddev 355
prepareApp [us]: min 12 656 max 57 372 avg 26 940 median 26 660 stddev 7 674
prepareAppCandidate + prepareApp [us]: min 12 806 max 57 963 avg 27 257 median 26 958 stddev 7 725
nConcurrentApps 32 samples 1824
prepareAppCandidate [us]: min 76 max 4 945 avg 184 median 136 stddev 287
prepareApp [us]: min 12 589 max 87 912 avg 37 803 median 36 480 stddev 15 334
prepareAppCandidate + prepareApp [us]: min 12 757 max 88 015 avg 37 987 median 36 606 stddev 15 379
After (on emulator):
additionalThreads 32 nConcurrentApps 1 samples 100
prepareAppCandidate [us]: min 197 max 655 avg 444 median 434 stddev 62
prepareApp [us]: min 30 372 max 44 675 avg 38 708 median 41 516 stddev 4 686
prepareAppCandidate + prepareApp [us]: min 30 795 max 45 328 avg 39 152 median 41 924 stddev 4 684
nConcurrentApps 1 samples 165
prepareAppCandidate [us]: min 83 max 803 avg 221 median 132 stddev 159
prepareApp [us]: min 12 224 max 23 058 avg 15 407 median 13 172 stddev 3 727
prepareAppCandidate + prepareApp [us]: min 12 319 max 23 638 avg 15 628 median 13 294 stddev 3 879
nConcurrentApps 2 samples 356
prepareAppCandidate [us]: min 66 max 1 470 avg 104 median 90 stddev 111
prepareApp [us]: min 11 949 max 20 065 avg 13 307 median 13 160 stddev 912
prepareAppCandidate + prepareApp [us]: min 12 025 max 20 144 avg 13 412 median 13 261 stddev 907
nConcurrentApps 4 samples 552
prepareAppCandidate [us]: min 72 max 696 avg 110 median 94 stddev 58
prepareApp [us]: min 12 115 max 18 504 avg 14 116 median 14 030 stddev 1 305
prepareAppCandidate + prepareApp [us]: min 12 251 max 18 756 avg 14 226 median 14 128 stddev 1 316
nConcurrentApps 8 samples 984
prepareAppCandidate [us]: min 71 max 2 196 avg 135 median 103 stddev 155
prepareApp [us]: min 11 948 max 25 692 avg 16 838 median 16 695 stddev 2 939
prepareAppCandidate + prepareApp [us]: min 12 041 max 26 019 avg 16 974 median 16 814 stddev 2 952
nConcurrentApps 16 samples 1184
prepareAppCandidate [us]: min 75 max 5 523 avg 401 median 227 stddev 584
prepareApp [us]: min 12 035 max 54 686 avg 25 184 median 24 884 stddev 7 269
prepareAppCandidate + prepareApp [us]: min 12 175 max 56 117 avg 25 585 median 25 202 stddev 7 398
nConcurrentApps 32 samples 1760
prepareAppCandidate [us]: min 72 max 4 791 avg 262 median 157 stddev 451
prepareApp [us]: min 12 654 max 87 433 avg 35 770 median 34 678 stddev 14 002
prepareAppCandidate + prepareApp [us]: min 12 777 max 88 638 avg 36 033 median 34 875 stddev 14 108
Change-Id: I0f039cf9c5023b78830816f776f108afdc8e2134
Tomasz Swierczek [Thu, 26 Sep 2024 07:02:56 +0000 (09:02 +0200)]
Release 1.9.5
* Change usleep time from 2 ms to 10 ms
* Add warning log for actually receiving a request from socket
* Fix potential memory leak
Change-Id: I4e43bf5ee16bf83214802b1fe3cc898758b584e7
Tomasz Swierczek [Thu, 26 Sep 2024 06:46:09 +0000 (08:46 +0200)]
Change usleep time from 2 ms to 10 ms
Apparently, the longer the sleep, less CPU time is used in heavy-load scenarios.
Change-Id: I79b89303eb14a74e699b7ba2e2980dd499dcb781
Tomasz Swierczek [Tue, 24 Sep 2024 10:00:55 +0000 (12:00 +0200)]
Add warning log for actually receiving a request from socket
Needed by VD to investigate few issues with performance on slower boards.
Change-Id: I3d0ba83303b4897212afe1dd100eef26a160f27a
Krzysztof Malysa [Wed, 11 Sep 2024 15:51:32 +0000 (17:51 +0200)]
Fix potential memory leak
Change-Id: I6a14537d3e510046b37603aa99e75f8f96b3a845
Dariusz Michaluk [Tue, 10 Sep 2024 11:25:10 +0000 (13:25 +0200)]
Release 1.9.4
* Add core privilege: isu.admin
* Add unit tests for increased coverage
* Fix tgkill retry logic
Change-Id: I5a1d33a07134d9d747912b0c26c9c5ffd08a4313
Mateusz Moscicki [Tue, 10 Sep 2024 08:30:23 +0000 (10:30 +0200)]
Add core privilege: isu.admin
Change-Id: I71d23fe21f9b82226d5604e5a173608068715c19
Tomasz Swierczek [Wed, 21 Aug 2024 10:28:05 +0000 (12:28 +0200)]
Add unit tests for increased coverage
Change-Id: Ifbb5ad446b4aa4c2d350f630ea713cd2d7bbbb9d
Krzysztof Jackiewicz [Mon, 22 Jul 2024 09:56:11 +0000 (11:56 +0200)]
Fix tgkill retry logic
If second tgkill attempt after EAGAIN succeeds, the abort() would still
be called. This commit fixes it.
Change-Id: I507c32188924fbb38f521c5d7fd1c1897c7ce534
Tomasz Swierczek [Thu, 11 Jul 2024 09:57:03 +0000 (11:57 +0200)]
Release 1.9.3
* Add more warning logs for performance analysis on release builds
* Remove pkg existance check in labelPaths function
* Remove unused function
Change-Id: If9efe93e4ffb4e2019724c258632ff6d60086dba