Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.

Bug 1261738

Summary: xdrstdio_create buffers do not output encoded values on ppc
Product: Red Hat Enterprise Linux 7 Reporter: Murphy Zhou <xzhou>
Component: libtirpcAssignee: Steve Dickson <steved>
Status: CLOSED ERRATA QA Contact: Zhi Li <yieli>
Severity: high Docs Contact:
Priority: unspecified    
Version: 7.2CC: dnsands, fs-qe, michael.meseke, rjones, steved, tgummels, woodard, xzhou
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: ppc64   
OS: Linux   
Whiteboard:
Fixed In Version: libtirpc-0.2.4-0.12.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1261596 Environment:
Last Closed: 2018-10-30 11:48:24 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: 1261596    
Bug Blocks: 910269, 1585558    
Attachments:
Description Flags
Fix for STDIO none

Comment 2 Daniel Sands 2018-02-14 23:31:13 UTC
I have also encountered this bug.  It exists on PPC64.  The cause is that the xdr_putlong uses a long to store the converted value, then passes it to fwrite as a byte buffer.  Only the first 4 bytes are written, which is okay for a LE system after byteswapping, but writes all zeroes on BE systems.

in xdr_stdio.c:
115	xdrstdio_putlong(xdrs, lp)
116		XDR *xdrs;
117		const long *lp;
118	{
119		long mycopy = (long)htonl((u_int32_t)*lp);
120	
121		if (fwrite(&mycopy, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1)
122			return (FALSE);
123		return (TRUE);
124	}

It seems incorrect to make "mycopy" a long instead of a u_int32_t, especially considering the result on BE systems.

Comment 3 Daniel Sands 2018-02-15 00:53:32 UTC
Created attachment 1396217 [details]
Fix for STDIO

Comment 4 Steve Dickson 2018-06-22 12:32:07 UTC
I'm not seeing this problem... 

ibm-p730-06-lp2$ arch
ppc64

ibm-p730-06-lp2$ rpm -q libtirpc-devel
libtirpc-devel-0.2.4-0.10.el7.ppc64

ibm-p730-06-lp2$ gcc -I/usr/include/tirpc reader.c -o reader-tirpc -ltirpc
ibm-p730-06-lp2$ gcc -I/usr/include/tirpc writer.c -o writer-tirpc -ltirpc

ibm-p730-06-lp2$ ./writer-tirpc | ./reader-tirpc
0 1 2 3 4 5 6 7 

ibm-p730-06-lp2$ ./writer | hexdump
0000000 0000 0000 0000 0000 0000 0000 0000 0001
0000010 0000 0000 0000 0002 0000 0000 0000 0003
0000020 0000 0000 0000 0004 0000 0000 0000 0005
0000030 0000 0000 0000 0006 0000 0000 0000 0007
0000040
ibm-p730-06-lp2$ ./writer-tirpc | hexdump
0000000 0000 0000 0000 0000 0000 0000 0000 0001
0000010 0000 0000 0000 0002 0000 0000 0000 0003
0000020 0000 0000 0000 0004 0000 0000 0000 0005
0000030 0000 0000 0000 0006 0000 0000 0000 0007
0000040

Comment 6 Daniel Sands 2018-06-22 20:44:54 UTC
Endianness makes the difference.  The code as is passes on LE systems, but fails on BE systems.

As explained above, it writes 4 bytes into an 8-byte temporary variable, then uses the pointer to the first 4 bytes in its write.  On LE systems, the first 4 bytes have the converted value.  On BE systems, the last 4 bytes have it and the first 4 are all zeroes.

Comment 7 Steve Dickson 2018-07-18 18:38:47 UTC
commit 145272c2b6d89a1c3a7de86a2cbef43880f1b61b
Author: Steve Dickson <steved>
Date:   Wed Jul 11 11:21:39 2018 -0400

    xdrstdio_create buffers do not output encoded values on ppc

Comment 9 Richard W.M. Jones 2018-07-24 15:55:10 UTC
*** Bug 1585658 has been marked as a duplicate of this bug. ***

Comment 10 Zhi Li 2018-07-25 02:53:00 UTC
Verified with libtirpc-0.2.4-0.12.el7.ppc64:
~~~~~
[root@xxx]# uname -m
ppc64
[root@xxx]# rpm -q libtirpc
libtirpc-0.2.4-0.10.el7.ppc64
[root@xxx]# ./writer | ./reader
0 1 2 3 4 5 6 7 
>>>> [root@xxx]# ./writer-tirpc  | ./reader-tirpc
2942232856 2942232856 2942232856 2942232856 2942232856 2942232856 2942232856 2942232856 
>>>> [root@xxx]# ./writer-tirpc-header  | ./reader-tirpc-header
2318854424 2318854424 2318854424 2318854424 2318854424 2318854424 2318854424 2318854424 
[root@ibm-p730-06-lp4 ~]# rpm -e --nodeps libtirpc
[root@ibm-p730-06-lp4 ~]# rpm -q libtirpc
package libtirpc is not installed

###############
update libtirpc
###############
[root@xxx]# yum install libtirpc-0.2.4-0.12.el7.ppc64.rpm
....
<snip>
Installed:
  libtirpc.ppc64 0:0.2.4-0.12.el7                                                                                                                                                        
Complete!
[root@xxx]# rpm -q libtirpc
libtirpc-0.2.4-0.12.el7.ppc64
[root@xxx]# ./writer | ./reader
0 1 2 3 4 5 6 7 
>>>> [root@xxx]# ./writer-tirpc  | ./reader-tirpc
0 1 2 3 4 5 6 7 
>>>> [root@xxx]# ./writer-tirpc-header  | ./reader-tirpc-header
0 1 2 3 4 5 6 7

Comment 11 Zhi Li 2018-07-25 02:53:50 UTC
Moving to VERIFIED according to comment #10.

Comment 13 errata-xmlrpc 2018-10-30 11:48:24 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/RHBA-2018:3312