platform/core/security/security-manager.git
4 years agoAdd privilege-Smack mapping 62/224862/13
Zofia Grzelewska [Wed, 12 Feb 2020 17:50:21 +0000 (18:50 +0100)]
Add privilege-Smack mapping

Add privilege-Smack mapping configuration:
* privilege-smack.list which describes privilege mapping
  to Smack label and Smack rules template
* priv-rules-default-template.smack which is an example
  of Smack rules template for privilege
* this implementation currently only applies policy on
  application launch (no runtime policy changes modify it)
and draft implementation.

IMPORTANT: This mechanism can be used, when *only one* user
           is used on Tizen.

Change-Id: Iafc999793e6fe465279d0e63ca087ae6b836181a

4 years agoFix security-manager worker 69/168869/8
Dariusz Michaluk [Tue, 14 Apr 2020 13:09:35 +0000 (15:09 +0200)]
Fix security-manager worker

Move worker process to main mount namespace after finishing job.

Change-Id: Ic0ed8011ecc8fab04a237c6a96190f4a8cc5d266

4 years agoRelease 0.5.22 43/230543/2 accepted/tizen/unified/20200413.130917 submit/tizen/20200410.113048
Tomasz Swierczek [Fri, 10 Apr 2020 10:43:39 +0000 (12:43 +0200)]
Release 0.5.22

* Make prepare_app more robust with respect to thread termination
* Fix ignoring ENOENT
* CheckProperDrop class unit tests
* Add new core privilege: notification.admin
* Do not ignore EACCES (and other errors) while getting threads info
* Unify path generation
* Add single manifest file for each RPM package

Change-Id: I3ba0fcd56821fa453947e3efa3543d5babcc56a5

4 years agoMake prepare_app more robust with respect to thread termination 80/230380/5
Konrad Lipinski [Thu, 9 Apr 2020 14:19:08 +0000 (16:19 +0200)]
Make prepare_app more robust with respect to thread termination

Since CheckProperDrop now silently ignores ENOENT when reading thread
proc entries, security_manager_sync_threads_internal should strive to do
the same when signalling threads via tgkill. This will not, of course,
eliminate race conditions - the entire thing is inherently racy.

Bonus:
* prepare_app contract prohibits concurrent thread creation/termination
* per HQ request, EACCES readproc log now suggests a possible race
  condition in the caller

Change-Id: Icf5d3e732540c4832d47e3e80f1592dab6f3ce35

4 years agoFix ignoring ENOENT 04/230204/6
Lukasz Pawelczyk [Wed, 8 Apr 2020 10:55:23 +0000 (12:55 +0200)]
Fix ignoring ENOENT

Also better error logging for check-proper-drop

Change-Id: I42bfff586d3a5d14a39ffbe16a8dfddea720d085

4 years agoCheckProperDrop class unit tests 10/228210/16
Lukasz Pawelczyk [Thu, 19 Mar 2020 15:54:04 +0000 (16:54 +0100)]
CheckProperDrop class unit tests

Change-Id: I1c867a319a5c14cf5ba67eb502e85505d00291c5

4 years agoAdd new core privilege: notification.admin 76/229976/1
Yunjin Lee [Tue, 7 Apr 2020 03:59:23 +0000 (12:59 +0900)]
Add new core privilege: notification.admin

- notification.admin: Application with this privilege can manage
notifications. For example, the app can get all notificaitons and
update, delete or hide them.

Change-Id: I4fc3c500f7f84f95dd443ebfde4b953a175112ad
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
4 years agoDo not ignore EACCES (and other errors) while getting threads info 40/226940/4
Lukasz Pawelczyk [Thu, 5 Mar 2020 16:22:29 +0000 (17:22 +0100)]
Do not ignore EACCES (and other errors) while getting threads info

Unfortunately procps-ng library ignores errors while reading thread
info and will silently go to the next thread in case of an error.

Reimplement readtask() with error checking.

Change-Id: Ibfa5ce72eedddec8ea0b2a2330ce679c94a2592f

4 years agoUnify path generation 73/226973/4
Zofia Grzelewska [Thu, 5 Mar 2020 17:47:56 +0000 (18:47 +0100)]
Unify path generation

Change-Id: I9baaf7bf66faa9176919d46b3ddd0b2a54dbcea8

4 years agoAdd single manifest file for each RPM package 34/228134/2
Tomasz Swierczek [Thu, 19 Mar 2020 07:48:18 +0000 (08:48 +0100)]
Add single manifest file for each RPM package

Change-Id: I625369d432a8251a80b456d659f483a074a2326d

4 years agoRelease 1.5.21 82/226282/1 accepted/tizen/unified/20200302.042005 submit/tizen/20200228.133513
Tomasz Swierczek [Fri, 28 Feb 2020 13:31:12 +0000 (14:31 +0100)]
Release 1.5.21

* Indicate tgkill failure in error log with errno
* Fix static analysis issues

Change-Id: Ic2de53c56c8fe1226cfd5ad318503a1264a1baf2

4 years agoIndicate tgkill failure in error log with errno 71/226171/2
Tomasz Swierczek [Thu, 27 Feb 2020 08:38:21 +0000 (09:38 +0100)]
Indicate tgkill failure in error log with errno

Change-Id: Ief80fdf01064dabbed57be2816fcfd792f03542a

4 years agoFix static analysis issues 38/226038/5
Tomasz Swierczek [Wed, 26 Feb 2020 07:57:20 +0000 (08:57 +0100)]
Fix static analysis issues

Change-Id: I202fff30f54d5ebab946f73d4e8fa827b49b3e35

4 years agoRelease 1.5.20 57/224157/1 accepted/tizen/unified/20200207.122346 submit/tizen/20200206.161502
Konrad Lipinski [Thu, 6 Feb 2020 15:55:47 +0000 (16:55 +0100)]
Release 1.5.20

* Fix app_update not setting sharedRO to false in db
* Refactor ServiceThread
* Reintroduce checks for directory existance in sharedRO setup

Change-Id: I2078b91fa5d5518440f5d92d82d3ea0f6389bfde

4 years agoFix app_update not setting sharedRO to false in db 40/224140/3
Konrad Lipinski [Thu, 6 Feb 2020 13:15:17 +0000 (14:15 +0100)]
Fix app_update not setting sharedRO to false in db

Change-Id: I502a00b4946ba3ef3c82c81f665e10c1b50d2e2b

4 years agoRefactor ServiceThread 44/222844/6
Konrad Lipinski [Mon, 20 Jan 2020 16:05:25 +0000 (17:05 +0100)]
Refactor ServiceThread

* avoid runtime member ptr indirection and storage
* retrieve Service via CRTP instead of storing it
* make ServiceThread a concrete class

Change-Id: I871602912ca7eb4ec9c4144fc104949931a60fc4

4 years agoReintroduce checks for directory existance in sharedRO setup 90/223990/3
Tomasz Swierczek [Wed, 5 Feb 2020 09:13:45 +0000 (10:13 +0100)]
Reintroduce checks for directory existance in sharedRO setup

While directories connected with per-app sharedRO should exist
if an application package has been declared to use the feature,
previous behaviour of security-manager allowed these dirs
to be nonexistent while still silently ignoring the misconfiguration
(pre-1.5.18 versions).

On already released product images, some apps, improperly installed
by installer as using sharedRO and NOT having actual folder structure,
could be already running in the wilderness. Update to new
security-manager, while true to original sharedRO-bind-mount design
(dirs SHOULD exist as designed), may introduce runtime errors.

This patch reintroduces existance checks for directories which are
arguments to bind mounts.

Alternative to this patch would be a migration script that would be much more
complicated and should be accompanied with security-manager commandline tool
used to update DB contents OR appfw script that would re-do the directory
structure. Both ways would be much more time-consuming & error prone
than reintroducing these checks, which I'm doing in this patch.

Change-Id: I9f25a85ae87e4189b81621f1ec3863a2d1cc9d2a

4 years agoRelease 1.5.19 19/223719/1 accepted/tizen/5.5/unified/20200326.232322 accepted/tizen/unified/20200204.125818 submit/tizen/20200203.111649 submit/tizen_5.5/20200325.102441
Tomasz Swierczek [Mon, 3 Feb 2020 08:02:35 +0000 (09:02 +0100)]
Release 1.5.19

* Remove nss plugin IPC with security-manager daemon
* Fix Svace defect, remove unreachable statement.
* Refactor macro usage within CheckProperDrop::checkThreads()

Change-Id: I9f36e37e2448791ef761b86a6efd9c64c521217a

4 years agoRemove nss plugin IPC with security-manager daemon 99/222099/14
Tomasz Swierczek [Thu, 9 Jan 2020 13:29:43 +0000 (14:29 +0100)]
Remove nss plugin IPC with security-manager daemon

Communication was needed to ensure the GID list is calculated based on
Cynara's privilege DB, which contains also per-user information of allowed
privileges.

It was agreed among security and platform teams that system daemons
have statically defined list of GIDs/privileges that doesn't change
over time and also, that this list is the same regardless of the user type
(gumd defines various user types).

This patch changes meaning of per-user-type policy files and Cynara's
per-user-type policy buckets. From now on, the Cynara policy for given user
is applicable as-is only for that user's applications. The user-level
& system-level daemons that may run with "User", "System" or "System::Privileged"
Smack labels have no longer their policy consulted with Cynara.
Instead, they are being given all the privilege-mapped GIDs, with exception
of GIDs that can be mapped to:

http://tizen.org/privilege/internal/livecoredump (priv_livecoredump)
http://tizen.org/privilege/internal/sysadmin (currently no GID associated)

These privileges are used by system team to control inter-service
access to certain DBus interfaces and if any GID is associated with them,
that GID should not be granted by nss plugin. Instead, that GID should
be added as supplementary group of particular service that should be granted
corresponding privilege (ie. using systemd service file or by assigning GID
as supplementary to UID under which the service is running).

When systemd SupplementaryGroup option in service files will be used
to declare all  "privileges" for all services, the security-manager nss plugin
will not be needed anymore.

Change-Id: I8da6385cfaf502cfd6117b3805e5986ae3c28b80

4 years agoFix Svace defect, remove unreachable statement. 30/223430/3
Dariusz Michaluk [Wed, 29 Jan 2020 16:47:48 +0000 (17:47 +0100)]
Fix Svace defect, remove unreachable statement.

Change-Id: I0bd14456de4e8b54e1753dfa8be2cf8d0b1b5217

4 years agoRefactor macro usage within CheckProperDrop::checkThreads() 37/220737/2
Konrad Lipinski [Thu, 19 Dec 2019 14:44:33 +0000 (15:44 +0100)]
Refactor macro usage within CheckProperDrop::checkThreads()

Change-Id: Iadef9bacd076a666d8a527e79165b01cf2daf544

4 years agoRelease 1.5.18 37/223137/1 accepted/tizen/5.5/unified/20200312.234628 accepted/tizen/unified/20200129.022634 submit/tizen/20200123.073443 submit/tizen_5.5/20200311.033315 submit/tizen_5.5_tv/20200311.054720
Tomasz Swierczek [Thu, 23 Jan 2020 07:04:14 +0000 (08:04 +0100)]
Release 1.5.18

* prepare_app optimization

Change-Id: Ie25de8f2cd3c345769267b15efe6e02a840a0ed6

4 years agodb: drop redundant IsPackageSharedRO query 13/222513/6
Konrad Lipinski [Thu, 19 Dec 2019 14:44:33 +0000 (15:44 +0100)]
db: drop redundant IsPackageSharedRO query

Change-Id: I90273f0f48290930c275685480627701e83bbc2a

4 years agoprepare_app: refactor supplementary group assignment 12/222512/7
Konrad Lipinski [Thu, 19 Dec 2019 14:44:33 +0000 (15:44 +0100)]
prepare_app: refactor supplementary group assignment

* use a stack array for syscalls
* stream forbiddenGroups = privilegedGroups \ allowedGroups instead of
  privilegedGroups, making IPC thinner

Change-Id: I343af0052fd90f1ed4fd37d41b7b8c7a1a5a7858

4 years agoprepare_app: coalesce all client->mgr IPCs into one 11/222511/6
Konrad Lipinski [Thu, 19 Dec 2019 14:44:33 +0000 (15:44 +0100)]
prepare_app: coalesce all client->mgr IPCs into one

Change-Id: I28398b36b9a14fd4e4d30570f15848a8f29c5ef1

4 years agoMake prepare_app_candidate faster 09/222509/5
Konrad Lipinski [Wed, 15 Jan 2020 17:32:10 +0000 (18:32 +0100)]
Make prepare_app_candidate faster

Change-Id: Ie875ff190aa032cbaa21e7ef9b72da98faf3b8b4

4 years agoprepare_app: optimize setupSharedRO 08/222508/4
Konrad Lipinski [Wed, 15 Jan 2020 17:19:36 +0000 (18:19 +0100)]
prepare_app: optimize setupSharedRO

Change-Id: Ifb52a67a09122847c2241db3c86bf8c15bc69438

4 years agoprepare_app: simplify thread syncing 07/222507/6
Konrad Lipinski [Wed, 15 Jan 2020 15:44:43 +0000 (16:44 +0100)]
prepare_app: simplify thread syncing

Change-Id: If78f4688d71213f06c525462cedb9d259f8d406b

4 years agoprepare_app: return errcode on CheckProperDrop failure 37/222837/3
Konrad Lipinski [Mon, 20 Jan 2020 12:16:09 +0000 (13:16 +0100)]
prepare_app: return errcode on CheckProperDrop failure

Change-Id: I3a8953650c1dcee4d2cbe6b4171cd2bb3e84993e

4 years agoThrow exception on failed config file read 47/222947/3
Konrad Lipinski [Tue, 21 Jan 2020 11:00:47 +0000 (12:00 +0100)]
Throw exception on failed config file read

Change-Id: I8b19bd1863f1df84ef3e10548be644e9632dcb5c

4 years agoDon't copy socket events 92/220592/3
Zofia Grzelewska [Thu, 19 Dec 2019 16:59:51 +0000 (17:59 +0100)]
Don't copy socket events

Change-Id: If103f7800e202bbd6e27b472668ea7feba7dbf38

4 years agoDrop intermediate istringstream in ConfigFile::read() 04/222504/2
Konrad Lipinski [Wed, 15 Jan 2020 14:58:22 +0000 (15:58 +0100)]
Drop intermediate istringstream in ConfigFile::read()

Change-Id: Ib6a2017a39fb20576eccc766e289eaae8de65098

4 years agoDrop useless cap_clear() following cap_init() 06/222506/3
Konrad Lipinski [Wed, 15 Jan 2020 15:28:27 +0000 (16:28 +0100)]
Drop useless cap_clear() following cap_init()

"The initial value of all flags are cleared." (https://linux.die.net/man/3/cap_init)

Change-Id: I6f55acaf0676daca3befe3b37fb249902c59e91e

4 years agoNanoooptimize mount-namespace.cpp 10/222510/2
Konrad Lipinski [Wed, 15 Jan 2020 17:53:30 +0000 (18:53 +0100)]
Nanoooptimize mount-namespace.cpp

Change-Id: I8fce33fce888cff5f5bea416099346b36004ff30

4 years agoRelease 1.5.17 92/222692/1 accepted/tizen/unified/20200117.075031 submit/tizen/20200117.074218
Tomasz Swierczek [Fri, 17 Jan 2020 07:40:47 +0000 (08:40 +0100)]
Release 1.5.17

* Add even more gcc 9 fixes after Wall enabling

Change-Id: Iec7c4a8acd9a605364dbdd217a1e83fc6993d740

4 years agoAdd even more gcc 9 fixes after Wall enabling 94/222494/2
Tomasz Swierczek [Wed, 15 Jan 2020 09:46:03 +0000 (10:46 +0100)]
Add even more gcc 9 fixes after Wall enabling

Needed to disable -Wcast-function-type for service-thread.h file only.
service-thread.h will require some fundamental rework later.

Change-Id: If9d13dfe8e3ae78ac658a140e9582130e98e2b6a

4 years agoRelease 1.5.16 accepted/tizen/unified/20200113.130714 submit/tizen/20200109.083615
Tomasz Swierczek [Thu, 9 Jan 2020 08:35:42 +0000 (09:35 +0100)]
Release 1.5.16

* Fix build for gcc 9
* Revert "Mark colour_log_formatter methods as override"

Change-Id: If053989e9f7aa8c4e9474483a3f0849c7f5fe5e3

4 years agoFix build for gcc 9 03/221903/2
Tomasz Swierczek [Wed, 8 Jan 2020 07:37:40 +0000 (08:37 +0100)]
Fix build for gcc 9

Change-Id: Iba39f4a644d5f676e8f1606bbc283efe97f2dd9c

4 years agoRevert "Mark colour_log_formatter methods as override" 67/220767/1 accepted/tizen/5.5/unified/20200105.221111 submit/tizen_5.5/20200103.003447
Tomasz Swierczek [Mon, 23 Dec 2019 05:58:53 +0000 (06:58 +0100)]
Revert "Mark colour_log_formatter methods as override"

This reverts commit 31bba785d8f2c84207f68e862751ec5fc421c2c5.

With older versions of boost, build-time errors occur with this patch
(marked 'override', but does not override).

Change-Id: I1dff4b41703a2896de60c1dbae82536f83636c04

4 years agoRelease 1.5.15 89/220689/1 accepted/tizen/unified/20191223.060214 submit/tizen/20191220.095458 submit/tizen_5.5/20191220.095710
Dariusz Michaluk [Fri, 20 Dec 2019 08:20:42 +0000 (09:20 +0100)]
Release 1.5.15

* Remove duplicated mount namespace setup
* Skip mount namespace setup specific to privacy privileges
* Enhance few logs around application launching.
* Add http://tizen.org/privilege/internal/livecoredump and disable it for non-applications
* Add user context to fetching tzplatform_config variable
* Mark colour_log_formatter methods as override
* Make colour_log_formatter compatible w/ boost 1.70

Change-Id: Icd275c4b19043a3251336cf26a13dd8492f981c1

4 years agoRemove duplicated mount namespace setup 57/220357/2
Dariusz Michaluk [Tue, 17 Dec 2019 14:37:22 +0000 (15:37 +0100)]
Remove duplicated mount namespace setup

When security_manager_prepare_app() is called twice by multi-process app zygote
mount namespace setup is duplicated.

This solution has race condition, but inter process synchronization
adds more overhead than benefits.

Change-Id: I92b9bead82c8caf3522b483a662e7a837f67a311

4 years agoSkip mount namespace setup specific to privacy privileges 80/220480/2
Dariusz Michaluk [Tue, 17 Dec 2019 17:54:40 +0000 (18:54 +0100)]
Skip mount namespace setup specific to privacy privileges

In case of empty privacy privilege to filesystem path mapping (privilege-mount.list file)
we can skip mount namespace setup specific to privacy privileges.

Change-Id: I7f1f4ef8e5f0614d7b232529f4ff665c2dfeaf5f

4 years agoEnhance few logs around application launching. 42/220442/1
Tomasz Swierczek [Wed, 18 Dec 2019 07:19:32 +0000 (08:19 +0100)]
Enhance few logs around application launching.

It was reported that some checks during our launching could be more verbose
and informative about what is going on. Added few more sentences to clearly
state if application process is improperly setup and why.

Change-Id: I47d6578dceff957cf76aa8ee690420d5a5cc9d7f

4 years agoAdd http://tizen.org/privilege/internal/livecoredump and disable it for non-applications 08/217708/3
Karol Lewandowski [Wed, 13 Nov 2019 10:44:11 +0000 (11:44 +0100)]
Add tizen.org/privilege/internal/livecoredump and disable it for non-applications

This commit adds new privilege for triggering coredump from running (live)
process.  The coredump can contain private information so additional security
measures are needed to disallow all system services from requesting livedump
for any process.

The functionality it's supposed to be used by (verified and approved) set of
processes only.

To implement this the privilege is provided in disabled state - no system service
gets it automatically.  To use it one has to add membership to priv_livecoredump
group (or supplementary group).

Change-Id: I3c6664b3befae0a572ef263b94b39e0cec7fce04

4 years agoAdd user context to fetching tzplatform_config variable 53/219153/2
Zofia Grzelewska [Fri, 29 Nov 2019 17:39:52 +0000 (18:39 +0100)]
Add user context to fetching tzplatform_config variable

Change-Id: I45cbea2d73d5c5fd3079df6f0925a8250eb005c4

4 years agoMark colour_log_formatter methods as override 37/219837/2
Konrad Lipinski [Tue, 10 Dec 2019 14:04:37 +0000 (15:04 +0100)]
Mark colour_log_formatter methods as override

Change-Id: I321149df1a390be56bf9a3ee1bcf83b726a01dc8

4 years agoMake colour_log_formatter compatible w/ boost 1.70 35/219835/2
Konrad Lipinski [Tue, 10 Dec 2019 13:37:08 +0000 (14:37 +0100)]
Make colour_log_formatter compatible w/ boost 1.70

Change-Id: I58a52805d98b3571662cc36aec9b170272012671

4 years agoRelease 1.5.14 accepted/tizen/unified/20191201.221523 submit/tizen/20191128.101053 submit/tizen_5.5/20191204.061724 submit/tizen_5.5/20191205.065343
Tomasz Swierczek [Thu, 28 Nov 2019 10:26:12 +0000 (11:26 +0100)]
Release 1.5.14

* Add SharedRO skel path labelling when labeling any dir as SharedRO
* Add release script
* Label package base paths for SHARED_RO bind mounting
* Label SHARED_RO directory under symlink
* Add new $APP_HOME/.shared/$PKG_NAME dir to legal paths
* Implement SharedRO with mount namespace
* Remove package generated SharedRO rules

Change-Id: Iefa023963d135c29aef636d223a31419ed9115d2

4 years agoAdd SharedRO skel path labelling when labeling any dir as SharedRO 00/218700/3
Tomasz Swierczek [Wed, 27 Nov 2019 05:58:05 +0000 (06:58 +0100)]
Add SharedRO skel path labelling when labeling any dir as SharedRO

security-manager relies on specific path layout for SharedRO mount points.
This patch adds labeling of skel subdirs for given package, if these exist.

Change-Id: Id8e3b0986eff47bc628849fcc6d51fa6176cde54

4 years agoAdd release script 42/218242/1
Zofia Grzelewska [Wed, 20 Nov 2019 13:04:25 +0000 (14:04 +0100)]
Add release script

Change-Id: I199a2333c989bed23a8eee47a5ba9b645363fd2d

4 years agoLabel package base paths for SHARED_RO bind mounting 89/217589/3
Zofia Grzelewska [Tue, 12 Nov 2019 14:27:11 +0000 (15:27 +0100)]
Label package base paths for SHARED_RO bind mounting

Label $APP_HOME/.shared/$PKG_NAME and $APP_HOME/.shared/$PKG_NAME
paths with "User::Home" to allow bind mount in application context.

Change-Id: Ib19de4e87766f5a313f1e5e0542e1da8b30f8a40

4 years agoLabel SHARED_RO directory under symlink 25/217125/3
Zofia Grzelewska [Mon, 4 Nov 2019 16:41:27 +0000 (17:41 +0100)]
Label SHARED_RO directory under symlink

SharedRO directories from previous implementation
are now symlinks pointing to new SharedRO directories.
This commits assures, that all contents under this symlink
are properly labeled.

Change-Id: I672aaf38ffca3ed6608d9c0aaa2ad7253df16349

4 years agoAdd new $APP_HOME/.shared/$PKG_NAME dir to legal paths 37/215937/4
Zofia Grzelewska [Thu, 10 Oct 2019 15:34:34 +0000 (17:34 +0200)]
Add new $APP_HOME/.shared/$PKG_NAME dir to legal paths

Add new SharedRO directory for bind mount implementation
of SharedRO.

Change-Id: Ie8dc40234b2cbdef7cb788e8883ef9508abb59bf

4 years agoImplement SharedRO with mount namespace 38/207538/11
Dariusz Michaluk [Wed, 29 May 2019 14:35:21 +0000 (16:35 +0200)]
Implement SharedRO with mount namespace

Perform three bind mounts to implement SharedRO
policy.

Change-Id: Ib30cf1537bdb1357ef53b77ead52a00b469566d1

4 years agoRemove package generated SharedRO rules 36/207536/10
Dariusz Michaluk [Wed, 29 May 2019 11:18:40 +0000 (13:18 +0200)]
Remove package generated SharedRO rules

Remove SharedRO rules and labels generated from
package name and replace them with "User::App::Shared".

Change-Id: I8d164be27e1d91dbf8787906a4aa083a63b4a1b7

4 years agoRelease 1.5.13 accepted/tizen/unified/20191113.123435 submit/tizen/20191113.053610
Tomasz Swierczek [Wed, 13 Nov 2019 05:34:45 +0000 (06:34 +0100)]
Release 1.5.13

* Add fsync after DB recovery.

Change-Id: I0dab12f010f35af2c32ec949a83a06202ded5ad8

4 years agoAdd fsync after DB recovery. 74/217074/2
jin-gyu.kim [Wed, 6 Nov 2019 05:42:21 +0000 (14:42 +0900)]
Add fsync after DB recovery.

To ensure the safety of the file, add fsync in security-manager-rules-loader.

Change-Id: I7de479c92f090d20d4f32d1147e803111eab85cd

4 years agoRelease 1.5.12 90/215590/2 accepted/tizen_5.5_unified_mobile_hotfix tizen_5.5_mobile_hotfix accepted/tizen/5.5/unified/20191031.022318 accepted/tizen/5.5/unified/mobile/hotfix/20201027.090144 accepted/tizen/unified/20191017.011721 accepted/tizen/unified/20191017.114033 submit/tizen/20191015.050025 submit/tizen/20191015.081321 submit/tizen_5.5/20191031.000004 submit/tizen_5.5_mobile_hotfix/20201026.185104 tizen_5.5.m2_release
Yunjin Lee [Fri, 11 Oct 2019 07:31:17 +0000 (16:31 +0900)]
Release 1.5.12

* Add core privileges: securesysteminfo and voicecontrol.tts

Change-Id: Ib0c157382df418323a0a2c2ff4d5263baa68d5a3
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
4 years agoAdd core privileges: securesysteminfo and voicecontrol.tts 87/215587/2
Yunjin Lee [Fri, 11 Oct 2019 05:51:52 +0000 (14:51 +0900)]
Add core privileges: securesysteminfo and voicecontrol.tts

- securesysteminfo: This privilege allows app to read non-resettable
secure deivce information such as IMEI.

- voicecontrol.tts: This privilege allows app to request voice control
engine to synthesize text to speech using its own voice.

Change-Id: I8eb1c6bb38efe07cf4d8b3262e81b4279a6b2ea9
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
5 years agoAdd core privileges: securesysteminfo and voicecontrol.tts
Yunjin Lee [Fri, 11 Oct 2019 05:51:52 +0000 (14:51 +0900)]
Add core privileges: securesysteminfo and voicecontrol.tts

- securesysteminfo: This privilege allows app to read non-resettable
secure deivce information such as IMEI.

- voicecontrol.tts: This privilege allows app to request voice control
engine to systhesize text to speech using its own voice.

Change-Id: I8eb1c6bb38efe07cf4d8b3262e81b4279a6b2ea9
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
5 years agoRelease 1.5.11 85/215485/1 accepted/tizen/unified/20191011.015409 submit/tizen/20191009.143649
Krzysztof Jackiewicz [Wed, 9 Oct 2019 08:55:09 +0000 (10:55 +0200)]
Release 1.5.11

* Do not fail NS worker action if mount point doesn't exist
* Refactor service_impl.cpp

Change-Id: If8a0fd4ef2c4669da6087fcafc136ee19a74cd50

5 years agoDo not fail NS worker action if mount point doesn't exist 00/215100/2
Tomasz Swierczek [Tue, 1 Oct 2019 11:05:53 +0000 (13:05 +0200)]
Do not fail NS worker action if mount point doesn't exist

This mimics actions taken at app launch, where privileges
defined for nonexisting mount points are not causing
the launch to be failed.

Change-Id: I4e8f14452d379ee86efc31412aa940a4aa67b463

5 years agoRefactor service_impl.cpp 96/214496/2
Tomasz Swierczek [Mon, 23 Sep 2019 08:30:48 +0000 (10:30 +0200)]
Refactor service_impl.cpp

Moved static functions to separate file in SecurityManager namespace.
This should improve module's SAM score.

Change-Id: I33eb34068072d1c52f3331ea8b8ca667657fef21

5 years agoRelease 1.5.10 24/213224/1 accepted/tizen/unified/20190904.011515 submit/tizen/20190903.051704
Tomasz Swierczek [Tue, 3 Sep 2019 04:43:03 +0000 (06:43 +0200)]
Release 1.5.10

* Disable http://tizen.org/privilege/internal/sysadmin for non-applications

Change-Id: I274bdbac2b70a970f11d8f20c3aa2b0b70bb8ac9

5 years agoDisable http://tizen.org/privilege/internal/sysadmin for non-applications 42/212942/2
Tomasz Swierczek [Wed, 28 Aug 2019 09:14:15 +0000 (11:14 +0200)]
Disable tizen.org/privilege/internal/sysadmin for non-applications

By default, system (&user-session) services were granted access to all privileges.
As we work towards fine-grained access control for system services, we need
to disable granting all privileges for services.

This 1st experimental step disables the sysadmin privilege, to be used
to control access to activationd daemon.

For internal applications, sysadmin privilege will be used in manifests, so
Cynara will be able to find exact match for applications' Smack label
in its manifest bucket; for policy evaluation to return success in such case,
all is needed is addition of this new privilege to user-types whitelists
(*.profile files).

For system services, access control to activationd will be limited
to list of user-IDs listed in DBus policy, hence the privilege can't
be automatically enabled for processes with labels User, System & System::Privileged.

For user-session services, this privilege will not be used at the moment.

The (possible) target solution for providing per-service access control
can be based on supplementary groups defined in systemd service files
(or applied as a conequence of cynara policy by security-manager nss plugin).

However, using supplementary groups with DBus policy is not possible at the moment
as both: kernel and DBus will have to be patched to use SO_PEERGROUPS (1)

(1) : https://www.spinics.net/lists/netdev/msg441568.html

Change-Id: Ie41a60d67d39c49b1ed6a49e0c17b9e5d2dabd86

5 years agoRelease 1.5.9 71/212571/3 accepted/tizen/unified/20190828.011043 submit/tizen/20190826.095036
Tomasz Swierczek [Fri, 23 Aug 2019 06:08:40 +0000 (08:08 +0200)]
Release 1.5.9

* Fix for synchronization of per-thread mount namespace setup
* Add check for proper synchronization of threads namespaces
* Fix licence comments in source code files

Change-Id: Iaf0352154b51ef33980f5a100d1891105cc4eb2e

5 years agoFix for synchronization of per-thread mount namespace setup 99/212399/7
Tomasz Swierczek [Wed, 21 Aug 2019 06:48:15 +0000 (08:48 +0200)]
Fix for synchronization of per-thread mount namespace setup

According to manual (1):

A process may not be reassociated with a new mount namespace
if it is multithreaded.

Also, unshare system call (2) is only creating new namespace
for the caller thread. This means that application candidate
processes that have more than 1 thread are doomed to always have
some threads still in the main mount namespace, without
enforcement of privilege policy connected to mount namespaces.
This renders the mount-namespace-based access control a bad solution.

This patch introduces a special API call to be used by app launchers
just to prepare app candidate processes. This API call doesn't take
any arguments - it just checks if mount-namespaces are enabled
and if yes, just calls unshare(), checking beforehand if the process
has only one thread.

(1) : http://man7.org/linux/man-pages/man2/setns.2.html
(2) : http://man7.org/linux/man-pages/man1/unshare.1.html

Change-Id: I82aefca3d5eb4915041df99ff0313896cbc769cb

5 years agoAdd check for proper synchronization of threads namespaces 04/212504/5
Tomasz Swierczek [Thu, 22 Aug 2019 06:24:14 +0000 (08:24 +0200)]
Add check for proper synchronization of threads namespaces

Change-Id: I743d755c2b7cf24bc0542c1e9e964f3c863aeb02

5 years agoFix licence comments in source code files 32/211132/1
Tomasz Swierczek [Tue, 30 Jul 2019 08:13:32 +0000 (10:13 +0200)]
Fix licence comments in source code files

Change-Id: I24556d7a2fa49091e6f7b0888fe2cad4992f562f

5 years agoRelease 1.5.8 93/210093/1 accepted/tizen/unified/20190725.042914 submit/tizen/20190715.152548 submit/tizen/20190718.095643 submit/tizen/20190722.094000 submit/tizen/20190724.083637
Dariusz Michaluk [Mon, 15 Jul 2019 15:16:08 +0000 (17:16 +0200)]
Release 1.5.8

* Prevent starting service without the socket
* Make GetErrnoString not throwing
* Optimize nss plugin memory usage
* Remove unnecessary setting
* Migrate to openssl 1.1

Change-Id: Ic4043d29bcbda9da9f8304403dcd6a388af21424

5 years agoPrevent starting service without the socket 85/210085/2
Dariusz Michaluk [Mon, 15 Jul 2019 14:30:50 +0000 (16:30 +0200)]
Prevent starting service without the socket

Change-Id: I88415e55586dbe436bb44792d6808aadd5a48bc5

5 years agoMake GetErrnoString not throwing 72/209972/2
Tomasz Swierczek [Fri, 12 Jul 2019 17:01:53 +0000 (19:01 +0200)]
Make GetErrnoString not throwing

The function is already made for processing error situations,
there is no point in throwing an error inside of it.

Change-Id: I2be841a30ba36cf699907fa23bbf4d0ffe85b2ea

5 years agoOptimize nss plugin memory usage 88/209388/12
Tomasz Swierczek [Fri, 5 Jul 2019 05:21:11 +0000 (07:21 +0200)]
Optimize nss plugin memory usage

Made the nss module not linked with commons or client library.
Using security-manager client library in nss module caused
additional memory usage by private data in each loaded libaries
out of which most were not needed for nss (smack, pcap, procps, rt,
sqlite, cynara-*, security-privilege-manager, mount, crypt, blkid,
pkgmgr_parser, vconf, minizip, pcre, uuid, xml2, gio, z, buxton2,
lzma, gmodule, resolv, ffi, tzplatformconfig, dlog).

Linking with dlog & tzplatformconfig left only in debug mode.

To test it, use "gdb id", break point on getgrgid, measure change of PSS after
finishing the function execution with vs. without the patch.

The PSS value of id process should go down by approx. 0.4 - 0.5 MB
(depending on the system load & number of processes).

Change-Id: If2cede89885320ea83ca79fd54770a7ea24d87d8

5 years agoRemove unnecessary setting 80/209580/1
INSUN PYO [Tue, 9 Jul 2019 05:04:24 +0000 (14:04 +0900)]
Remove unnecessary setting

Change-Id: I695a16bf83a7292422369490dda1e62a8ca30691

5 years agoMigrate to openssl 1.1 88/206888/2
Konrad Lipinski [Tue, 28 May 2019 13:20:14 +0000 (15:20 +0200)]
Migrate to openssl 1.1

Change-Id: Ied1db6cd18d336fa8a6b9aebd402b1f4eead30d3

5 years agoRelease 1.5.7 accepted/tizen/unified/20190612.111715 submit/tizen/20190611.044719
Tomasz Swierczek [Tue, 11 Jun 2019 04:46:29 +0000 (06:46 +0200)]
Release 1.5.7

* Add additional check for threads supgid pointers
* Add logging of server-side operation handling time

Change-Id: I0f62ddaaefac6af7e754a0f6f7161ae584196832

5 years agoAdd additional check for threads supgid pointers 46/207646/2
Tomasz Swierczek [Mon, 10 Jun 2019 10:18:51 +0000 (12:18 +0200)]
Add additional check for threads supgid pointers

According to implementation of readtask (proc/readproc.c),
the pointers could be NULL in specific implementations.

Change-Id: If1e8308c517ddbfbd500f7c5822c80dd3225df0c

5 years agoAdd logging of server-side operation handling time 56/206256/7
Tomasz Swierczek [Wed, 15 May 2019 09:31:33 +0000 (11:31 +0200)]
Add logging of server-side operation handling time

Logs are added only in debug mode for each service
method that implements API exposed by the daemon.

Change-Id: I90412b9d6c32edd0d7559f5eb713117ba0a1fecd

5 years agoRelease 1.5.6 43/207543/1 submit/tizen/20190606.151034
Tomasz Swierczek [Thu, 6 Jun 2019 14:01:09 +0000 (16:01 +0200)]
Release 1.5.6

* Improve security_manager_prepare_app() performance
* Stop forcing logs from server-side write() and close() operations
* Revert "Enhance logs in case of socket problems, client hangs on waitForSocket()"
* Properly handle EINPROGRESS error from connect()

Change-Id: I02c5e576882d3f9bb713b924a7f90f7287165f96

5 years agoImprove security_manager_prepare_app() performance 51/207351/2
Dariusz Michaluk [Fri, 31 May 2019 13:10:55 +0000 (15:10 +0200)]
Improve security_manager_prepare_app() performance

This commit merges getPrivilegedGroups() and getAppGroups() into one client request.

Change-Id: I77b42773845b264794398af7995bba087320689d

5 years agoStop forcing logs from server-side write() and close() operations 33/206233/1
Tomasz Swierczek [Wed, 15 May 2019 09:13:05 +0000 (11:13 +0200)]
Stop forcing logs from server-side write() and close() operations

This reverts commit 7ad04ef8ccaebe23cc30f90f3e9ffa04b3acd698 (DEBUG ONLY ErrorLogs).
Logging sockef fd was left, but in LogDebug logs, also in CloseSocket.

Change-Id: I3582b9080de7e2368a08030d75d0df15ed81c68e

5 years agoRevert "Enhance logs in case of socket problems, client hangs on waitForSocket()" 40/206140/2
Dariusz Michaluk [Tue, 14 May 2019 14:26:27 +0000 (14:26 +0000)]
Revert "Enhance logs in case of socket problems, client hangs on waitForSocket()"

This reverts commit 3f59f6b73c66bdc4cc3fd91eaa7eef1d2abe1aa0.

Change-Id: I279ddc1a9b4213429960afd9060af049f0f4c057

5 years agoProperly handle EINPROGRESS error from connect() 39/206139/1
Krzysztof Jackiewicz [Fri, 10 May 2019 08:39:20 +0000 (10:39 +0200)]
Properly handle EINPROGRESS error from connect()

If connect() fails with EINPROGRESS, the connection may be completed
by polling/selecting the socket for writing. This commit replaces
POLLIN with POLLOUT to handle it properly.

Change-Id: If332634c6d517d7ec00f19a5970e7fe16ee9bb06
(cherry picked from commit e4adb53b99b0011037a3dfc408026cc6a40be349)

5 years agoRelease 1.5.5 46/205146/1 submit/tizen/20190430.132225
Krzysztof Jackiewicz [Mon, 29 Apr 2019 12:26:12 +0000 (14:26 +0200)]
Release 1.5.5

- Remove dbus.service.wants dependency

Change-Id: I2df523a40e4abf551bedfa9a45f78d4cc49127c9

5 years agoRemove dbus.service.wants dependency 24/204624/2
INSUN PYO [Thu, 25 Apr 2019 05:57:56 +0000 (14:57 +0900)]
Remove dbus.service.wants dependency

Change-Id: I54c7abd0158ddd993ab09982171c6994d41bc08b

5 years agoRelease 1.5.4 23/204823/1 accepted/tizen/unified/20190429.103747 submit/tizen/20190426.145014
Dariusz Michaluk [Fri, 26 Apr 2019 14:44:43 +0000 (16:44 +0200)]
Release 1.5.4

- Enhance logs in case of socket problems, client hangs on waitForSocket()
- Increase backlog for listening sockets

Change-Id: Ibf652e8bd8597d8ed1fd88fa5127cb8621af1a69

5 years agoEnhance logs in case of socket problems, client hangs on waitForSocket() 08/204808/3
Dariusz Michaluk [Fri, 26 Apr 2019 12:12:19 +0000 (14:12 +0200)]
Enhance logs in case of socket problems, client hangs on waitForSocket()

Change-Id: I30c3add6e1e21c3c28ae7a7b3b8c6e66477ea9ae

5 years agoIncrease backlog for listening sockets 09/204809/1
Dariusz Michaluk [Fri, 26 Apr 2019 12:18:41 +0000 (14:18 +0200)]
Increase backlog for listening sockets

When systemd's socket activaction is utilized, the default backlog
parameter passed to the listen() function is set to SOMAXCONN,
which is equal to 128. In distributions where systemd is not used
for socket activation, the default UNIX socket
implementation sets the backlog value to 5.
This may lead to rare overflow of an internal connection queue.
This manifests itself as the -EAGAIN error returned by connect().

To mitigate the issue, the backlog parameter has been set
to SOMAXCONN, which is a default value used by systemd.

Change-Id: I42b277d8d66c23335474fdf63db937ef22b8e171

5 years agoRelease 1.5.3 59/203459/1 accepted/tizen/unified/20190416.071449 submit/tizen/20190415.060512
Yunjin Lee [Mon, 15 Apr 2019 04:09:19 +0000 (13:09 +0900)]
Release 1.5.3

- Add core privilege: d2d.datasharing, d2d.remotelaunch

Change-Id: Iddf2b61f70c87a4e4fbe6f3ee06fe1ec0bce27e5
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
5 years agoAdd core privilege: d2d.datasharing, d2d.remotelaunch 52/203452/1
Yunjin Lee [Mon, 15 Apr 2019 02:41:59 +0000 (11:41 +0900)]
Add core privilege: d2d.datasharing, d2d.remotelaunch

- d2d.datasharing: Application with this privilege can share data with
other devices
- d2d.remotelaunch: Application with this privilege can be launched by
applications on other devices

Change-Id: I423d56309fefc64942a8f8e6fe2f755727bddae6
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
5 years agoRelease 1.5.2 84/203184/1 accepted/tizen/unified/20190411.144016 submit/tizen/20190410.103749
Dariusz Michaluk [Wed, 10 Apr 2019 10:30:28 +0000 (12:30 +0200)]
Release 1.5.2

- Add new rules-loader options

Change-Id: I9974c82d251730f12582a9db126d93cce1fa1b8e

5 years agoAdd new rules-loader options 58/202458/5
Dariusz Michaluk [Thu, 14 Mar 2019 15:46:06 +0000 (16:46 +0100)]
Add new rules-loader options

--default - write all System/User rules (subject is not a package name)
--packages - write rules for list of packages
--exclude - write rules for all packages except list of packages

Change-Id: I66b2aa55f3419df8e93709e3191963d3f8e74ee4

5 years agoRelease 1.5.1 18/200618/2 accepted/tizen/unified/20190405.015727 submit/tizen/20190329.053841 submit/tizen/20190404.021824
Yunjin Lee [Wed, 27 Feb 2019 09:45:40 +0000 (18:45 +0900)]
Release 1.5.1

- Add core privilege: windowsystem.admin
- Make waitpid(WNOHANG) call more explicit to appease SVACE

Change-Id: Ia20386770e804219c63ebbcb111f0ebc9c64075d
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
5 years agoAdd core privilege: windowsystem.admin 12/200612/2
Yunjin Lee [Wed, 27 Feb 2019 09:16:28 +0000 (18:16 +0900)]
Add core privilege: windowsystem.admin

- The application with this privilege can change the settings for
services provided by display server, such as the quick panel and softkey
bar.

Change-Id: Ic0d441a820f687d1e36cfe20e7e3ca8a485168d1
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
5 years agoMake waitpid(WNOHANG) call more explicit to appease SVACE 60/201460/1
Konrad Lipinski [Thu, 14 Mar 2019 09:44:14 +0000 (10:44 +0100)]
Make waitpid(WNOHANG) call more explicit to appease SVACE

Change-Id: I63e7bddca2a729658d9ab8da94587a1780c7d32b

5 years agoRelease 1.5.0 71/200871/4 accepted/tizen/unified/20190307.231033 submit/tizen/20190305.095610
Tomasz Swierczek [Tue, 5 Mar 2019 08:18:04 +0000 (09:18 +0100)]
Release 1.5.0

* Replace time(NULL) with monotonic clock usage
* Enhance logs in case of writing errors

This release changes numbering to differentiate older branches of code.

tizen branch will continue to use 1.5.X numbering while tizen_5.0 version
will contininue to use 1.4.X numbering (for bugfixes/maintenance).

Change-Id: I752e69c738e565de27c5097381cbb11b2ac6ad48

5 years agoReplace time(NULL) with monotonic clock usage 64/200864/4
Tomasz Swierczek [Tue, 5 Mar 2019 07:14:11 +0000 (08:14 +0100)]
Replace time(NULL) with monotonic clock usage

Calculating timeout for socket connections should
use monotonic clock.

Change-Id: Ie791173cf2663fdf0b94381f391bd5504b3e5e06

5 years agoEnhance logs in case of writing errors & socket problems 58/200858/3
Tomasz Swierczek [Tue, 5 Mar 2019 06:26:04 +0000 (07:26 +0100)]
Enhance logs in case of writing errors & socket problems

In rare case security-manager is closing connections to clients
and after that, it tries to write responses to already closed connections.

With these enhanced logs it would be possible to match if the closed connections
(already appearing in logs) are for same socket number like ignored packets.

Change-Id: Ia105c8731d64d83d8d83182e12ae8adee1b961f0

5 years agoRelease 1.4.14 78/199578/1 accepted/tizen/unified/20190214.060632 submit/tizen/20190213.072219
Tomasz Swierczek [Wed, 13 Feb 2019 06:15:11 +0000 (07:15 +0100)]
Release 1.4.14

* Force logging server-side write() and close() operations
* Add logging response buffer size in debug mode

Change-Id: I8ccbbe45a48e14c7ee43781a7a5c71242fa85c09

5 years agoForce logging server-side write() and close() operations 17/199517/4
Tomasz Swierczek [Tue, 12 Feb 2019 09:24:34 +0000 (10:24 +0100)]
Force logging server-side write() and close() operations

In some cases on TV, client gets 0 from recv while it should receive
an int with status from server. At the same time, there are no error
logs from server side and no issues with systemd service perceived.

This patch is a temporary solution to force logging relevant actions
on server side, to check whether server actually properly processes data.

Logs were added as ErrorLog to make sure these are visible during robustness
tests of TV (where platform code is synced automatically).

This patch WILL BE REVERTED after 31.03

Change-Id: I9284c42b87e49d333261a4dde7aedeae5261343c