RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
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 1558125 1597836 1609081 1654309
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:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2018:3113 0 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>
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>
    Reviewed-by: John Ferlan <jferlan>
    Reviewed-by: Daniel P. Berrangé <berrange>

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.