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 [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
Tomasz Swierczek [Mon, 8 Jul 2024 07:40:50 +0000 (09:40 +0200)]
Add more warning logs for performance analysis on release builds
Change-Id: Ie83e2768d4da2208e1e4666b2c1969b2c38e2a6a
Tomasz Swierczek [Mon, 8 Jul 2024 07:42:44 +0000 (09:42 +0200)]
Remove pkg existance check in labelPaths function
The function is called 2 out of 3 times in places
where the package was already added (appInstall, appUpdate),
so no check is needed.
Added the check manually before function call in registering paths API,
where in fact we need to return invalid param for backward compatibility.
Change-Id: I7fb8b967409972ef1f0734f40320682b6bf6cc1b
Krzysztof Jackiewicz [Tue, 11 Jun 2024 08:21:44 +0000 (10:21 +0200)]
Remove unused function
Change-Id: I07191ea6a8a7632c7f0446fe5724eea678dae0f2
Tomasz Swierczek [Fri, 31 May 2024 04:38:47 +0000 (06:38 +0200)]
Release 1.9.2
* Add core privilege: keymanager.extended
Change-Id: Ib758362fe042a0d25f599a70304be926c8637897
Dariusz Michaluk [Fri, 17 May 2024 11:08:34 +0000 (13:08 +0200)]
Add core privilege: keymanager.extended
- keymanager.extended (platform level): app can use extended CKMC API
Change-Id: I1eee03db7511a7bbf18daf5dcc979857f258a4cf
Tomasz Swierczek [Wed, 17 Apr 2024 12:46:48 +0000 (14:46 +0200)]
Release 1.9.1
* Add mitigation for DDOS attack
* Adjust coverage script after lcov upgrade
Change-Id: Ib852206bcbeb276db97152c7b463916f62eff483
Tomasz Swierczek [Wed, 17 Apr 2024 11:48:46 +0000 (13:48 +0200)]
Add mitigation for DDOS attack
Adversary can send too big message to the daemon,
making it fail on allocation. Few places were required
to be enhanced with catch for std::bad_alloc & proper
graceful closing of connection instead of terminating
the process.
Change-Id: Id05dd3ee3d323a8d47ba93e33fae9d9bc6bb255d
Dariusz Michaluk [Fri, 5 Apr 2024 10:07:43 +0000 (12:07 +0200)]
Adjust coverage script after lcov upgrade
Change-Id: I5e02bfd884ea1fa8b6f96796bcaea143ac6eb10c
Tomasz Swierczek [Thu, 22 Feb 2024 16:47:27 +0000 (17:47 +0100)]
Release 1.9.0
* Add core privilege: wifi.secureinfo
Change-Id: I33704a6c60d798d788fd89dcfef7fe9c33a94871
Krzysztof Malysa [Tue, 20 Feb 2024 10:35:14 +0000 (11:35 +0100)]
Add core privilege: wifi.secureinfo
- wifi.secureinfo (platform level): app can read Wi-Fi security information
Change-Id: Iad23ef25c8c2aa65ecf27e47cc1ebbf59c645292
Tomasz Swierczek [Wed, 17 Jan 2024 08:53:05 +0000 (09:53 +0100)]
Release 1.8.14
* Removed unnecessary bloat & fix readme
* Modified error log in case of failed relabel_self setup
* Add unit tests for permissible file update, initialization and removal
* Implement a mechanism for permissible file repair
* Implement permissible file integrity verification
Change-Id: I1155d61b5343f8981facd2a3fb5b5a9d7f71a144
Tomasz Swierczek [Mon, 15 Jan 2024 14:39:30 +0000 (15:39 +0100)]
Removed unnecessary bloat & fix readme
Change-Id: Iafa766759f035a2b9f5d4232d0b16eac46781f4e
Tomasz Swierczek [Fri, 27 Oct 2023 14:05:59 +0000 (16:05 +0200)]
Modified error log in case of failed relabel_self setup
Error in this place sometimes happens on VD images, but without
harsh consequences, as if it happened in places where the label
list is still empty. Added number of labels to be printed.
Change-Id: I564b819dd53ae359b908ee111573cdde950343ce
Filip Skrzeczkowski [Wed, 4 Oct 2023 09:12:23 +0000 (11:12 +0200)]
Add unit tests for permissible file update, initialization and removal
Change-Id: Id05b5deaa8d4fd39c53478c555524f4be4ddac2b
Filip Skrzeczkowski [Thu, 28 Sep 2023 11:19:50 +0000 (13:19 +0200)]
Implement a mechanism for permissible file repair
Permissible files that have been marked as invalid due to their hash
not matching can now be repaired by fetching the relevant data directly
form PrivilegeDb. This works for both the service and the client library.
As the client lacks the privileges to do it on their own, in that case
a request is sent to the Security Manager daemon.
Change-Id: I43fee3d39c015a7fbba0e674c29c904ac26e91bf
Filip Skrzeczkowski [Wed, 23 Aug 2023 13:01:00 +0000 (15:01 +0200)]
Implement permissible file integrity verification
Permissible files have a SHA-1 hash attached at the beginning.
Upon opening it is compared with a new hash calculated from the
file content in order to verify if the file's integrity is intact.
An error is thrown should the hashes differ. Files with no hash are
still supported but reading/updating the rules stored in them
will cause them to automatically switch to the new system.
Change-Id: I5ec379b58cc78e63bcde084ada43273237d61beb
Tomasz Swierczek [Wed, 29 Nov 2023 10:06:34 +0000 (11:06 +0100)]
Release 1.8.13
* Rework security_manager_sync_threads_internal()
Change-Id: I03550d31dd5d8b1230dddc0f8c0b04e022beafce
Tomasz Swierczek [Fri, 24 Nov 2023 12:47:07 +0000 (13:47 +0100)]
Rework security_manager_sync_threads_internal()
Add "stop-the-world" implemenation in signal handler.
Why this change may be needed?
------------------------------
On slower platforms, some dotnet-based app candidate processes
tend to have 10-15-... threads. Sending signals that change
Smack labels & drop caps to each of them can be delayed - for apps
that don't have a priority to get launched, this can take up
to 10-15 seconds, in pathological cases (observed in real life,
on low-end boards). In such situation, there's non-zero time window
when some threads have changed security attributes and some
haven't - access control issues occur in app candidate's logic,
leading to serious errors & abort()s in the launched app.
With this modification, threads change the Smack labels & capabilities
when none of them are performing any of their original app candidate
logic and the only thread NOT in signal handler is the one
with security-manager client library.
This is expected to limit Smack/permission issues mentioned earlier.
Details, disclaimers:
---------------------
This implementation CANNOT fix an issue where app candidate process
created a resource (ie. a file) BEFORE call to security_manager_prepare_app()
and then, wants to access it (for read) AFTER call to the function.
This is because, before the transition, the process has either User
or System::Privileged Smack label, to which apps do not have R Smack rule
(such issues can still occur and can't be dealt with at security-manger level).
This implementation can be up to 3x slower on low-end boards,
as we have 3 waiting points here, instead of one:
1) waiting for signals to arrive in all threads (place from old implementation)
2) waiting for signals to be able to start changing caps/Smack labels
3) waiting for signals to sync after attributes are changed to start work
Tests performed on Tizen emulator show about 30-40% slowdown
of prepare app vs. previous implementation.
This implementation assumes that the size of set of all TIDs
that can appear in a process (already dead + currently alive) will not exceed 1000.
A global array of std::atomic's is used to keep track of each thread's
state in the execution of signal handler.
This implementation uses sleep() and std::atomic to implement
waiting for the barrier inside a signal handler (home-made spinlock,
basically). While this can be done more elegantly, ie. with std::atomic's wait()
functionality, this C++ feature doesn't seem to be supported in current Tizen
toolchain (c++2a supported, not full c++20).
An alternative way for synchronization would be to use high-profile system
resources like fd's or semaphores, however, because the VD H/W platform
where the issue of thread dis-synchronization happens is very slow, interfacing
with kernel was limited to minimum, as adding any context switch to kernel
may slow down even more.
Change-Id: Ic7037acaeb4e3eaab03284ae63216e7ab4d6d862
Tomasz Swierczek [Fri, 24 Nov 2023 10:20:27 +0000 (11:20 +0100)]
Release 1.8.12
* Add even more logs around IPC
Change-Id: I15012a4e14844397b3115ff8f21a6fb57256d524
Tomasz Swierczek [Fri, 24 Nov 2023 10:19:43 +0000 (11:19 +0100)]
Add even more logs around IPC
Needed by VD division for diagnostic purposes on release images.
Change-Id: Id45f577c50234a80152d646b6dc11f12b6633690
Tomasz Swierczek [Thu, 16 Nov 2023 10:49:00 +0000 (11:49 +0100)]
Release 1.8.11
* Add better logs around IPC
Change-Id: Ib5aa13e91250469b64c301ebfc17e7f5e7f2b2d1
Tomasz Swierczek [Thu, 16 Nov 2023 10:30:00 +0000 (11:30 +0100)]
Add better logs around IPC
Needed by VD division to debug socket clogging problem in the kernel.
Change-Id: Ic1764b8e9342f93911dcf26f6c03fca028a7f72f
Tomasz Swierczek [Tue, 17 Oct 2023 10:33:22 +0000 (12:33 +0200)]
Release 1.8.10
* Add mitigation for long processing of signals in VD's environments
Change-Id: I499a9b16bd2ba9552ac8972c7efba8e26b1906b2
Tomasz Swierczek [Tue, 17 Oct 2023 09:46:40 +0000 (11:46 +0200)]
Add mitigation for long processing of signals in VD's environments
* waiting for signals - timeout increased to 20s from 10s
* added 2 ms timeout if tgkill() will return EAGAIN (happend in actual product image in testing once)
Change-Id: I26ce63e66fc36536136a3eab7903efb07fb35437
Tomasz Swierczek [Thu, 31 Aug 2023 06:25:16 +0000 (08:25 +0200)]
Release 1.8.9
* Create DB file backup in case it was discovered to be corrupted
* Fix app-defined privileges certificate verification
* Migrate to openssl3
Change-Id: I5ebe3bbf8e081d0fbb2efe9f3ae2813db2cb158f
Tomasz Swierczek [Tue, 22 Aug 2023 07:54:48 +0000 (09:54 +0200)]
Create DB file backup in case it was discovered to be corrupted
This way, the DB can be later analyzed in detail.
Unit tests were modified to check if the backup
is properly created.
This change was requested by VD division.
Change-Id: I151113f793a2d87ea5060931ffeef72f511558cf
Dariusz Michaluk [Tue, 29 Aug 2023 09:30:50 +0000 (11:30 +0200)]
Fix app-defined privileges certificate verification
Since OpenSSL 3.0 a number of additional checks introduced to X509_verify_cert()
according to requirements in RFC 5280 in case X509_V_FLAG_X509_STRICT is set.
For example, the basicConstraints of CA certificates must be marked critical.
This checks cause verification failure for not well-formed certificates.
Having backward compatibility in mind, it's better to disable strict checking
than replacing all broken certificates in applications.
Change-Id: I8c6cb50be7c36ff7ef3d5c221dd4f066c2626be6
Dariusz Michaluk [Wed, 12 Jul 2023 10:13:04 +0000 (12:13 +0200)]
Migrate to openssl3
Change-Id: Ibab2eed97c6011e303433e48322b3f00fbb48a62
Tomasz Swierczek [Fri, 4 Aug 2023 06:26:37 +0000 (08:26 +0200)]
Release 1.8.8
* Fix error checking for open
Change-Id: I8780a3601482f84681f37009aa7dd0fd6ad7f4c8
Tomasz Swierczek [Fri, 4 Aug 2023 04:39:49 +0000 (06:39 +0200)]
Fix error checking for open
stdin should not get closed, but anyway, this should get fixed.
Change-Id: Icfeb0e8be0893ec14640f579d7818670d84ef918
Krzysztof Jackiewicz [Fri, 21 Jul 2023 08:56:28 +0000 (10:56 +0200)]
Release 1.8.7
* Improve threads' privilege synchronisation
Change-Id: I178bee9a70016bf29ac62de67576b3580ecbdf9b
Tomasz Swierczek [Thu, 13 Jul 2023 14:55:50 +0000 (16:55 +0200)]
Improve threads' privilege synchronisation
* Drop the caps after the threads have been listed for a second time
(after the sync). This is to avoid errors during accessing /proc for
newly spawned threads as a unprivileged process.
* Check if newly spawned threads have correct labels.
* Retry the privileges sync twice for all remaining privileged threads.
* Retry listing of /proc/self/task/ in case of failure.
* Use set instead of vector for easier tid checks.
* Omit main thread from the list.
Change-Id: I21e7e5dd3d5efb70fe51a1597bd7bc4ccf1099e8
Tomasz Swierczek [Tue, 11 Jul 2023 17:14:43 +0000 (19:14 +0200)]
Release 1.8.6
* Revert "Change the signal used by security-manager prepare_app implementation"
Change-Id: I26f7f7e384a4b0ca127acad3399d94e2c3a3fce1
Tomasz Swierczek [Tue, 11 Jul 2023 17:14:07 +0000 (19:14 +0200)]
Revert "Change the signal used by security-manager prepare_app implementation"
This reverts commit
4e26238c9e62a442042145a42207c8b669bf939d.
TCT tests seem to fail when signal is changed to SIGRTMIN+2
from SIGSETXID used previously.
Change-Id: Ib7df235addc30d6fb4b5d503a6f43d012218b55d
Tomasz Swierczek [Mon, 10 Jul 2023 05:49:31 +0000 (07:49 +0200)]
Release 1.8.5
* Increase waiting time for threads to receive signal
* Change the signal used by security-manager prepare_app implementation
* Fix an ugly bug in printing debug information about threads
Change-Id: I29507a05612dab8fcff9629bd743885b02c19ad5
Tomasz Swierczek [Mon, 10 Jul 2023 05:47:24 +0000 (07:47 +0200)]
Increase waiting time for threads to receive signal
As discussed with VD engineers, thats now increased to 10 seconds.
Also, additional log with information about waiting (warning log)
was added.
Change-Id: Iaf76777af2adb2ce65f98a71349a99e1a0704cd5
Tomasz Swierczek [Fri, 7 Jul 2023 08:10:20 +0000 (10:10 +0200)]
Change the signal used by security-manager prepare_app implementation
SIGSETXID was used previously to mimic the exact behaviour of glibc.
However, in testing on VD side using SIGSETXID can cause interference
with regular glibc usage, which also leads to abort().
To give more details: if threads are so delayed that their signal handling
is done ie. > 2 seconds after the sending was done, the signal arrives
in the thread when security-manager already did change the signal handler
back to original glibc. Then, glibc, checks whether it sent the signal,
it recognizes it didn't, and aborts/quits.
Changing signal number will not cause glibc to abort/fail, and if execution
gets back to security-manager main thread, IT will fail, printing
all necessary information about threads for debugging, before calling abort().
Changed signal number to SIGRTMIN+2, as advised.
Change-Id: I9b755504898daee71997ee35023c3d647e332b84
Tomasz Swierczek [Fri, 7 Jul 2023 07:28:06 +0000 (09:28 +0200)]
Fix an ugly bug in printing debug information about threads
The for range was calcualted based on wrong variable,
resulting in not all threads information being printed.
Also, changed error handling a bit.
Change-Id: I45fb88c889fb158ba63e0eb55f8d9c813fb40f9c
Tomasz Swierczek [Thu, 6 Jul 2023 07:29:14 +0000 (09:29 +0200)]
Release 1.8.4
* Fix static analysis issues
* Fix build for new toolchain
* Add additional debug information in prepare_app
Change-Id: I5ff8f36c31f7e5527a816842433a56c1ec2d1a00
Tomasz Swierczek [Thu, 6 Jul 2023 07:26:13 +0000 (09:26 +0200)]
Fix static analysis issues
Change-Id: I90839d874efd4e8b53a7c30870182fbf83c8c248
Tomasz Swierczek [Thu, 6 Jul 2023 07:05:04 +0000 (09:05 +0200)]
Fix build for new toolchain
Change-Id: I156cf22c4a752057490a6d6d7fbe040358fc933d
Tomasz Swierczek [Wed, 5 Jul 2023 08:28:57 +0000 (10:28 +0200)]
Add additional debug information in prepare_app
In case a thread is not receiving signal to change its Smack label
& capabilities, additional debugging information is required to
check what has happened.
Printing the debugging information is followed by an explicit
abort() so that the app candidate process can be debugged
to know what was happening inside each of the threads.
Statuses available to inspect each thread:
* thread dead during attempt to send signal
-> NOT an issue, but info is printed with TID as it can be useful
* thread not synced
-> thread was on the list when signal sending attempt was made,
but didn't seem to have received signal
* thread received signal
-> thread did receive signal, but failed at setting Smack label
* thread changed Smack label
-> it did receive signal, did change Smack label but cannot change caps
* thread fully synced
-> all went well - information is printed just to help debugging
Dump of status of each thread like above is printed ONLY if offending
thread is found that didn't seem to process signal handler correctly.
Change-Id: Ia1a560fb4baffadc354a403e60d1ab81d8828c42
Tomasz Swierczek [Fri, 16 Jun 2023 08:08:38 +0000 (10:08 +0200)]
Release 1.8.3
* Change the way threads are checked at the end of prepare_app call
Change-Id: I16c3b498726fede923dfce9cc1a603ad67e8dbb7
Tomasz Swierczek [Wed, 14 Jun 2023 07:45:05 +0000 (09:45 +0200)]
Change the way threads are checked at the end of prepare_app call
It was verified experimentally(*), that even if functions:
(1) smack_set_label_for_self()
(2) cap_set_proc()
have successfully changed process (main thread) security attributes,
even then /proc can contain stale/older data when implementation
in file:
check-proper-drop.cpp (the client side)
is checking whether all threads are properly synchronized.
Assuming mentioned functions operate properly and we trust their
return values, we can assume that checking in check-proper-drop.cpp
can be limited to checking if any new thread was spawned that was not
on the list of threads during call to function:
security_manager_sync_threads_internal()
This way, we're not relying on contents of /proc in terms of actual
security attributes, just the list of thread-IDs.
(*)
Following error (abort in client library) has been detected during
automated testing of VD image:
19548.940 E/SECURITY_MANAGER_CLIENT(P11930, T11930): check-proper-drop.cpp: checkThreads(175) > Offending taskId is: 11930
which means, that even though (1) and (2) succeeded for current taskId
(these had to, analysing the logic of our client library), there was an issue
in checking the contents of /proc for current taskId.
Change-Id: Ida49acd8981eea8c3df30ef32f23a1f4b0ef1ae3
Tomasz Swierczek [Tue, 30 May 2023 12:24:33 +0000 (14:24 +0200)]
Release 1.8.2
* Abort app candidate process in case of wrong setup
Change-Id: I13c0e803d1a39b50f4956b5fbb8facd7d8eea3cd
Tomasz Swierczek [Tue, 30 May 2023 11:46:12 +0000 (13:46 +0200)]
Abort app candidate process in case of wrong setup
When offending thread with higher privileges is detected,
new error log is added and security-manager-client library
forces entire app candidate process to abort.
This will effectively block possibility of privilege escalation
if a new thread was spawned ie. by Chromium during prepare_app call.
Abort will also generate coredump, making it easier to debug
the source of offending thread.
Change-Id: I16772d0e51aa112548acb64f7b82ccf87948ded9
Tomasz Swierczek [Wed, 24 May 2023 12:54:55 +0000 (14:54 +0200)]
Release 1.8.1
* Optimize operations on file with list of Smack labels
* Change order of items checking during getDirectoryContents() loop
* Small fixes in unit tests
Change-Id: I2acc5605bb54366700f1c05f4b856b96b1f82d70
Tomasz Swierczek [Mon, 8 May 2023 09:20:18 +0000 (11:20 +0200)]
Optimize operations on file with list of Smack labels
There's no need to call DB and tz-platform-config for each
label of given user; it makes sense to re-use the fact
that update is called always on update/install/uninstall of precisely
specified package, so changes only affect labels of that package,
be it removal or addition to the set.
Change-Id: I88686341fc49186afe60ed9f86dbdb98c1258064
Tomasz Swierczek [Tue, 2 May 2023 06:44:53 +0000 (08:44 +0200)]
Change order of items checking during getDirectoryContents() loop
Previously, the function called fstatat() even on . and .. which
could have been not wanted by the caller to get listed/analyzed.
This change was inspired by an issue where an error happened during
call to prepare_app() - error happened on calling fstatat(), during
checking if threads properly dropped capabilities/changed labels;
error was in accessing ".." element inside /proc/self/task,
while the audit logged, at the same time, a Smack error of access
attempt from label User::Pkg::<ID> to System::Privileged on
proc filesystem.
While this change doesn't fix that issue on its own, it optimizes
the code.
Change-Id: I83fda49530fb32776cf6edcc364dc574a7ee08f9
Tomasz Swierczek [Wed, 22 Feb 2023 14:22:05 +0000 (15:22 +0100)]
Small fixes in unit tests
Spellcheck & another few negative tests for filesystem.
Change-Id: If905479a78f29f341487168483e2b68c13da0ee4
Tomasz Swierczek [Tue, 21 Feb 2023 09:11:54 +0000 (10:11 +0100)]
Release 1.8.0
Package versioning bump to 1.8.X as Tizen 6.5 got update
(non-fast-forward) to 1.7.14.
This release is intended for tizen and tizen_7.0 branches.
Change-Id: I0c7fe641bb210c7ccfe5bf2e5db59f943083c9f4
Tomasz Swierczek [Thu, 2 Feb 2023 06:28:39 +0000 (07:28 +0100)]
Release 1.7.13
* Fix static analysis
Change-Id: I04137e1db4e557a6b4cdc828541773a2fad9b955
Tomasz Swierczek [Thu, 26 Jan 2023 10:19:22 +0000 (11:19 +0100)]
Fix static analysis
Printing moved object is useless, even in debug logs.
The order of operation (logging vs moving) was changed.
Change-Id: I49ad49991e773ecf5ac65aa331b1cfb2bf1ad7cc
Tomasz Swierczek [Thu, 22 Dec 2022 10:30:01 +0000 (11:30 +0100)]
Release 1.7.12
* Change some logs into warnings
Change-Id: Ic77c3be5eb1b28648fecdce67ae14ebae9bac0d5
Tomasz Swierczek [Thu, 15 Dec 2022 11:54:50 +0000 (12:54 +0100)]
Change some logs into warnings
Per specific request of Visual Display Division.
Change-Id: I4e5f579dafa16aab7f7f443a9f57e15c443862b4