Bug 1562125

Summary: "setarch ppc<*>" fails with "Unrecognized architecture"
Product: Red Hat Enterprise Linux 7 Reporter: Renaud Métrich <rmetrich>
Component: util-linuxAssignee: Karel Zak <kzak>
Status: CLOSED ERRATA QA Contact: Radka Brychtova <rskvaril>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.4CC: fsumsal, jcm, ovasik, rskvaril
Target Milestone: rc   
Target Release: ---   
Hardware: ppc64le   
OS: Linux   
Whiteboard:
Fixed In Version: util-linux-2.23.2-57.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 10:52:39 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:    
Bug Blocks: 1546552    

Description Renaud Métrich 2018-03-29 15:01:17 UTC
Description of problem:

On a ppc64le system, trying to change the personality using "setarch ppc<*>" fails with "Unrecognized architecture", e.g.:

# uname -m
ppc64le
# setarch ppc32 uname -m
setarch: ppc32: Unrecognized architecture

Using "linux32" works:

# setarch linux32 uname -m
ppcle


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

util-linux-2.23.2-43.el7_4.2.ppc64le


How reproducible:

Always


Additional info:

Running under gdb, we can see the code is working as expected, until "uname(&un)" is reached (line 218), then some "rollback" occurs (error printed on line 212).

# gdb --args /usr/bin/setarch ppc32 uname -m
(gdb) break set_arch
Breakpoint 1 at 0x10001ae8: file sys-utils/setarch.c, line 140.
(gdb) run
Starting program: /usr/bin/setarch ppc32 uname -m

Breakpoint 1, 0x0000000010001ae8 in set_arch (pers=0x3ffffffff3ca "ppc32", options=0, list=0)
    at sys-utils/setarch.c:140
140	{
(gdb) next
148	  } transitions[] = {
(gdb) 
140	{
(gdb) 
148	  } transitions[] = {
(gdb) 
140	{
(gdb) 
148	  } transitions[] = {
(gdb) 
140	{
(gdb) 
148	  } transitions[] = {
(gdb) 
201	  if (list) {
(gdb) 
207	  for(i = 0; transitions[i].perval >= 0; i++)
(gdb) 
208	      if(!strcmp(pers, transitions[i].target_arch))
(gdb) 
207	  for(i = 0; transitions[i].perval >= 0; i++)
(gdb) 
208	      if(!strcmp(pers, transitions[i].target_arch))
(gdb) 
207	  for(i = 0; transitions[i].perval >= 0; i++)
(gdb) 
208	      if(!strcmp(pers, transitions[i].target_arch))
(gdb) 
215	  if (set_pers(pers_value) == -EINVAL)
(gdb) 
218	  uname(&un);
(gdb) 
219	  if(transitions[i].result_arch &&
(gdb) p un
$1 = {sysname = "Linux", '\000' <repeats 59 times>, 
  nodename = "ibm-p8-02-lp1.rhts.eng.bos.redhat.com", '\000' <repeats 27 times>, 
  release = "3.10.0-693.21.1.el7.ppc64le", '\000' <repeats 37 times>, 
  version = "#1 SMP Fri Feb 23 14:02:56 EST 2018", '\000' <repeats 29 times>, 
  machine = "ppcle", '\000' <repeats 59 times>, domainname = "(none)", '\000' <repeats 58 times>}
(gdb) next
220		strcmp(un.machine, transitions[i].result_arch))
(gdb) 
219	  if(transitions[i].result_arch &&
(gdb) 
222	    if(strcmp(transitions[i].result_arch, "i386")
(gdb) 
212	    errx(EXIT_FAILURE, _("%s: Unrecognized architecture"), pers);
(gdb) 
setarch: ppc32: Unrecognized architecture
[Inferior 1 (process 10531) exited with code 01]

Comment 2 Renaud Métrich 2018-03-29 15:13:46 UTC
Got it.

After changing personality (line 215), there is a comparison made between "un.machine" and "transitions[i].result_arch", with following values:

- un.machine == "ppcle"
- transitions[i].result_arch == "ppc"

This makes the code fail on line 227 which has been optimized (so showing as line 212).

Comment 3 Karel Zak 2018-04-03 08:52:53 UTC
Probably already fixed in upstream (and Fedora) tree:

commit 95bf26fd68ec7f0b2dde1f022dc79d04d1a6e620

Comment 9 errata-xmlrpc 2018-10-30 10:52:39 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:3178