kpatch Have your security and eat it too! Josh Poimboeuf Senior - - PowerPoint PPT Presentation

kpatch
SMART_READER_LITE
LIVE PREVIEW

kpatch Have your security and eat it too! Josh Poimboeuf Senior - - PowerPoint PPT Presentation

kpatch Have your security and eat it too! Josh Poimboeuf Senior Software Engineer, Red Hat LinuxCon North America August 22, 2014 Agenda What is kpatch? Why use kpatch? Demo How it works Features & Limitations Try


slide-1
SLIDE 1

Josh Poimboeuf Senior Software Engineer, Red Hat LinuxCon North America August 22, 2014

kpatch

Have your security and eat it too!

slide-2
SLIDE 2

2

Agenda

  • What is kpatch?
  • Why use kpatch?
  • Demo
  • How it works
  • Features & Limitations
  • Try it!
  • Questions?
slide-3
SLIDE 3

3

What is kpatch?

  • Live kernel patching framework
  • Patch a running kernel
  • No reboots
  • No disruption to applications
  • Used for security and stability fixes
  • Not for major kernel updates
slide-4
SLIDE 4

4

Open source

  • Started as internal Red Hat project
  • Feb 2014: Released on github
  • Goal: merge into upstream Linux
  • Already stable and useful
  • 100% self-contained
  • Works on many distributions
  • Fedora, Ubuntu, Debian, Arch, RHEL7*, CentOS7, OL7

* Use at your own risk

slide-5
SLIDE 5

5

Why kpatch?

slide-6
SLIDE 6

6

Kernel bugs are problematic

  • Many security bugs waiting to be

found

  • Large attack surface
  • Huge code base
  • System-level impact -> high priority
  • Many high-priority security fixes
  • Kernel update = reboot
  • Kernel updates are often delayed
slide-7
SLIDE 7

7

Why is rebooting a problem?

  • Disruption to users/applications
  • Sysadmins don't always have control
  • f users or applications
  • Many applications aren't distributed
  • Re-architecting can be expensive or impractical
  • Distributed systems need to reboot too
  • (Up)time is money
  • Hardware reboot failures
slide-8
SLIDE 8

8

Security vs business factors

  • Security doesn't exist in a vacuum
  • Judgment calls / business decisions
  • Risk of getting hacked vs reboot costs
  • Reboot now? Or risk it and wait?
slide-9
SLIDE 9

9

Security at the expense of flexibility comes at the expense of security

slide-10
SLIDE 10

10

kpatch to the rescue

  • Remove security / flexibility trade-offs
  • No more risk analysis, judgment calls,

business decisions, etc.

  • Apply security fixes immediately
  • No disruption to users/applications
  • Can wait for a better time to reboot
  • Scheduled reboots
slide-11
SLIDE 11

11

kpatch benefits

  • Security-focused
  • Flexibility and predictability
  • Uptime-focused
  • Security
  • The rest of us
  • All of the above
  • Decouple (arbitrary) security fix

schedule from reboot schedule

slide-12
SLIDE 12

12

“But this sounds crazy...”

  • Integrated with kernel (not a Band-Aid)
  • Uses ftrace to do the patching
  • Replacement functions are first class functions
  • Compatible with oops, ftrace, kprobes, kdump, perf, etc.
  • Taint flag
  • Patching process is deterministic
  • Simple design
  • Code is 100% self-contained
slide-13
SLIDE 13

13

Is it safe?

*if you're very careful with your patch selection

*

slide-14
SLIDE 14

14

Demo

slide-15
SLIDE 15

15

How it works

slide-16
SLIDE 16

16

How it works

  • 1. Build the patch module
  • kpatch-build foo.patch
  • 2. Patch the kernel
  • kpatch load kpatch-foo.ko
slide-17
SLIDE 17

17

Building the patch module

  • Much harder than patching the kernel!
  • Compile kernel with/without patch
  • Compare binaries
  • Detect which have functions changed
  • Extract object code of changed

functions into patch module

  • Edge cases...
  • Compiler optimizations, kernel special ELF sections
slide-18
SLIDE 18

18

Determining patch safety

  • Some patches are inherently unsafe
  • Data structure changes
  • Data semantic changes
  • Tooling does some safety analysis
  • Impossible for a program to definitively

determine whether a patch is safe

slide-19
SLIDE 19

19

A human must analyze each patch to determine whether it's safe to apply in a live patching context!

slide-20
SLIDE 20

20

Human patch analysis

  • What function does
  • What patch does
  • How patch changes data interactions
  • Modify patch if needed
  • Kernel expert recommended
  • Or get your Linux distribution to do it
slide-21
SLIDE 21

21

Patching the kernel

slide-22
SLIDE 22

22

Patching the kernel

  • 1. Load new functions into memory
  • 2. Link new functions into kernel
  • Allows access to unexported kernel symbols
  • 3. Activeness safety check
  • Prevent old & new functions from running at same time
  • stop_machine() + stack backtrace checks
  • 4. Patch it!
  • Uses ftrace
slide-23
SLIDE 23

23

Patching with ftrace

Original Function ftrace kpatch

New Function

call return return

no op

Old Function

noop

Original Function call

no op

Old Function

call

Before patching: After patching:

call

return call

slide-24
SLIDE 24

24

Features & Limitations

slide-25
SLIDE 25

25

Features

  • Patch rollback
  • Patch on reboot
  • Multiple patches
  • Atomic patch upgrade
  • Module patching (and deferred)
  • User load/unload hook functions
  • Skip backtrace safety check
slide-26
SLIDE 26

26

Limitations

  • Human safety analysis required!
  • Not a general purpose upgrade tool
  • ~80% of all CVE patches currently

supported

  • Data structure changes, edge cases
  • Goal: 99%
  • stop_machine() latency: 1ms – 40ms
  • Currently x86_64 only
slide-27
SLIDE 27

27

kpatch on RHEL 7

  • Not supported at this time
  • Working with small customer group to

get early operational feedback

  • Goal: get it (or something like it)

merged upstream first

slide-28
SLIDE 28

28

Try it!

slide-29
SLIDE 29

29

Feedback wanted

  • We've built the “car”
  • Kicked the tires
  • Many test drives
  • Not many long family road trips or daily commuters yet?
  • Looking for brave users to solve real-

world problems with it

  • Help influence the direction of kpatch
slide-30
SLIDE 30

30

Try it!

  • See the README on github
  • Quick start guide
  • More in-depth information
  • Open github issues
  • Join the mailing list
  • Ping us on IRC
  • Contributors welcome!
slide-31
SLIDE 31

31

Reference

  • Github repository
  • https://github.com/dynup/kpatch
  • Mailing list
  • https://www.redhat.com/mailman/listinfo/kpatch
  • IRC channel: #kpatch on freenode
  • Contact me: jpoimboe@redhat.com
slide-32
SLIDE 32

32

Questions?