** Description changed:

+ SRU Justification:
+ 
+ [ Impact ]
+ 
+  * On s390x, iconv conversions to 8-bit EBCDIC charsets (IBM1047, IBM037
+    and similar) can segfault in __to_generic_vx: R_TMP is declared as a
+    plain output ("=d") without early-clobber, so the compiler may allocate
+    the same register as an input (R_BUF), and the "vst" to the buffer then
+    stores to address 0x0. Any conversion of 16+ characters to an affected
+    charset crashes the converting process — hard crash of applications
+    processing EBCDIC data on IBM Z.
+ 
+  * The crash is confirmed for -O1 builds (upstream reproducer); Ubuntu
+    stock builds use -O2 where the collision currently does not occur —
+    that is luck, not a guarantee; whether it can happen at other levels
+    is unknown. The fix is a minimal one-line early-clobber mark
+    ("=d" -> "=&d"), cherry-picked from upstream commit ff45d05f
+    ("s390: Fix missing early-clobber in __to_generic_vx [BZ #34952]").
+ 
+ [ Test Plan ]
+ 
+  * On s390x, per series, enable -proposed and install the update
+    (example for noble; replace suite name for resolute/stonking):
+ 
+      $ cat << EOF | sudo tee /etc/apt/sources.list.d/proposed.sources
+      Types: deb
+      URIs: http://ports.ubuntu.com/ubuntu-ports
+      Suites: noble-proposed
+      Components: main restricted universe multiverse
+      Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
+      EOF
+      $ sudo apt update
+      $ sudo apt install -t noble-proposed libc6 libc-bin 
libc-gconv-modules-extra
+      $ apt policy libc6
+        Installed: 2.39-0ubuntu8.13
+ 
+  * Convert 16 characters to IBM1047 (upstream reproducer input) — must
+    exit 0 with 16 × 0xc1, no crash:
+ 
+      $ head -c16 /dev/zero | tr '\0' A | iconv -f UTF-8 -t IBM1047 | od -An 
-tx1
+       c1 c1 c1 c1 c1 c1 c1 c1 c1 c1 c1 c1 c1 c1 c1 c1
+ 
+  * Convert a longer input (100+ characters) to IBM1047 and IBM037 — must
+    convert losslessly:
+ 
+      $ head -c100 /dev/zero | tr '\0' A | iconv -f UTF-8 -t IBM1047 | wc -c
+      100
+      $ head -c100 /dev/zero | tr '\0' A | iconv -f UTF-8 -t IBM037 | wc -c
+      100
+ 
+  * UTF-8 <-> IBM1047 roundtrip must be byte-exact:
+ 
+      $ printf "Hello EBCDIC world 123" | iconv -f UTF-8 -t IBM1047 | iconv -f 
IBM1047 -t UTF-8
+      Hello EBCDIC world 123
+ 
+  * Note: the crash itself only manifests on glibc built with -O1; the
+    stock -O2 binaries of the affected versions do not crash before or
+    after the update, so the source-level fix is verified via the
+    conversion checks above (executed on real z Systems s390x hardware for
+    the tenacious build) plus the package build tests below.
+ 
+  * The full upstream glibc test suite (incl. iconv/tst-iconv1-4) is
+    executed during package build; the PPA test builds completed
+    successfully on all supported architectures.
+ 
+ [ Where problems could occur ]
+ 
+  * The change forces a dedicated register for R_TMP in __to_generic_vx.
+    Any regression would show up exclusively in iconv conversions using
+    the 8-bit generic modules on s390x (IBM037/IBM1047 & similar): wrong
+    conversion results or crashes of the converting process.
+ 
+  * A wrongly placed early-clobber could degrade register allocation in
+    that asm block (performance) — the patch is upstream-reviewed
+    (Reviewed-by: Stefan Liebler, s390 glibc maintainer) and identical in
+    all four backports.
+ 
+  * No regressions expected outside s390x: the changed file is
+    s390-specific (sysdeps/s390/multiarch/); no ABI, soname or symbol
+    changes; build logs of the other architectures show no difference to
+    the previous package versions.
+ 
+ [ Other Info ]
+ 
+  * Upstream bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34952
+    Upstream fix: commit ff45d05f
+    
https://sourceware.org/git/?p=glibc.git;a=commit;h=ff45d05f8b0f3c8f576b2d3992263aad06488d40
+    (Author: Florian Fuchs <[email protected]>, committed by Stefan Liebler)
+ 
+  * Backported as d/p/s390x-8bit-generic-early-clobber.patch (DEP-3):
+      tenacious (27.04, devel):  2.44-1ubuntu3     -> 2.44-1ubuntu4
+      stonking (26.10):          2.44-1ubuntu2.1    -> 2.44-1ubuntu2.2
+      resolute (26.04):          2.43-2ubuntu2.7    -> 2.43-2ubuntu2.8
+      noble (24.04):             2.39-0ubuntu8.12   -> 2.39-0ubuntu8.13
+    Per-series debdiffs are attached to this bug.
+ 
+  * PPA test builds: https://launchpad.net/~fheimes/+archive/ubuntu/lp2176181
+    Test suite is executed during build time.
+ 
+  * Originally reported via IBM LTC (bugnameltc-225890), title prefixed
+    "[UBUNTU 24.04]" for the noble target; the same defect exists in all
+    in-service releases (verified per release source); fixed dev-release
+    first, then newest -> oldest.
+ 
+ __________
+ 
  ---Problem Description---
  
  On s390x, the iconv modules based on sysdeps/s390/multiarch/8bit-
  generic.c like IBM1047.so may segfault in __to_generic_vx. There the
  inline assembly declares R_TMP as plain output ("=d") without an early-
  clobber, so the compiler may give it the same register as one of the
  inputs. This is currently seen if glibc is build with -O1, but there is
  no reason why it cannot happen with -O2/-O3/-Os (here it is just luck).
  In this case, writing to the buffer with vst leads to writing to address
  0x0 which segfaults.
  
  Reproducer, when glibc built with -O1:
  head -c16 /dev/zero | tr '\0' A | iconv -f UTF-8 -t IBM1047
  
  See also upstream glibc bugzilla:
  "Bug 34952 - s390x: ICE at -O1 caused by iconv segfault in __to_generic_vx"
  https://sourceware.org/bugzilla/show_bug.cgi?id=34952
  
  and upstream glibc commit which marks R_TMP as early-clobber ("=&d"):
  "s390: Fix missing early-clobber in __to_generic_vx [BZ #34952]"
  
https://sourceware.org/git/?p=glibc.git;a=commit;h=ff45d05f8b0f3c8f576b2d3992263aad06488d40

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2176181

Title:
  [UBUNTU 24.04] glibc: s390x: segfault in 8bit-generic.c iconv modules
  like IBM1047

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu-z-systems/+bug/2176181/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to