Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1463692

Summary: glibc: Incorrect pointer alignment in NSS group merge result construction
Product: Red Hat Enterprise Linux 7 Reporter: Florian Weimer <fweimer>
Component: glibcAssignee: DJ Delorie <dj>
Status: CLOSED ERRATA QA Contact: Sergey Kolosov <skolosov>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.5CC: ashankar, codonell, dj, fweimer, mcermak, mnewsome, pfrankli, skolosov
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: glibc-2.17-197.el7 Doc Type: Bug Fix
Doc Text:
Cause: Users with [SUCCESS=MERGE] in /etc/nsswitch.conf may see incorrectly merged group query results. On some platforms (s390x and powerpc64), it may (rarely) crash. Fix: glibc has been fixed to correctly merge group records. Result: Queries to merged group databases should return correctly merged records.
Story Points: ---
Clone Of:
: 1471985 (view as bug list) Environment:
Last Closed: 2018-04-10 14:00:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1471985    
Bug Blocks: 1473718    

Description Florian Weimer 2017-06-21 14:02:55 UTC
Sergey Kolosov discovered that the NSS group merge feature (added in bug 1298975) does not work on ppc64 and s390x.  The cause seems to be this code in grp/grp-merge.c:

  /* Copy the pointers from the members array into the buffer and assign them
     to the gr_mem member of destgrp.  */
  destgrp->gr_mem = (char **) &destbuf[c];
  len = sizeof (char *) * (memcount + 1);
  BUFCHECK (len);
  memcpy (&destbuf[c], members, len);
  c += len;
  free (members);
  members = NULL;

After the assigned to destgrp->gr_mem, we have:

(gdb) print destbuf
$1 = 0x10031000 "groupa"
(gdb) print c
$2 = 21
(gdb) print destgrp->gr_mem
$3 = (char **) 0x10031015

This pointer is not suitable aligned, and this triggers undefined behavior.

We should switch this code over to the allocation buffer interface, which deals with exactly this kind of problem.

Comment 1 Carlos O'Donell 2017-06-21 14:47:50 UTC
Correct, gr_mem is not sufficiently aligned at the start.

On pcc64 any * must be doubleword aligned (8 bytes).
On s390 any * must be word aligned (4 bytes).

These are just natural alignment rules.

Comment 2 Carlos O'Donell 2017-07-20 08:58:02 UTC
Absolutely needs to be fixed and is already fixed in upstream master:

commit f8cef4d07d9641e27629bd3ce2d13f5d702fb251
Author: DJ Delorie <dj>
Date:   Wed Jul 19 13:14:34 2017 -0400

    Fix cast-after-dereference
    
    Original code was dereferencing a char*, then casting the value
    to size_t.  Should cast the pointer to size_t* then deference.

commit 4fa8ae49aa169fb8d97882938e8bee3ed9ce5410
Author: DJ Delorie <dj>
Date:   Fri Jul 14 21:46:42 2017 -0400

    Fix BZ #21654 - grp-merge.c alignment
    
    * grp/grp_merge.c (__copy_grp): Align char** to minimum pointer
    alignment not char alignment.
    (__merge_grp): Likewise.

Comment 4 Florian Weimer 2017-10-02 14:43:58 UTC
Note that comment 2 shows the real fix, I think the alignment wasn't the actual cause of the bug.  We need all three commits, including:

commit 4fa8ae49aa169fb8d97882938e8bee3ed9ce5410
Author: DJ Delorie <dj>
Date:   Fri Jul 14 21:46:42 2017 -0400

    Fix BZ #21654 - grp-merge.c alignment
    
    * grp/grp_merge.c (__copy_grp): Align char** to minimum pointer
    alignment not char alignment.
    (__merge_grp): Likewise.

Comment 8 errata-xmlrpc 2018-04-10 14:00:52 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:0805