Bug 2091553

Summary: glibc: Incorrect results of POWER9-optimized strncpy [rhel-8.7.0]
Product: Red Hat Enterprise Linux 8 Reporter: Florian Weimer <fweimer>
Component: glibcAssignee: DJ Delorie <dj>
Status: CLOSED ERRATA QA Contact: Martin Coufal <mcoufal>
Severity: medium Docs Contact: mtimar
Priority: unspecified    
Version: 8.7CC: ashankar, codonell, dj, fweimer, glibc-bugzilla, mcoufal, mnewsome, mscastanho, mtimar, pfrankli, sipoyare, skolosov, tulioqm
Target Milestone: rcKeywords: Bugfix, Triaged, ZStream
Target Release: ---Flags: pm-rhel: mirror+
Hardware: ppc64le   
OS: All   
Whiteboard:
Fixed In Version: glibc-2.28-205.el8 Doc Type: Bug Fix
Doc Text:
.POWER9-optimized strncpy function no longer gives incorrect results Previously, the POWER9 strncpy function did not use the correct register as the source of the NUL bytes for padding. Consequently, the output buffer contained uninitialized register content instead of the NUL padding. With this update, the strncpy function has been fixed, and the end of the output buffer is now correctly padded with NUL bytes.
Story Points: ---
Clone Of: 2091549
: 2094540 (view as bug list) Environment:
Last Closed: 2022-11-08 10:43:12 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: 2091549    
Bug Blocks: 2094540    

Description Florian Weimer 2022-05-30 10:05:33 UTC
+++ This bug was initially created as a clone of Bug #2091549 +++

Zdenek Sojka reported that strncpy does not always clear the destination buffer. The upstream bug gives the following reproducer:

#include <string.h>
#include <stdlib.h>

#define N 3
char a[N];
char c[N];

int
main (void)
{
  __asm__ volatile ("xxspltib 18, 0xf":::"vs18");
  strncpy (c, a, N);
  for (unsigned i = 0; i < N; i++)
    if (c[i])
      abort ();
  return 0;
}

Comment 8 Matheus Castanho 2022-06-08 14:36:21 UTC
The fix has been applied upstream for glibc 2.36 and has been backported to all affected versions (glibc >= 2.33).

Commit for glibc 2.36:
https://sourceware.org/git/?p=glibc.git;a=commit;h=0218463dd8265ed937622f88ac68c7d984fe0cfc

Commit for glibc 2.33:
https://sourceware.org/git/?p=glibc.git;a=commit;h=82c7441f04e3c2a653ee29672731e040a1799c6b

Comment 14 errata-xmlrpc 2022-11-08 10:43:12 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 (glibc bug fix and enhancement update), 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/RHBA-2022:7684