<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>9532</bug_id>
          
          <creation_ts>2016-04-27 18:16:41 +0000</creation_ts>
          <short_desc>useradd / extrausers chain pseudo, causing stack overflows (segfaults) [s390]</short_desc>
          <delta_ts>2020-10-01 08:30:33 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>core</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>OBSOLETE</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard> </status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>Future</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Sascha Silbe">silbe</reporter>
          <assigned_to name="Unassigned">unassigned</assigned_to>
          <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>ross.burton</cc>
    
    <cc>seebs</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>New (Never tested)</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>61743</commentid>
    <comment_count>0</comment_count>
    <who name="Sascha Silbe">silbe</who>
    <bug_when>2016-04-27 18:16:41 +0000</bug_when>
    <thetext>Chaining pseudo instances will cause stack overflows (visible as segfaults) on s390x (and maybe other architectures). This is because the same symbols live both in the LD_PRELOAD&apos;ed shared library as well as in the executable and the linker will happily interleave invocations of non-static functions, leading to different copies of static variables having different values and the code just going wild. I haven&apos;t tried figuring out why this happens to work on x86_64. May be differences in linker behaviour or just luck.

The easiest fix is to teach the useradd and extrausers classes to only chain the commands with pseudo if they&apos;re not already running inside pseudo (by checking for PSEUDO_PREFIX before setting PSEUDO and allowing for PSEUDO to be empty by using the ${PSEUDO:-} syntax).

It may also be possible to fix pseudo itself to be structured and / or linked in a different way so that there&apos;s only a single instance of each symbol. I haven&apos;t tried going down that route.

Example error (while installing dbus):

=== Begin ===
DEBUG: SITE files [&apos;endian-big&apos;, &apos;bit-64&apos;, &apos;s390x-common&apos;, &apos;common-linux&apos;, &apos;common-glibc&apos;, &apos;s390x-linux&apos;, &apos;common&apos;]
DEBUG: Executing shell function useradd_sysroot
Running groupadd commands...
NOTE: dbus: Performing groupadd with [--root /home/silbe/poky/build-master/tmp/sysroots/qemus390x -r netdev]
Segmentation fault
WARNING: exit code 1 from a shell command.
ERROR: dbus: groupadd command did not succeed.
ERROR: Function failed: useradd_sysroot (log file is located at /home/silbe/poky/build-master/tmp/work/s390x-poky-linux/dbus/1.10.6-r0/temp/log.do_install.176717)
=== End ===</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61806</commentid>
    <comment_count>1</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2016-04-28 16:20:32 +0000</bug_when>
    <thetext>Peter: can pseudo be fixed to handle this behaviour on S390?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61811</commentid>
    <comment_count>2</comment_count>
    <who name="Seebs">seebs</who>
    <bug_when>2016-04-28 17:07:27 +0000</bug_when>
    <thetext>Interesting question. In theory, pseudo should be trying to detect that it&apos;s running under pseudo, and re-execing itself, but if it segfaults before that, it probably can&apos;t.

It looks like this can be reproduced without s390 hardware, with qemu? If so, I could try to reproduce it and fix it.

At the very least, we&apos;d almost certainly have to have the version that&apos;s fixed so that the client can spawn things correctly, or it&apos;d still blow up sooner or later anyway.

It&apos;s sort of surprising that the linker isn&apos;t consistent about which versions of things it picks, though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61815</commentid>
    <comment_count>3</comment_count>
    <who name="Sascha Silbe">silbe</who>
    <bug_when>2016-04-28 18:49:18 +0000</bug_when>
    <thetext>IIRC it segfaulted too early for some re-exec trick. (But it&apos;s been a rather lengthy and confusing debug session some time ago, so my memory could be incorrect).

In cause you&apos;re trying to reproduce it: This time around I used Debian Jessie. Might also have happened with some Fedora version, but I&apos;m not sure.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61832</commentid>
    <comment_count>4</comment_count>
    <who name="Seebs">seebs</who>
    <bug_when>2016-04-29 20:01:58 +0000</bug_when>
    <thetext>Do I need anything fancy set up to reproduce this, assuming I don&apos;t have an actual S390 machine?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61886</commentid>
    <comment_count>5</comment_count>
    <who name="Sascha Silbe">silbe</who>
    <bug_when>2016-05-03 10:55:06 +0000</bug_when>
    <thetext>You can request access to S390 hardware at https://developer.ibm.com/linuxone/ . I had some modifications for building images for S390 applied locally; will try building an x86_64 image with an unmodified poky version now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61887</commentid>
    <comment_count>6</comment_count>
    <who name="Sascha Silbe">silbe</who>
    <bug_when>2016-05-03 11:14:54 +0000</bug_when>
    <thetext>Building an x86_64 image on s390x with a pristine checkout fails, of course. Obvious in retrospect: First thing, bitbake builds a native toolchain. So to actually encounter this bug, you&apos;d need to add s390 support first... :-/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61939</commentid>
    <comment_count>7</comment_count>
    <who name="Sascha Silbe">silbe</who>
    <bug_when>2016-05-04 14:40:35 +0000</bug_when>
    <thetext>OK, got it reduced to a minimal set of changes for reproducing the
pseudo issue:

- meta/classes/siteinfo.bbclass: s390x is a big-endian 64-bit
  architecture. The GNU target triplet as output by config.guess is
  s390x-ibm-linux-gnu.

- meta/classes/kernel-arch.bbclass: the kernel uses ARCH=s390 for
  s390x. Linux used to support both 31/32-bit machines AKA s390 and
  64-bit machines AKA s390x via a config option, but nowadays only
  64-bit machines are supported.

- meta/recipes-connectivity/openssl/openssl.inc: OpenSSL uses target
  linux64-s390x for s390x

- meta/classes/uninative.bbclass: There&apos;s no uninative tarball yet for
  s390x and relocate_sdk.py seems to be broken for big-endian machines
  anyway, so uninative needs to be disabled for BUILD_ARCH=s390x.

After modifying the poky source using the above information, sourcing
oe-init-build-env once to create the default configuration and setting
MACHINE=x86_64 in build/conf/local.conf, the following invocation
reproduces the pseudo segfault:

( . ./oe-init-build-env build &amp;&amp; bitbake dbus )</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88283</commentid>
    <comment_count>8</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2020-10-01 08:30:33 +0000</bug_when>
    <thetext>Re=open if you are seeing this still. We don&apos;t have access to any s390 systems.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>