Bug 1492597 - Enable seccomp by out of the box with QEMU >= 2.11
Summary: Enable seccomp by out of the box with QEMU >= 2.11
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.6
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: ---
Assignee: Ján Tomko
QA Contact: yafu
URL:
Whiteboard:
Depends On:
Blocks: 1500889 1500891 1609081 1654309 1558125 1597836
TreeView+ depends on / blocked
 
Reported: 2017-09-18 09:36 UTC by Daniel Berrangé
Modified: 2019-03-07 15:49 UTC (History)
16 users (show)

Fixed In Version: libvirt-4.3.0-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1597836 (view as bug list)
Environment:
Last Closed: 2018-10-30 09:50:00 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2018:3113 None None None 2018-10-30 09:51:23 UTC

Description Daniel Berrangé 2017-09-18 09:36:48 UTC
Description of problem:

Historically seccomp feature in QEMU has maintained a giant whitelist of syscalls to allow every feature builtin to QEMU to work. This offered little security benefit (because things like execve are allowed), and at the same time was unreliable (because no one was sure what syscalls 3rd party libraries needed), so was not something that could be enabled by default. 

In QEMU 2.11, the seccomp feature has been changed to use modular blacklists. By default only a small set of syscalls are blocked, so this can safely be enabled with near zero risk of breaking any part of QEMU. To allow useful security policy to be enabled, you can opt-in to blocking further syscalls. In particular its possible to block the ability to execve other programs, or elevate privileges via setuid.

Since libvirt never relies on QEMU's  ifup helper, or setuid bridge helper, etc it can safely block execve + elevated privileges in seccomp .

This would give us a moderately useful seccomp policy for QEMU out of the box.

Patches:

https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg04072.html

Background:

https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg03348.html

Comment 3 Ján Tomko 2018-03-31 20:16:43 UTC
RFC version posted upstream:
https://www.redhat.com/archives/libvir-list/2018-March/msg01965.html

Comment 5 Ján Tomko 2018-04-17 14:33:37 UTC
Pushed as:
commit 3527f9dde67460e9f2d50ce52b8dade8c0848e86
Author:     Ján Tomko <jtomko@redhat.com>
CommitDate: 2018-04-17 16:29:38 +0200

    qemu: deny privilege elevation and spawn in seccomp
    
    If QEMU uses a seccomp blacklist (since 2.11), -sandbox on
    no longer tries to whitelist all the calls, but uses sets
    of blacklists:
    default (always blacklisted with -sandbox on)
    obsolete (defaults to deny)
    elevateprivileges (setuid & co, default: allow)
    spawn (fork & execve, default: allow)
    resourcecontrol (setaffinity, setscheduler, default: allow)
    
    If these are supported, default to sandbox with all four
    categories blacklisted.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1492597
    
    Signed-off-by: Ján Tomko <jtomko@redhat.com>
    Reviewed-by: John Ferlan <jferlan@redhat.com>
    Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

git describe: v4.2.0-258-g3527f9dde6

Comment 8 yafu 2018-08-24 09:38:30 UTC
Verified with libvirt-4.5.0-7.el7.x86_64 and qemu-kvm-rhev-2.12.0-11.el7.x86_64.

Test steps:
1.Check the default seccomp config in qemu.conf, seccomp is enabled by default:
#cat /etc/libvirt/qemu.conf
# Use seccomp syscall sandbox in QEMU.
# 1 == seccomp enabled, 0 == seccomp disabled
#
# If it is unset (or -1), then seccomp will be enabled
# only if QEMU >= 2.11.0 is detected, otherwise it is
# left disabled. This ensures the default config gets
# protection for new QEMU using the blacklist approach.
#
#seccomp_sandbox = 1

2.Start a guest and check the qemu cmd line:
#ps aux | grep -i sandbox
...-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny ...

3.Disable seccomp config in qemu.conf and restart libvirtd service:
#cat /etc/libvirt/qemu.conf
seccomp_sandbox = 0

#systemctl restart libvirtd

3.Start a guest and check the qemu cmd line:
#ps aux  | grep -i sandbox
...-sandbox off...

4.Set seccomp_sandbox to an integer expected 0, then restart libvirtd service, start a guest and check the qemu cmd line, seccomp is enabled as expression described.

5.Set seccomp_sandbox to a char, then restart libvirtd service:
#cat /etc/libvirt/qemu.conf
seccomp_sandbox = a

#systemctl restart libvirtd

#pidof libvirtd
no output

6.Check the error info in syslog:
#cat /var/log/messages
Aug 24 05:18:09 dell-per730-44 libvirtd: 137449: error : virConfParseValue:531 : configuration file syntax error: /etc/libvirt/qemu.conf:680: expecting a value
Aug 24 05:18:09 dell-per730-44 libvirtd: 137449: error : virStateInitialize:667 : Initialization of QEMU state driver failed: configuration file syntax error: /etc/libvirt/qemu.conf:680: expecting a value
Aug 24 05:18:09 dell-per730-44 libvirtd: 137449: error : daemonRunStateInit:806 : Driver state initialization failed

7.Also test do migration between host enable seccomp and disable seccomp, the test results are expected.

Comment 10 errata-xmlrpc 2018-10-30 09:50:00 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:3113


Note You need to log in before you can comment on or make changes to this bug.