+ All Categories
Home > Documents > Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18...

Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18...

Date post: 12-Nov-2018
Category:
Upload: phamthien
View: 218 times
Download: 0 times
Share this document with a friend
27
systemd integration and user management José Bollo [email protected]
Transcript
Page 1: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

systemd integration and

user management

José [email protected]

Page 2: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 2

Overview of applications

Security Context Z

Security Context A

User Interface

Binder

Effective API

Binder

local API

Tra

nsp

ort

Lay

er

Security Context S

Binder

Effective API

NETWORK

Other ECU or Cloud

Same ECU

Shadow API

Page 3: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 3

Setting the security context

Launcher Launcher clone1. fork

Launcher clonewith targeted

security context

applicationin its

security context

Launcher clonewith targeted

security context

2. prepare security context

3. drop privileges

4.exec

Page 4: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 4

Launcher and launching

● The launcher set the setting security context of applications that it launches

● Before, integration with systemd, the daemon afm-user-daemon (privileged) prepared the security environment of the forked process before to launch it for real. It performed the following actions:– Set supplementary groups

– Set smack label

– Drop capabilities

Done in fact using the client library of the security-manager of Tizen 3

Page 5: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 5

Issues with afm-user-daemon launching

● afm-user-daemon had to be privileged● afm-user-daemon was NOT managing:

– Autostart of services

– Dependency of applications to services

– Ressource management using cgroups

– Namespace containerization

– Setting environment of a different user

But systemd does!

Page 6: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 6

Benefits of using systemd

● Removal of one privileged process: afm-user-daemon● Access and use of high level features:

– Socket activation

– Management of users and integration of PAM

– Dependency resolution to services

– Cgroups and resource control

– Namespaces containerization

– Autostart of required API

– Permissions and security settings

– Network management

– …

Page 7: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 7

Design philosophy

KEEP IT SIMPLEand Flying

Page 8: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 8

History of the framework

Tizen 3

Ostro

AGL

June 2

015

Marc

h 2015

Nov. 2

015

First tizen 3 security

release

AGL spec 1.0 may 28th

Dec. 2016

Integration to AGL

Start of refiting the framework

Introduction of the binder

synchronization

Marc

h 2017

Oct

. 2017

Integration to systemD

Integration to systemD with users

Page 9: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 9

Integration with systemd in AGL

● Charming chinook:– Privileged afm-user-daemon+security-manager as launcher

● Daring dab:– Unprivileged afm-user-daemon leverages systemd --user to

launch applications

– Works only for user root ☹● Electric Eel (featuring EE RC3):

– No need of afm-user-daemon (emulated for compatibility during transition)

– Half privileged afm-system-daemon leverages systemd –system (pid1) to launch applications (and services) for system and for any user

Page 10: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 10

Workflow

Page 11: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 11

Packaged applications (widgets)

signed content

WGTWGT

packaged content

config.xml

Page 12: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 12

afb-daemon

Figure of the framework

afm-system-daemon

WGT

WGT

Security Context

Bindings

application

DB of apps=

Widget’s files + systemd units

cryptographiclayered

permissions

WGT

systemd

Page 13: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 13

config.xml

Generation of systemd units

/etc/afm/afm-unit.conf

WGT

WGT

json

Mustacheengine

Unitsdescription

*.service *.socket ...

If permissionvalidated

temporarydata

Unit installer

Page 14: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 14

Internal widget config

<feature name="urn:AGL:widget:required-permission"> <param name="urn:AGL:permission:real-time" value="required" /> <param name="urn:AGL:permission:syscall:*" value="required" /> </feature>

"required-permission":{ "urn:AGL:permission:real-time":{ "name":"urn:AGL:permission:real-time", "value":"required" }, "urn:AGL:permission:syscall:*":{ "name":"urn:AGL:permission:syscall:*", "value":"required" }}

EXTRACT OF CONFIG.XML

INTERNAL JSON

Internal transformduring installation

Page 15: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 15

Mustache templating

Hello {{name}}You have just won {{value}} dollars!{{#in_ca}}Well, {{taxed_value}} dollars, after taxes.{{/in_ca}}

Hello ChrisYou have just won 10000 dollars!Well, 6000.0 dollars, after taxes.

{ "name": "Chris", "value": 10000, "taxed_value": 10000 - (10000 * 0.4), "in_ca": true}

TEMPLATE DATA

PRODUCT

Details: https://mustache.github.io/https://gitlab.com/jobol/mustach

Page 16: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 16

Example of afm-unit.conf

[Service]SmackProcessLabel=User::App::{{:id}}User=%i

CapabilityBoundingSet=AmbientCapabilities=

Slice=user-unlimited-%i.slice

{{#required-permission}} {{#urn:AGL:permission::public:display}} SupplementaryGroups=display {{/urn:AGL:permission::public:display}}{{/required-permission}}

Conditionnal group

UID of the useris the parameter

Setting of SMACK

Page 17: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 17

Demo

Page 18: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 18

Security Context

afb-daemon

Transition mode

afm-system-daemon

Bindings

application

systemd

afm-user-daemon(legacy)

dbus

ws-client ws-client

USER LAND

SYSTEM LAND

afm-util

Page 19: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 19

Managing resources

Page 20: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 20

Possible resource control using slice

{{#required-permission}} {{#urn:AGL:permission::platform:unlimited}} Slice=user-unlimited-%i.slice {{/urn:AGL:permission::platform:unlimited}} {{^urn:AGL:permission::platform:unlimited}} Slice=user-limited-%i.slice {{/urn:AGL:permission::platform:unlimited}}{{/required-permission}}

Page 21: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 21

Possible container isolation

{{#required-permission}} {{^urn:AGL:permission::platform:not-sandboxed}} ReadOnlyPaths=/ InaccessiblePaths=/home ReadWritePaths=/run/user/%i /home/%i /dev PrivateTmp=yes {{/urn:AGL:permission::platform:not-sandboxed}}{{/required-permission}}

(we can also consider use of systemd-nspawn)

Page 22: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 22

Dealing with users

Page 23: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 23

User identity handling

● Default users exist: agl-driver and agl-passenger

● Existing several ways of authenticating users– Key RF

– Phone

– Gesture

– ...

● Provide dynamic allocation of uids for authenticated users● Use uids to ensure privacy of users and Smack for privacy of

applications● Link identity with the Oauth2 service to allow federation

Page 24: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 24

Identity workflow

PAM activation

✔ Plugable Authentication Module✔ Standard✔ Highly configurable✔ Modular design

✔ Face recognition✔ Voice identification✔ Password

1. initiate authentication

2. start user session

User identity service

USER SESSION

Cloudidentity

User services

User applications3. sync

Page 25: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 25

Identity service

User identity service

USER SESSION

Cloudidentity

User services

User applications

Userdata

● Manage user data● By application● Globally

● Manage synchronisation and caching● Provide OpenId negociation

Page 26: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 26

Launching application

USER SESSION

afm-system-daemon systemd

Home screen User applications

UID of the clientis the parameter

Page 27: Integration of systemd - iot.bzhiot.bzh/download/public/2017/AMM-Dresden/AGL-systemd.pdf · 18 October 2017 AGL AMM, Dresden, systemd integration 2 Overview of applications Security

18 October 2017 AGL AMM, Dresden, systemd integration 27

Questions

Available in meta-agl branch sandbox/jobol/sds


Recommended