22
Thunderbolt 3 and GNU/Linux FOSDEM 2018 Christian Kellner, PhD Desktop Hardware Enablement 04/02/2018

Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

  • Upload
    others

  • View
    16

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

Thunderbolt 3 and GNU/Linux

FOSDEM 2018

Christian Kellner, PhDDesktop Hardware Enablement04/02/2018

Page 2: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

What is this , anyway?

Page 3: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

3

“The USB-C that does it all”Intel*

* https://thunderbolttechnology.net/

Page 4: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

4

Thunderbolt 3 — Overview

• USB type C connector (one port to confuse them all)

• 40 Gb/s• 4 PCI Express (Gen 3) lanes• 8 DisplayPort (1.2) lanes • Native USB 3.1• Daisy-chain up to 6 devices• Up to 100 W for charging, 15W for devices

• Networking, external Graphic• Docks, docks, docks

Page 5: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

5

Thunderbolt 3 — Connection Modes

USB ONLY DISPLAYPORT ONLY

DP & USB MULTI-FUNCTION

Active when USB devices are plugged in.Behaves as a normal USB-C 3.1 port.

THUNDERBOLT 3

Switch pins of USB-C into DP alternate mode. TB will act as a router for DP data from GFX to USB-C port

One high-speed pair is used for DP.The other high-speed pair is used for USB 3.1

All 4 high speeds links active (at 10/20 Gbps).max 4 PCIe Gen 3 lanesmax 2 DisplayPort links

THUNDERBOLT NETWORKIG

POWER DELIVERY & CHARGING

Page 6: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

6

Thunderbolt — Security ???Thunderbolt is PCIe → DMA→ DMA attacks

https://github.com/ufrisk/pcileech

Page 7: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

7

Thunderbolt 3 — Security Modes

NONE DP ONLY

USER

No Security. Doh. All devices are authorized by default.

SECURE

Display Port only. You guessed right.

Thunderbolt devices need to authorized. Only then are PCIe lanes activated.

Thunderbolt devices need to authorized. Their identity can be verifed via a key.

Page 8: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

8

Thunderbolt 3 — Security ModesIn the land of the dialogs … … no we are not doing that.

Page 9: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

Thunderbolt and GNU/Linux

Page 10: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

10

Thunderbolt & GNU/LinuxOverview

sysfs/udev

Linux 4.13

boltdSystem deaemon

gnome-shell

gnome-control-center

boltctlD-Bu

s

other DE integration

Page 11: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

11

Kernel InterfaceLinux kernel 4.13+ provide a sysfs interface

/sys/bus/thunderbolt/ └── devices ├── domain0 → 0-0/ security subsystem@ uevent […]    ├── 0-0 → 0-1/ authorized device device_name vendor_name unique_id […]    ├── 0-1 → 0-301/ authorized […] key […] unique_id    └── 0-301 → […] nvm_active2/ nvm_non_active2/ nvm_version nvm_authenticate

# echo 1 > /sys/bus/thunderbolt/devices/0-1/authorized

# key=$(openssl rand -hex 32)# echo $key > /sys/bus/thunderbolt/devices/0-1/key# echo 1 > /sys/bus/thunderbolt/devices/0-1/authorized

# echo $key > /sys/bus/thunderbolt/devices/0-1/key# echo 2 > /sys/bus/thunderbolt/devices/0-1/authorized

/sys/bus/thunderbolt/ └── devices ├── domain0 → 0-0/ security subsystem@ uevent […]    ├── 0-0 → 0-1/ authorized device device_name vendor_name unique_id […]    ├── 0-1 → 0-301/ authorized […] key […] unique_id    └── 0-301 → […] nvm_active2/ nvm_non_active2/ nvm_version nvm_authenticate

# echo 1 > /sys/bus/thunderbolt/devices/0-1/authorized

# key=$(openssl rand -hex 32)# echo $key > /sys/bus/thunderbolt/devices/0-1/key# echo 1 > /sys/bus/thunderbolt/devices/0-1/authorized

# echo $key > /sys/bus/thunderbolt/devices/0-1/key# echo 2 > /sys/bus/thunderbolt/devices/0-1/authorized

Page 12: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

12

Thunderbolt frmware updatesfwupd & Linux Vendor Firmware Service (LVFS)

* https://fwupd.org/

# get current versionnvm_version

# write new firmware tonvm_non_active2/nvmem

# start updatingnvm_authenticate

# get current versionnvm_version

# write new firmware tonvm_non_active2/nvmem

# start updatingnvm_authenticate

Page 13: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

13

Thunderbolt & GNU/Linuxboltd

boltdSystem deaemon D-

Bus

● System daemon, activated on demand ● D-Bus API to manage devices, signal device “changes”● Authorize, enroll (authorize and store)● Polkit to secure the D-Bus API● Device “database” of previously enrolled devices and their policy● Paranoid (now fortify) mode

● Needs a policy agent to do the initial authorization, enrollment

Page 14: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

14

boltdD-Bus API: manager interface

Page 15: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

15

boltdD-Bus API: manager interface

Page 16: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

16

boltctlcli interface

Page 17: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

17

gnome-shellActs as a policy agent

Listen to “device-added” D-Bus signal from boltd

user logged in & session unlocked

yes no

user is admin

yes no

Notifcation: new Unauthorized device

Enroll device Polkitadmin authorization

Page 18: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

18

gnome-shellActs as a policy agent

Page 19: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

19

gnome-shellprovide UI feedback about thunderbolt bus activity

Page 20: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

20

gnome-control-centermanage devices, provide feedback

Page 21: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

21

gnome-control-centermanage devices, provide feedback

Page 22: Thunderbolt 3 and GNU/Linux - FOSDEM · Thunderbolt 3 — Connection Modes USB ONLY DISPLAYPORT ONLY DP & USB MULTI-FUNCTION Active when USB devices are plugged in. Behaves as a normal

THANK YOU

github.com/gicmo/bolt

christian.kellner.me