+ All Categories
Home > Documents > Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager...

Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager...

Date post: 15-Jul-2020
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
28
https://www.pengutronix.de Safe and Secure Field Updates of Embedded Linux Systems Enrico Jörns – [email protected]
Transcript
Page 1: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

https://www.pengutronix.de

Safe and Secure Field Updates ofEmbedded Linux Systems

Enrico Jörns – [email protected]

Page 2: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

2/28

About Me

Embedded software developer Co-maintainer of FOSS update framework RAUC At Pengutronix since 2014

Embedded Linux consulting & support since 2001 > 4500 patches in Linux kernel

Page 3: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

3/28

Updating Embedded Systems

Unattended / remote Long life time Insecure physical environment CVEs, bugs Technology changes

→ Requires robust and fail-safe update & system design

> 10 years

Page 4: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

4/28

Image-Based Updating

Package-based updates inappropriate Require interactive administration Conflicts Untested combinations Affected by file system corruption

Full image-based system updates Well-defined state (reproducibility!) Well-tested state of application + software

Page 5: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

5/28

Fail-Safe Updating

Updating device. Do not turn off!

Page 6: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

6/28

Fail-Safe Updating

A: Active (running) system

B: Non-running system

Page 7: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

7/28

Fail-Safe Updating

A B

Bootloader

Deactivate partition to update

Page 8: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

8/28

Fail-Safe Updating

A B

Bootloader

Deactivate partition to update

Write update(s) to disk

Critical Operation!

Page 9: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

9/28

Fail-Safe Updating

A B

Bootloader

Deactivate partition to update

Write update(s) to disk

Critical Operation! Update fully completed +

verified, etc.

Page 10: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

10/28

Fail-Safe Updating

A B

Bootloader

Deactivate partition to update

Write update(s) to disk

Critical Operation! Update fully completed +

verified, etc. Activate updated slot

Page 11: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

11/28

A BAR

A BR

Redundancy – Variants

Downtime Fallback

Disk space

No downtime

Fallback

Disk space

Extra robust

Page 12: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

12/28

Bootloader Updates – eMMC

Single pointof failure!

boot0boot1

usersystem

extCSDboot.img

● Provides 2 built-in boot partitions● Selectable by extCSD register Allows atomic bootloader update

eMMC

Page 13: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

13/28

Failure Detection & Fallback

Watchdog to detect fatal crashes + hangs

Optional: Fallback after n failed attempts

When is a system considered booted successfully? How to detect faulty runtime behaviour?

Page 14: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

14/28

systemd – System and Service Manager

example.service: Watchdog multiplexer & application control

Detect dying + hanging services

Resource limiting Encapsulation + hardening

features

[unit]Description=Critical application

[Service]ExecStart=/usr/bin/myappWatchdogSec=30sRestart=on-failureStartLimitInterval=5minStartLimitBurst=3StartLimitAction=reboot-force...LimitNPROC=32...ProtectSystem=strict

Page 15: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

15/28

Updating – Authentication

With great power

comes great responsibility!

Page 16: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

16/28

Updating – Authentication

Prevent unauthorized access!

Signing the update artifact Verification on target Use well-proven & open

source crypto (OpenSSL)

Update

DeviceDevice

+

Update

Page 17: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

17/28

Authentication – X.509 PKI

root

develop release

per device

Self-signed (for testing!) Development vs. release

key Per-device keys Multiple signer Replace and revoke keys

Page 18: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

18/28

A New CVE For Our Platform Came Up!

When can we deploy the fix?

Page 19: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

19/28

Software Stack – Technical Debt

https://medium.com/@adamdonaghy/in-defence-of-tech-debt-dc9595e0d316

Project-specific modifications

Deprecated / unmaintained software

unable to react!

Resolve using open sourcetools & workflows

Page 20: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

20/28

Software Maintenance

Embedded Linux platform

open sourcesoftware

proprietarysoftware

Start with latest versions Push changes upstream Regular update cycles Use embedded Linux build

systems

Automated testing (on hardware)

> 90% of all critical bugs fixedby the open source communities

Page 21: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

21/28

Automation & Reproducibility

Page 22: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

22/28

Using Open Source Update Tools

Home-grown solutions error-prone! Less effort, less costs Stability through community review

and testing New features ‘for free‘ Use development time for new features

instead of reinventing the wheel!

swupdate

Page 23: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

23/28

FOSS Update Tools – RAUC

LGPLv2 C + glib + OpenSSL Flexible and extensible X.509 (CMS), PKCS#11 Application-controlled

update process Binary delta update

streaming (casync)

Page 24: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

24/28

FOSS Update Tools – RAUC

[system]compatible=MyProduct2000bootloader=barebox

[keyring]path=/etc/rauc/keyring.pem

[slot.rootfs.0]device=/dev/sda0type=ext4bootname=system0

[slot.rootfs.1]device=/dev/sda1type=ext4bootname=system1

[...]

Target device: RAUC system configuration

[update]compatible=MyProduct2000version=2019.02-4build=20190228134503

[image.rootfs]filename=rootfs.ext4size=419430400sha256=b14c1457dc1046...

[image.appfs]filename=appfs.ext4size=219430400sha256=ecf4c031d01cb9...hooks=post-install

Update Bundle: manifest

Page 25: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

25/28

Conclusion

Safe & secure updating is complex Use open source update frameworks! A good overall system design is the key to robustness systemd provides good tooling for fail-safe system designs Eliminate technical debt by using open source software and

workflows!

Page 26: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

https://www.pengutronix.de

Thank you!

Questions?

Pengutronix e.K.

H. 4-261

Page 27: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

27/28

References

Yocto Project – System update:

https://wiki.yoctoproject.org/wiki/System_Update

RAUC system update documentation:

https://rauc.readthedocs.io/en/latest/

systemd watchdog handling

http://0pointer.de/blog/projects/watchdog.html

Labgrid – Embedded boards control for testing automation

https://labgrid.readthedocs.io/en/latest/

RAUC on GitHub:

https://github.com/rauc/rauc

Page 28: Safe and Secure Field Updates of Embedded Linux Systems · systemd – System and Service Manager example.service: Watchdog multiplexer & application control Detect dying + hanging

28/28

Build System

install

r/oext4

block devicer/w

extract

journal tagsdm-integrity

hash treeimage tar

Target

dm-verity dm-integrity

Updating And Verified Boot


Recommended