• Bug#1104443: libtinfo6: library demands write+exec memory on loongarch6

    From Russell Coker@21:1/5 to All on Wed Apr 30 12:30:01 2025
    Package: libtinfo6
    Version: 6.5+20250216-2
    Severity: normal
    X-Debbugs-Cc: debian-loongarch@lists.debian.org
    User: debian-loongarch@lists.debian.org
    Usertags: loong64

    root@koneko:~# awk
    awk: error while loading shared libraries: cannot make segment writable for relocation: Permission denied

    When running SE Linux in enforcing mode on a loong64 system I get the
    above when trying to run awk. Below is the strace output that indicates
    that this library is doing it:

    openat(AT_FDCWD, "/lib/loongarch64-linux-gnu/libtinfo.so.6", O_RDONLY|O_CLOEXEC) = 3
    read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\2\1\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
    statx(3, "", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH, STATX_BASIC_STATS, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=265360, ...}) = 0
    mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffff3108000
    mmap(NULL, 395472, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_DENYWRITE, -1, 0) = 0x7ffff2c2c000
    mmap(0x7ffff2c30000, 329936, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0) = 0x7ffff2c30000
    munmap(0x7ffff2c2c000, 16384) = 0
    munmap(0x7ffff2c84000, 35024) = 0
    mprotect(0x7ffff2c64000, 98304, PROT_NONE) = 0
    mmap(0x7ffff2c7c000, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3c000) = 0x7ffff2c7c000
    close(3) = 0
    set_tid_address(0x7ffff3109450) = 8563
    set_robust_list(0x7ffff3109460, 24) = 0
    rseq(0x7ffff3109ec0, 0x20, 0, 0x2a0010) = 0
    mprotect(0x7ffff2e4c000, 16384, PROT_READ) = 0
    mprotect(0x7ffff2c7c000, 16384, PROT_READ) = 0
    mprotect(0x7ffff2f1c000, 16384, PROT_READ) = 0
    mprotect(0x7ffff2fc8000, 16384, PROT_READ) = 0
    mprotect(0x7ffff307c000, 16384, PROT_READ) = 0
    mprotect(0x7ffff30fc000, 16384, PROT_READ) = 0
    mprotect(0x7ffff3160000, 16384, PROT_READ) = 0
    mprotect(0x120000000, 737280, PROT_READ|PROT_WRITE|PROT_EXEC) = -1 EACCES (Permission denied)
    writev(2, [{iov_base="/usr/bin/awk", iov_len=12}, {iov_base=": ", iov_len=2}, {iov_base="error while loading shared libra"..., iov_len=36}, {iov_base=": ", iov_len=2}, {iov_base="", iov_len=0}, {iov_base="", iov_len=0}, {iov_base="cannot make segment
    writable for"..., iov_len=43}, {iov_base=": ", iov_len=2}, {iov_base="Permission denied", iov_len=17}, {iov_base="\n", iov_len=1}], 10/usr/bin/awk: error while loading shared libraries: cannot make segment writable for relocation: Permission denied


    -- System Information:
    Debian Release: trixie/sid
    Architecture: loong64 (loongarch64)

    Kernel: Linux 6.12.25-loong64 (SMP w/4 CPU threads)
    Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
    Shell: /bin/sh linked to /usr/bin/dash
    Init: unable to detect

    Versions of packages libtinfo6 depends on:
    ii libc6 2.41-7

    libtinfo6 recommends no packages.

    libtinfo6 suggests no packages.

    -- debconf-show failed

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas Dickey@21:1/5 to Russell Coker on Sat May 31 21:30:02 2025
    On Wed, Apr 30, 2025 at 06:22:36AM -0400, Russell Coker wrote:
    Package: libtinfo6
    Version: 6.5+20250216-2
    Severity: normal
    X-Debbugs-Cc: debian-loongarch@lists.debian.org
    User: debian-loongarch@lists.debian.org
    Usertags: loong64

    root@koneko:~# awk
    awk: error while loading shared libraries: cannot make segment writable for relocation: Permission denied

    I see this for discussion on that error message:

    https://forums.gentoo.org/viewtopic-p-8768758.html?sid=9d73cf3cc10c865d0099c2bc3f60f29a

    which quotes some code from the loader:

    /* Bletch. We must make read-only segments writable
    long enough to relocate them. */

    When running SE Linux in enforcing mode on a loong64 system I get the
    above when trying to run awk. Below is the strace output that indicates
    that this library is doing it:

    tinfo isn't loading something
    (g)awk is loading something.

    gawk loads readline, which wants tinfo (as in the discussion, use readelf
    to get useful information to support this report).

    I'd expect the problem is between either gawk/readline, or readline/tinfo. Since more application use the latter (i.e., bash), I'd suspect the former.

    openat(AT_FDCWD, "/lib/loongarch64-linux-gnu/libtinfo.so.6", O_RDONLY|O_CLOEXEC) = 3
    read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\2\1\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
    statx(3, "", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH, STATX_BASIC_STATS, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=265360, ...}) = 0
    mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffff3108000
    mmap(NULL, 395472, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_DENYWRITE, -1, 0) = 0x7ffff2c2c000
    mmap(0x7ffff2c30000, 329936, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0) = 0x7ffff2c30000
    munmap(0x7ffff2c2c000, 16384) = 0
    munmap(0x7ffff2c84000, 35024) = 0
    mprotect(0x7ffff2c64000, 98304, PROT_NONE) = 0
    mmap(0x7ffff2c7c000, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3c000) = 0x7ffff2c7c000
    close(3) = 0
    set_tid_address(0x7ffff3109450) = 8563 set_robust_list(0x7ffff3109460, 24) = 0
    rseq(0x7ffff3109ec0, 0x20, 0, 0x2a0010) = 0
    mprotect(0x7ffff2e4c000, 16384, PROT_READ) = 0
    mprotect(0x7ffff2c7c000, 16384, PROT_READ) = 0
    mprotect(0x7ffff2f1c000, 16384, PROT_READ) = 0
    mprotect(0x7ffff2fc8000, 16384, PROT_READ) = 0
    mprotect(0x7ffff307c000, 16384, PROT_READ) = 0
    mprotect(0x7ffff30fc000, 16384, PROT_READ) = 0
    mprotect(0x7ffff3160000, 16384, PROT_READ) = 0
    mprotect(0x120000000, 737280, PROT_READ|PROT_WRITE|PROT_EXEC) = -1 EACCES (Permission denied)
    writev(2, [{iov_base="/usr/bin/awk", iov_len=12}, {iov_base=": ", iov_len=2}, {iov_base="error while loading shared libra"..., iov_len=36}, {iov_base=": ", iov_len=2}, {iov_base="", iov_len=0}, {iov_base="", iov_len=0}, {iov_base="cannot make segment
    writable for"..., iov_len=43}, {iov_base=": ", iov_len=2}, {iov_base="Permission denied", iov_len=17}, {iov_base="\n", iov_len=1}], 10/usr/bin/awk: error while loading shared libraries: cannot make segment writable for relocation: Permission denied


    -- System Information:
    Debian Release: trixie/sid
    Architecture: loong64 (loongarch64)

    Kernel: Linux 6.12.25-loong64 (SMP w/4 CPU threads)
    Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
    Shell: /bin/sh linked to /usr/bin/dash
    Init: unable to detect

    Versions of packages libtinfo6 depends on:
    ii libc6 2.41-7

    libtinfo6 recommends no packages.

    libtinfo6 suggests no packages.

    -- debconf-show failed




    --
    Thomas E. Dickey <dickey@invisible-island.net>
    https://invisible-island.net

    -----BEGIN PGP SIGNATURE-----

    iQGzBAABCgAdFiEEGYgtkt2kxADCLA1WzCr0RyFnvgMFAmg7VQIACgkQzCr0RyFn vgNetQv/dIHqujWRoUgLZUP4065tcJkMMhTUe/GZBPNJpibvjIUJqcyr20LgSL7C 3z4Zb+WlsTdnl6kuFMl3ilQ1vuWuXXOvf95ZQ7OL2ggvzPbZCeFjesr/DytjZkFS RzshgyQlPB1v/SlVbKArrG3/6Fgu+uD+llnBGmYsRIJQGzxTUWhm7ymFGQC9Cd9h TxDf6EKymO8aN6QbRm+g3BIsp30CXCrtGj6x8PKL1w/4zb7km0IAhToio/JQMBAj 57cs8vtu2jMTOlJkXBcoN/liP48SMF7hXWZMEt2ZOgn6lhMfGkoyiwXtULIRBtMh g0WoWwJwL2uwbahToPzHFd8ffUeYETjtNMiIlConKGN9soOO2InZMByB2/J8AcVI g/BH3ZtgET0V5uRRU0bfI+626QlWXOUxk8z6RVXMSJaXIbZ0l2woG9F/nWV7/jyK NJClC/anUz7EBGNnFNdPS1ERiPOVHBgiA/ABhmlK1SVDWaYRkkPlMwz9+Eea6ssa
    PMSBUaJN
    =r/C7
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)