Systemd - Bypassing MemoryDenyWriteExecution policy

Bug #1725348 reported by Thomas Imbert on 2017-10-20
This bug affects 1 person
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)

Bug Description


 * MemoryDenyWritePolicy can be bypassed by using a slightly different syscall.

[Test Case]

 * Check that MemoryDenyWritePolicy, blocks pkey_mprotect as well as mprotect.

[Regression Potential]

 * Upstream fix cherrypick, security vulnerability.

[Other Info]

 * Original report


We would like to report to you a vulnerability about systemd which allows to bypass the MemoryDenyWriteExecution policy on Linux 4.9+.

The vulnerability is described in the attached PDF file.


CVE References

Thomas Imbert (mastho) wrote :
Marc Deslauriers (mdeslaur) wrote :

Thanks for reporting this issue. Have you reported it to the systemd developers?

Thomas Imbert (mastho) wrote :

Hum I thought this was the way to report it to systemd developers.

Marc Deslauriers (mdeslaur) wrote :

Thanks, I was just making sure it wasn't already reported or public yet.

Marc Deslauriers (mdeslaur) wrote :

Subscribing Martin to this issue.

Hi Martin, does upstream require an embargo for this issue?

No, we don't require an embargo, although I'd be thankful for making a delay of one day so that we can have a patch ready when this is made public.

I think the impact is low because the man page says "Note that this feature is fully available on x86-64, and partially on x86". I hope this sounds discouraging enough that nobody relies on this feature too much ;)

information type: Private Security → Public Security

The attachment "0001-shared-seccomp-disallow-pkey_mprotect-the-same-as-mp.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Changed in systemd (Ubuntu Bionic):
status: New → Fix Committed
Launchpad Janitor (janitor) wrote :
Download full text (3.4 KiB)

This bug was fixed in the package systemd - 235-3ubuntu2

systemd (235-3ubuntu2) bionic; urgency=medium

  * systemd-fsckd: Fix ADT tests to work on s390x too.

systemd (235-3ubuntu1) bionic; urgency=medium

  * Merge 235-3 from debian:
    - Drop UBUNTU-CVE-2017-15908 included in Debian.

  * Remaining delta from Debian:
    - ship dhclient enter hook for dhclient integration with resolved
    - ship resolvconf integration via stub-resolv.conf
    - ship s390x virtio interface names migration
    - do not disable systemd-resolved upon libnss-resolve removal
    - do not remote fs in containers, for non-degrated boot
    - CVE-2017-15908 in resolved fix loop on packets with pseudo dns types
    - Unlink invocation id key, upon chown failure in containers
    - Change default to UseDomains by default
    - Do not treat failure to set Nice= setting as error in containers
    - Add a condition to systemd-journald-audit.socet to not start in
      containers (fails)
    - Build without any built-in/fallback DNS server setting
    - Enable resolved by default
    - Update autopkgtests for reliability/raciness, and testing for typical
    - Always upgrade udev, when running adt tests
    - Skip test-execute on armhf
    - Cherry-pick a few testsuite fixes

  * UBUNTU Do not use nested kvm during ADT tests.

systemd (235-3) unstable; urgency=medium

  [ Michael Biebl ]
  * Switch from XC-Package-Type to Package-Type. As of dpkg-dev 1.15.7
    Package-Type is recognized as an official field name.
  * Install modprobe configuration file to /lib/modprobe.d.
    Otherwise it is not read by kmod. (Closes: #879191)

  [ Felipe Sateler ]
  * Backport upstream (partial) fix for combined DynamicUser= + User=
    UID was not allowed to be different to GID, which is normally the case in
    debian, due to the group users being allocated the GID 100 without an
    equivalent UID 100 being allocated.
  * Backport upstream patches to fully make DynamicUser=yes + static,
    pre-existing User= work.

  [ Martin Pitt ]
  * Add missing python3-minimal dependency to systemd-tests
  * Drop long-obsolete systemd-bus-proxy system user
    systemd-bus-proxy hasn't been shipped since before stretch and never
    created any files. Thus clean up the obsolete system user on upgrades.
    (Closes: #878182)
  * Drop static systemd-journal-gateway system user
    systemd-journal-gatewayd.service now uses DynamicUser=, so we don't need
    to create this statically any more. Don't remove the user on upgrades
    though, as there is likely still be a running process. (Closes: #878183)
  * Use DynamicUser= for systemd-journal-upload.service.
  * Add Recommends: libnss-systemd to systemd-sysv.
    This is useful to actually be able to resolve dynamically created system
    users with DynamicUser=true. This concept is going to be used much more
    in future versions and (hopefully) third-party .services, so pulling it
    into the default installation seems prudent now.
  * resolved: Fix loop on packets with pseudo dns types.
    (CVE-2017-15908, Closes: #880026, LP: #1725351)
  * bpf-firewall: Properly handle kernels without BPF cgroup but with TRIE...


Changed in systemd (Ubuntu Bionic):
status: Fix Committed → Fix Released
Changed in systemd (Ubuntu Zesty):
status: New → Won't Fix
Changed in systemd (Ubuntu Xenial):
status: New → Invalid
Changed in systemd (Ubuntu Artful):
status: New → In Progress
description: updated

Hello Thomas, or anyone else affected,

Accepted systemd into artful-proposed. The package will build now and be available at in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-artful to verification-done-artful. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-artful. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at . Thank you in advance!

Changed in systemd (Ubuntu Artful):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-artful
Dimitri John Ledkov (xnox) wrote :

Using test software from pkeys(7) manpage, modified to use PROT_WRITE | PROT_EXEC, created systemd unit that tries to use memory protection, and started it as a systemd unit.

Thus calling:
status = pkey_mprotect(buffer, getpagesize(),
if (status == -1)
fprintf(stderr, "about to read buffer again...\n");

$ systemctl cat test.service
# /etc/systemd/system/test.service

$ dpkg-query -W systemd
systemd 234-2ubuntu12.1

From journal:
a.out[6763]: buffer contains: 69
a.out[6763]: about to read buffer again...

Is bad, since it is expected that MemoryDenyWriteExecute shall not allow the pkey_mprotect call, and one should not see the "about to read buffer again..." message.

Upgrading to:
$ dpkg-query -W systemd
systemd 234-2ubuntu12.3

Starting test.unit again, and journal now has:
a.out[17978]: buffer contains: 69
a.out[17978]: pkey_mprotect: Operation not permitted
systemd[1]: test.service: Main process exited, code=exited, status=1/FAILURE

Which is awesome =)

tags: added: verification-done verification-done-artful
removed: verification-needed verification-needed-artful
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package systemd - 234-2ubuntu12.3

systemd (234-2ubuntu12.3) artful; urgency=medium

  [ Dimitri John Ledkov ]
  * Fix test-functions failing with Ubuntu units. LP: #1750608
  * tests: switch to using ext4 by default, instead of ext3. LP: #1750608
  * Fix kdump service not starting, due to systemd not loading dropins.
    Cherrypick a fix from upstream. (LP: #1708409)
  * systemd-fsckd: Fix ADT tests to work on s390x too. (LP: #1736955)
  * netwokrd: add support for RequiredForOnline stanza. (LP: #1737570)
  * resolved.service: set DefaultDependencies=no (LP: #1734167)
  * systemd.postinst: enable persistent journal. (LP: #1618188)
  * core: add support for non-writable unified cgroup hierarchy for container support.
    Rebase and de-fuzz. (LP: #1734410)
  * Prevent MemoryDenyWriteExecution policy bypass, by disallowing pkey_mprotect when mprotect is disallowed.
    CVE-2017-15908 (LP: #1725348)
  * networkd: enable promote_secondaries on networkd managed dhcp links.
    This fixes failing to renew DHCP lease, on networkd managed devices.
    (LP: #1721223)

  [ Kleber Sacilotto de Souza ]
  * systemd-rfkill service times out when a new rfkill device is added
    - rfkill-fix-erroneous-behavior-when-polling-the-udev-.patch: Comparing
    udev_device_get_sysname(device) and sysname will always return true. We need to
    check the device received from udev monitor instead.
    - rfkill-fix-typo.patch: Fix typo in rfkill log message. (LP: #1734908)

 -- Dimitri John Ledkov <email address hidden> Tue, 20 Feb 2018 16:11:58 +0000

Changed in systemd (Ubuntu Artful):
status: Fix Committed → Fix Released

The verification of the Stable Release Update for systemd has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

To post a comment you must log in.
This report contains Public Security information  Edit
Everyone can see this security related information.

Other bug subscribers