#1104443 libtinfo6: library demands write+exec memory on loongarch64

Package:
libtinfo6
Source:
libtinfo6
Description:
shared low-level terminfo library for terminal handling
Submitter:
Russell Coker
Date:
2025-05-31 19:27:01 UTC
Severity:
normal
Tags:
#1104443#5
Date:
2025-04-30 10:22:36 UTC
From:
To:
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

#1104443#10
Date:
2025-05-31 19:14:13 UTC
From:
To:
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.  */

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.

#1104443#13
Date:
2025-05-31 19:14:13 UTC
From:
To:
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.  */

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.