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 1759954 - systemd-cryptsetup dies due to memory corruption
Summary: systemd-cryptsetup dies due to memory corruption
Keywords:
Status: CLOSED DUPLICATE of bug 1752050
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: systemd
Version: ---
Hardware: All
OS: Linux
high
high
Target Milestone: rc
: 8.0
Assignee: systemd-maint
QA Contact: Frantisek Sumsal
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-10-09 13:29 UTC by Renaud Métrich
Modified: 2019-10-09 15:11 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-10-09 15:11:05 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Renaud Métrich 2019-10-09 13:29:05 UTC
Description of problem:

With Clevis/Tang, when executing multiple instances of systemd-cryptsetup to unlock a system (6 or 8 instances), systemd-cryptsetup can die with "malloc(): memory corruption" or "realloc(): invalid next size" glibc message.

This is due to zero'ing non allocated data in src/shared/ask-password-api.c:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
 63 static int retrieve_key(key_serial_t serial, char ***ret) {
 :
 70         for (;;) {
 71                 p = new(char, m);
 :
 75                 n = keyctl(KEYCTL_READ, (unsigned long) serial, (unsigned long) p, (unsigned long) m,     0);
 :
 82                 explicit_bzero(p, n);
 83                 free(p);
 84                 m *= 2;
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

On line 82, reached when the buffer "p" of size "m" is too small to contain the key ("n" bytes required), a zero'ing is done for "n" bytes long, instead of "m" bytes (size of the buffer).


Version-Release number of selected component (if applicable):

systemd-239-13.el8_0.5 + systemd from RHEL 8.1 beta

How reproducible:

Always with many Luks devices


Steps to Reproduce:
1. Install a VM with many Luks devices

  To do so, don't click on "Click here to create them automatically" in storage panel but directly on "+" button.
  This will create 1 LVM VG on /dev/vda2 + as many Luks devices as there are logical volumes.
  Split the system in many parts e.g. / /usr /tmp /home /var /var/log /var/log/audit swap
  Use "redhat" password for encryption.

2. Install Clevis+Tang and rebuild initramfs

  # yum -y install clevis-dracut
  # for i in $(seq 0 7); do clevis luks bind -f -k- -d /dev/rhel/0$i tang '{"url":"http://vm-tang7","thp":"txJOw9zhjTgEwcNnlRN-NGsv3hU"}' <<< "redhat"; done
  # dracut -f

3. Add all luks1 devices to kernel command line

  # awk '{ print "rd.luks.uuid="$1 }' /etc/crypttab
  rd.luks.uuid=luks-569a3783-4ec6-4bd0-a122-d6ca32ff8c23
  rd.luks.uuid=luks-ba80a2b3-dd86-4321-8a51-bf65a94c7c9c
  ...

  Edit /etc/default/grub to
  - add all devices to GRUB_CMDLINE_LINUX=
  - replace all "rd.lvm.lv" occurrences by a single "rd.lvm.vg=rhel" (rhel == VG)

  # grub2-mkconfig -o /etc/grub2.cfg
  
4. Reboot the system

Actual results:

dracut enters Emergency journalctl shows systemd-cryptsetup dying:

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
\x2d9e85\x2dd2af2e550912.service: Main process exited, code=dumped, status=6/ABRT
Oct 09 09:29:01 vm-clevis8-luksv1 systemd[1]: systemd-cryptsetup@luks\x2d4243c2be\x2dad56\x2d43ed\x2d9e85\x2dd2af2e550912.service: Failed with result 'core-dump'.
Oct 09 09:29:02 vm-clevis8-luksv1 systemd-cryptsetup[873]: malloc(): memory corruption
...
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Entering passphrase manually fails. System needs to be rebooted and Tang server disconnected.

Expected results:

Automatic unlocking

Comment 3 Renaud Métrich 2019-10-09 15:11:05 UTC

*** This bug has been marked as a duplicate of bug 1752050 ***


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