internals of landlock: a new kind of linux security module ...jul 04, 2018  · extended berkeley...

71
Internals of Landlock: a new kind of Linux Security Module leveraging eBPF Micka¨ el Sala¨ un ANSSI July 4, 2018 1 / 24

Upload: others

Post on 22-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Internals of Landlock: a new kind of LinuxSecurity Module leveraging eBPF

Mickael Salaun

ANSSI

July 4, 2018

1 / 24

Page 2: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Protect users from your application

Threat

1. bug exploitation of your code

2. bug or backdoor in a third party component

⇒ your application is used against your will

Defenses

I follow secure development practices

I use an hardened toolchain

I use OS security features (e.g. sandboxes)

The Landlock features

I help define and embed security policy in your code

I enforce an access control on your application

2 / 24

Page 3: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Protect users from your application

Threat

1. bug exploitation of your code

2. bug or backdoor in a third party component

⇒ your application is used against your will

Defenses

I follow secure development practices

I use an hardened toolchain

I use OS security features (e.g. sandboxes)

The Landlock features

I help define and embed security policy in your code

I enforce an access control on your application

2 / 24

Page 4: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Protect users from your application

Threat

1. bug exploitation of your code

2. bug or backdoor in a third party component

⇒ your application is used against your will

Defenses

I follow secure development practices

I use an hardened toolchain

I use OS security features (e.g. sandboxes)

The Landlock features

I help define and embed security policy in your code

I enforce an access control on your application

2 / 24

Page 5: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Demonstration #1

Read-only accesses...

I /publicI /etcI /usrI . . .

...and read-write accesses

I /tmpI . . .

3 / 24

Page 6: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

What about the other Linux security features?

Fine-grained control Embedded policy Unprivileged use

SELinux. . . X

seccomp-bpf X X

namespaces X ∼

Landlock X X X1

Tailored access control to match your needs: programmatic access control

1Disabled on purpose for the initial upstream inclusion, but planned to be enabledafter a test period.

4 / 24

Page 7: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

What about the other Linux security features?

Fine-grained control Embedded policy Unprivileged use

SELinux. . . X

seccomp-bpf X X

namespaces X ∼

Landlock X X X1

Tailored access control to match your needs: programmatic access control

1Disabled on purpose for the initial upstream inclusion, but planned to be enabledafter a test period.

4 / 24

Page 8: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

What about the other Linux security features?

Fine-grained control Embedded policy Unprivileged use

SELinux. . . X

seccomp-bpf X X

namespaces X ∼

Landlock X X X1

Tailored access control to match your needs: programmatic access control

1Disabled on purpose for the initial upstream inclusion, but planned to be enabledafter a test period.

4 / 24

Page 9: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Landlock overview

5 / 24

Page 10: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

extended Berkeley Packet Filter

In-kernel virtual machine

I safely execute code in the kernel at run time

I widely used in the kernel: network filtering (XDP), seccomp-bpf,tracing. . .

I can call dedicated functions

I can exchange data through maps between eBPF programs anduser-space

Static program verification at load time

I memory access checks

I register typing and tainting

I pointer leak restrictions

I execution flow restrictions

6 / 24

Page 11: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

extended Berkeley Packet Filter

In-kernel virtual machine

I safely execute code in the kernel at run time

I widely used in the kernel: network filtering (XDP), seccomp-bpf,tracing. . .

I can call dedicated functions

I can exchange data through maps between eBPF programs anduser-space

Static program verification at load time

I memory access checks

I register typing and tainting

I pointer leak restrictions

I execution flow restrictions

6 / 24

Page 12: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

The Linux Security Modules framework (LSM)

LSM framework

I allow or deny user-space actions on kernel objects

I policy decision and enforcement points

I kernel API: support various security models

I 200+ hooks: inode permission, inode unlink, file ioctl. . .

Landlock

I hook: set of actions on a specific kernel object (e.g. walk a file path)

I program: access-control checks stacked on a hook

I triggers: actions mask for which a program is run (e.g. read, write,execute, remove, IOCTL. . . )

7 / 24

Page 13: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

The Linux Security Modules framework (LSM)

LSM framework

I allow or deny user-space actions on kernel objects

I policy decision and enforcement points

I kernel API: support various security models

I 200+ hooks: inode permission, inode unlink, file ioctl. . .

Landlock

I hook: set of actions on a specific kernel object (e.g. walk a file path)

I program: access-control checks stacked on a hook

I triggers: actions mask for which a program is run (e.g. read, write,execute, remove, IOCTL. . . )

7 / 24

Page 14: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Safely handle malicious policies

I Landlock should be usable by everyone

I we can’t tell if a process will be malicious

⇒ trust issue

8 / 24

Page 15: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Unprivileged access control

Sought properties

I multiple applications, need independant but composable securitypolicies

I tamper proof: prevent bypass through other processes (i.e. via ptrace)

Harmlessness

I safe approach: follow the least privilege principle (i.e. no SUID)

I limit the kernel attack surface:I minimal kernel code (security/landlock/*: ∼2000 SLOC)I eBPF static analysisI move complexity from the kernel to eBPF programs

9 / 24

Page 16: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Unprivileged access control

Sought properties

I multiple applications, need independant but composable securitypolicies

I tamper proof: prevent bypass through other processes (i.e. via ptrace)

Harmlessness

I safe approach: follow the least privilege principle (i.e. no SUID)

I limit the kernel attack surface:I minimal kernel code (security/landlock/*: ∼2000 SLOC)I eBPF static analysisI move complexity from the kernel to eBPF programs

9 / 24

Page 17: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Unprivileged access control

Protect access to process ressources

I the rule creator must be allowed to ptrace the sandboxed process

Protect access to kernel ressources

I prevent information leak: an eBPF program shall not have moreaccess rights than the process which loaded it

I still, access control need some knowledge to take decision (e.g. filepath check)

I only interpreted on viewable objects and after other access controls

10 / 24

Page 18: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Unprivileged access control

Protect access to process ressources

I the rule creator must be allowed to ptrace the sandboxed process

Protect access to kernel ressources

I prevent information leak: an eBPF program shall not have moreaccess rights than the process which loaded it

I still, access control need some knowledge to take decision (e.g. filepath check)

I only interpreted on viewable objects and after other access controls

10 / 24

Page 19: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Identifying a file path

I path evaluation based on walking through inodes

I multiple Landlock program types

11 / 24

Page 20: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

eBPF inode map

Goalrestrict access to a subset of the filesystem

Challenges

I efficient

I updatable from user-space

I unprivileged use:I no xattrI no absolute path

Solution

I new eBPF map type to identify an inode object

I use inode as key and associate it with a 64-bits arbitrary value

12 / 24

Page 21: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

eBPF inode map

Goalrestrict access to a subset of the filesystem

Challenges

I efficient

I updatable from user-space

I unprivileged use:I no xattrI no absolute path

Solution

I new eBPF map type to identify an inode object

I use inode as key and associate it with a 64-bits arbitrary value

12 / 24

Page 22: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

eBPF inode map

Goalrestrict access to a subset of the filesystem

Challenges

I efficient

I updatable from user-space

I unprivileged use:I no xattrI no absolute path

Solution

I new eBPF map type to identify an inode object

I use inode as key and associate it with a 64-bits arbitrary value

12 / 24

Page 23: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Demonstration #2

Update access rights on the fly

13 / 24

Page 24: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Chained programs and session

Landlock programs and their triggers (example)

14 / 24

Page 25: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Chained programs and session

Landlock programs and their triggers (example)

14 / 24

Page 26: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Chained programs and session

Landlock programs and their triggers (example)

14 / 24

Page 27: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Walking through a file path

Example: open /public/web/index.html

15 / 24

Page 28: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Walking through a file path

Example: open /public/web/index.html

15 / 24

Page 29: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Walking through a file path

Example: open /public/web/index.html

15 / 24

Page 30: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Walking through a file path

Example: open /public/web/index.html

15 / 24

Page 31: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Walking through a file path

Example: open /public/web/index.html

15 / 24

Page 32: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Walking through a file path

Example: open /public/web/index.html

15 / 24

Page 33: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

From the rule to the kernel

I writing a Landlock rule

I loading it in the kernel

I enforcing it on a set of processes

16 / 24

Page 34: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Life cycle of a Landlock program

17 / 24

Page 35: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Landlock program’s metadata

1 static union bpf_prog_subtype metadata = {2 .landlock_hook = {3 .type = LANDLOCK_HOOK_FS_PICK,4 .options = LANDLOCK_OPTION_PREVIOUS,5 .previous = 2, /* landlock2 */6 .triggers = LANDLOCK_TRIGGER_FS_PICK_APPEND | \7 LANDLOCK_TRIGGER_FS_PICK_CREATE | \8 // [...]9 LANDLOCK_TRIGGER_FS_PICK_WRITE,

10 }11 };

18 / 24

Page 36: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Landlock program’s metadata

1 static union bpf_prog_subtype metadata = {2 .landlock_hook = {3 .type = LANDLOCK_HOOK_FS_PICK,4 .options = LANDLOCK_OPTION_PREVIOUS,5 .previous = 2, /* landlock2 */6 .triggers = LANDLOCK_TRIGGER_FS_PICK_APPEND | \7 LANDLOCK_TRIGGER_FS_PICK_CREATE | \8 // [...]9 LANDLOCK_TRIGGER_FS_PICK_WRITE,

10 }11 };

18 / 24

Page 37: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Landlock program’s metadata

1 static union bpf_prog_subtype metadata = {2 .landlock_hook = {3 .type = LANDLOCK_HOOK_FS_PICK,4 .options = LANDLOCK_OPTION_PREVIOUS,5 .previous = 2, /* landlock2 */6 .triggers = LANDLOCK_TRIGGER_FS_PICK_APPEND | \7 LANDLOCK_TRIGGER_FS_PICK_CREATE | \8 // [...]9 LANDLOCK_TRIGGER_FS_PICK_WRITE,

10 }11 };

18 / 24

Page 38: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Landlock program’s metadata

1 static union bpf_prog_subtype metadata = {2 .landlock_hook = {3 .type = LANDLOCK_HOOK_FS_PICK,4 .options = LANDLOCK_OPTION_PREVIOUS,5 .previous = 2, /* landlock2 */6 .triggers = LANDLOCK_TRIGGER_FS_PICK_APPEND | \7 LANDLOCK_TRIGGER_FS_PICK_CREATE | \8 // [...]9 LANDLOCK_TRIGGER_FS_PICK_WRITE,

10 }11 };

18 / 24

Page 39: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Landlock program’s metadata

1 static union bpf_prog_subtype metadata = {2 .landlock_hook = {3 .type = LANDLOCK_HOOK_FS_PICK,4 .options = LANDLOCK_OPTION_PREVIOUS,5 .previous = 2, /* landlock2 */6 .triggers = LANDLOCK_TRIGGER_FS_PICK_APPEND | \7 LANDLOCK_TRIGGER_FS_PICK_CREATE | \8 // [...]9 LANDLOCK_TRIGGER_FS_PICK_WRITE,

10 }11 };

18 / 24

Page 40: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Landlock program’s metadata

1 static union bpf_prog_subtype metadata = {2 .landlock_hook = {3 .type = LANDLOCK_HOOK_FS_PICK,4 .options = LANDLOCK_OPTION_PREVIOUS,5 .previous = 2, /* landlock2 */6 .triggers = LANDLOCK_TRIGGER_FS_PICK_APPEND | \7 LANDLOCK_TRIGGER_FS_PICK_CREATE | \8 // [...]9 LANDLOCK_TRIGGER_FS_PICK_WRITE,

10 }11 };

18 / 24

Page 41: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Landlock program code

1 int fs_pick_write(struct landlock_ctx_fs_pick *ctx) {2 __u64 cookie = ctx->cookie;34 cookie = update_cookie(cookie, ctx->inode_lookup,5 (void *)ctx->inode);6 if (cookie & MAP_MARK_WRITE)7 return LANDLOCK_RET_ALLOW;8 return LANDLOCK_RET_DENY;9 }

19 / 24

Page 42: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Landlock program code

1 int fs_pick_write(struct landlock_ctx_fs_pick *ctx) {2 __u64 cookie = ctx->cookie;34 cookie = update_cookie(cookie, ctx->inode_lookup,5 (void *)ctx->inode);6 if (cookie & MAP_MARK_WRITE)7 return LANDLOCK_RET_ALLOW;8 return LANDLOCK_RET_DENY;9 }

19 / 24

Page 43: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Landlock program code

1 int fs_pick_write(struct landlock_ctx_fs_pick *ctx) {2 __u64 cookie = ctx->cookie;34 cookie = update_cookie(cookie, ctx->inode_lookup,5 (void *)ctx->inode);6 if (cookie & MAP_MARK_WRITE)7 return LANDLOCK_RET_ALLOW;8 return LANDLOCK_RET_DENY;9 }

19 / 24

Page 44: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Landlock program code

1 int fs_pick_write(struct landlock_ctx_fs_pick *ctx) {2 __u64 cookie = ctx->cookie;34 cookie = update_cookie(cookie, ctx->inode_lookup,5 (void *)ctx->inode);6 if (cookie & MAP_MARK_WRITE)7 return LANDLOCK_RET_ALLOW;8 return LANDLOCK_RET_DENY;9 }

19 / 24

Page 45: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Landlock program code

1 int fs_pick_write(struct landlock_ctx_fs_pick *ctx) {2 __u64 cookie = ctx->cookie;34 cookie = update_cookie(cookie, ctx->inode_lookup,5 (void *)ctx->inode);6 if (cookie & MAP_MARK_WRITE)7 return LANDLOCK_RET_ALLOW;8 return LANDLOCK_RET_DENY;9 }

19 / 24

Page 46: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Landlock program code

1 int fs_pick_write(struct landlock_ctx_fs_pick *ctx) {2 __u64 cookie = ctx->cookie;34 cookie = update_cookie(cookie, ctx->inode_lookup,5 (void *)ctx->inode);6 if (cookie & MAP_MARK_WRITE)7 return LANDLOCK_RET_ALLOW;8 return LANDLOCK_RET_DENY;9 }

19 / 24

Page 47: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Loading a rule in the kernel

1 union bpf_attr attr = {2 .insns = bytecode_array,3 .prog_type = BPF_PROG_TYPE_LANDLOCK_HOOK,4 .prog_subtype = &metadata,5 // [...]6 };7 int prog_fd = bpf(BPF_PROG_LOAD, &attr, sizeof(attr));

20 / 24

Page 48: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Loading a rule in the kernel

1 union bpf_attr attr = {2 .insns = bytecode_array,3 .prog_type = BPF_PROG_TYPE_LANDLOCK_HOOK,4 .prog_subtype = &metadata,5 // [...]6 };7 int prog_fd = bpf(BPF_PROG_LOAD, &attr, sizeof(attr));

20 / 24

Page 49: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Loading a rule in the kernel

1 union bpf_attr attr = {2 .insns = bytecode_array,3 .prog_type = BPF_PROG_TYPE_LANDLOCK_HOOK,4 .prog_subtype = &metadata,5 // [...]6 };7 int prog_fd = bpf(BPF_PROG_LOAD, &attr, sizeof(attr));

20 / 24

Page 50: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Loading a rule in the kernel

1 union bpf_attr attr = {2 .insns = bytecode_array,3 .prog_type = BPF_PROG_TYPE_LANDLOCK_HOOK,4 .prog_subtype = &metadata,5 // [...]6 };7 int prog_fd = bpf(BPF_PROG_LOAD, &attr, sizeof(attr));

20 / 24

Page 51: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Loading a rule in the kernel

1 union bpf_attr attr = {2 .insns = bytecode_array,3 .prog_type = BPF_PROG_TYPE_LANDLOCK_HOOK,4 .prog_subtype = &metadata,5 // [...]6 };7 int prog_fd = bpf(BPF_PROG_LOAD, &attr, sizeof(attr));

20 / 24

Page 52: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Loading a rule in the kernel

20 / 24

Page 53: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Applying a Landlock program to a process

1 seccomp(SECCOMP_PREPEND_LANDLOCK_PROG, 0, &prog_fd);

21 / 24

Page 54: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Applying a Landlock program to a process

21 / 24

Page 55: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Applying a Landlock program to a process

21 / 24

Page 56: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Applying a Landlock program to a process

21 / 24

Page 57: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Kernel execution flow

Example: the inode create hook

1. check if landlocked(current)2. call decide fs pick(LANDLOCK TRIGGER FS PICK CREATE, dir)3. for all fs pick programs enforced on the current process

3.1 update the program’s context3.2 interpret the program3.3 continue until one denies the access

22 / 24

Page 58: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Landlock: wrap-up

User-space hardening

I programmatic and embeddable access control

I designed for unprivileged use

I apply tailored access controls per process

I make it evolve over time (map)

Current status

I standalone patches merged in net/bpf, security and kselftest trees

I security/landlock/*: ∼2000 SLOC

I ongoing patch series: LKML, @l0kodI full security module stacking is comming!

23 / 24

Page 59: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Landlock: wrap-up

User-space hardening

I programmatic and embeddable access control

I designed for unprivileged use

I apply tailored access controls per process

I make it evolve over time (map)

Current status

I standalone patches merged in net/bpf, security and kselftest trees

I security/landlock/*: ∼2000 SLOC

I ongoing patch series: LKML, @l0kodI full security module stacking is comming!

23 / 24

Page 60: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

https://landlock.io

24 / 24

Page 61: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Rule enforcement on process hierarchy

Page 62: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Rule enforcement on process hierarchy

Page 63: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Rule enforcement on process hierarchy

Page 64: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Rule enforcement on process hierarchy

Page 65: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Rule enforcement on process hierarchy

Page 66: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Rule enforcement on process hierarchy

Page 67: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Enforcement through cgroups

Why?user/admin security policy (e.g. container): manage groups of processes

Challenges

I complementary to the process hierarchy rules (via seccomp(2))

I processes moving in or out of a cgroup

I unprivileged use with cgroups delegation (e.g. user session)

Page 68: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Enforcement through cgroups

Why?user/admin security policy (e.g. container): manage groups of processes

Challenges

I complementary to the process hierarchy rules (via seccomp(2))

I processes moving in or out of a cgroup

I unprivileged use with cgroups delegation (e.g. user session)

Page 69: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Future Landlock program types

fs gettag inodes: needed for relative path checks (e.g. openat(2))

fs ioctlcheck IOCTL commands

net *check IPs, ports, protocol. . .

Page 70: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Future Landlock program types

fs gettag inodes: needed for relative path checks (e.g. openat(2))

fs ioctlcheck IOCTL commands

net *check IPs, ports, protocol. . .

Page 71: Internals of Landlock: a new kind of Linux Security Module ...Jul 04, 2018  · extended Berkeley Packet Filter In-kernel virtual machine I safely execute code in the kernel at run

Future Landlock program types

fs gettag inodes: needed for relative path checks (e.g. openat(2))

fs ioctlcheck IOCTL commands

net *check IPs, ports, protocol. . .