Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 667926 - sys-apps/sandbox: ISE:do_peekstr:process_vm_readv(...) while building sys-libs/ncurses-6.1-r2 (Segmentation fault tic -x -s -o /var/tmp/portage/sys-libs/ncurses-6.1-r2/image//usr/share/terminfo terminfo.tmp)
Summary: sys-apps/sandbox: ISE:do_peekstr:process_vm_readv(...) while building sys-lib...
Status: UNCONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Sandbox (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Sandbox Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-07 00:59 UTC by Gary G. Sparkes Jr.
Modified: 2022-12-17 14:03 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge -pqv (emerge.pqv,168 bytes, text/plain)
2018-10-07 00:59 UTC, Gary G. Sparkes Jr.
Details
emerge --info (emerge.info,4.53 KB, text/plain)
2018-10-07 01:00 UTC, Gary G. Sparkes Jr.
Details
environment file from work dir (environment,108.43 KB, text/plain)
2018-10-07 01:00 UTC, Gary G. Sparkes Jr.
Details
compressed build.log file (build.zip,127.75 KB, application/x-zip-compressed)
2018-10-07 01:04 UTC, Gary G. Sparkes Jr.
Details
Dockerfile for a basic stage3 system for reproduction (Dockerfile,441 bytes, text/plain)
2022-03-14 18:08 UTC, Kobboi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gary G. Sparkes Jr. 2018-10-07 00:59:17 UTC
When running emerge --update --newuse --deep --quiet @world I receive a segmentation fault during the building of ncurses-6.1-r2


/bin/bash ./run_tic.sh
** Building terminfo database, please wait...
installing form.pc
Running sh /var/tmp/portage/sys-libs/ncurses-6.1-r2/work/ncurses-6.1/misc/shlib tic to install /var/tmp/portage/sys-libs/ncurses-6.1-r2/image//usr/share/terminfo ...

	You may see messages regarding extended capabilities, e.g., AX.
	These are extended terminal capabilities which are compiled
	using
		tic -x
	If you have ncurses 4.2 applications, you should read the INSTALL
	document, and install the terminfo without the -x option.

installing menu.pc
/var/tmp/portage/sys-libs/ncurses-6.1-r2/work/ncurses-6.1/misc/shlib: line 141: 24525 Segmentation fault      tic -x -s -o /var/tmp/portage/sys-libs/ncurses-6.1-r2/image//usr/share/terminfo terminfo.tmp
? tic could not build /var/tmp/portage/sys-libs/ncurses-6.1-r2/image//usr/share/terminfo
make[1]: *** [Makefile:89: install.data] Error 1
make[1]: *** Waiting for unfinished jobs....
installing ncurses++.pc
installing ncurses.pc
installing panel.pc
make[1]: Leaving directory '/var/tmp/portage/sys-libs/ncurses-6.1-r2/work/ncurses-6.1-abi_x86_64.amd64/ncurses/misc'
make: *** [Makefile:120: install] Error 2
make: Leaving directory '/var/tmp/portage/sys-libs/ncurses-6.1-r2/work/ncurses-6.1-abi_x86_64.amd64/ncurses'
 * ERROR: sys-libs/ncurses-6.1-r2::gentoo failed (install phase):
 *   emake failed
 *
Comment 1 Gary G. Sparkes Jr. 2018-10-07 00:59:47 UTC
Created attachment 549538 [details]
emerge -pqv
Comment 2 Gary G. Sparkes Jr. 2018-10-07 01:00:28 UTC
Created attachment 549540 [details]
emerge --info
Comment 3 Gary G. Sparkes Jr. 2018-10-07 01:00:44 UTC
Created attachment 549542 [details]
environment file from work dir
Comment 4 Gary G. Sparkes Jr. 2018-10-07 01:04:00 UTC
Created attachment 549544 [details]
compressed build.log file
Comment 5 Kobboi 2021-12-21 23:08:50 UTC
I am running into a similar issue. I am running in a docker container

[00:04:54] ** Building terminfo database, please wait...
[00:04:54] Running /var/tmp/portage/sys-libs/ncurses-6.3_p20211106/work/cross/progs/tic to install /var/tmp/portage/sys-libs/ncurses-6.3_p20211106/image/usr/share/terminfo ...
[00:04:54] 
[00:04:54] You may see messages regarding extended capabilities, e.g., AX.
[00:04:54] These are extended terminal capabilities which are compiled
[00:04:54] using
[00:04:54] tic -x
[00:04:54] If you have ncurses 4.2 applications, you should read the INSTALL
[00:04:54] document, and install the terminfo without the -x option.
[00:04:54] 
[00:04:54] ncurses 6.3.20211106
[00:04:54] * /var/tmp/portage/sys-apps/sandbox-2.25/work/sandbox-2.25/libsandbox/trace.c:do_peekstr():134: failure (Operation not permitted):
[00:04:54] * ISE:do_peekstr:process_vm_readv(85407, 0x00007ffde94fb5e0{0x00007f24898f7010, 0xc12}, 1, 0x00007ffde94fb5f0{0x00007ffe77e5e3ee, 0xc12}, 1, 0) failed: Operation not permitted
[00:04:54] ./run_tic.sh: line 176: 85406 Aborted                 (core dumped) ( $TIC_PATH -x -s -o "$TERMINFO" $source )
[00:04:54] ? tic could not build /var/tmp/portage/sys-libs/ncurses-6.3_p20211106/image/usr/share/terminfo
Comment 6 Kobboi 2021-12-21 23:14:53 UTC
Currently running emerge in the container with FEATURES="-ipc-sandbox -network-sandbox -pid-sandbox". Any FEATURE I am missing here? AFAIK, this used to be sufficient (last check does date from a couple of months ago)
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-12-22 04:19:32 UTC
(In reply to Kobboi from comment #6)
> Currently running emerge in the container with FEATURES="-ipc-sandbox
> -network-sandbox -pid-sandbox". Any FEATURE I am missing here? AFAIK, this
> used to be sufficient (last check does date from a couple of months ago)

sandbox version?

I've noticed some changes here too. Normally this kind of thing has happened with QEMU but not Docker (QEMU had issues sometimes more with sandbox/usersandbox, but Docker "always" just needed the network/ipc bits off, AFIAK).

(Similar report from a while ago on forums: https://forums.gentoo.org/viewtopic-t-1107794.html).

Could you upload the full build.log & emerge --info? Also any sandbox logs although I don't think it would've written one here.

CCing sandbox@.
Comment 8 Kobboi 2021-12-30 11:28:43 UTC
(In reply to Sam James from comment #7)
> (In reply to Kobboi from comment #6)
> > Currently running emerge in the container with FEATURES="-ipc-sandbox
> > -network-sandbox -pid-sandbox". Any FEATURE I am missing here? AFAIK, this
> > used to be sufficient (last check does date from a couple of months ago)
> 
> sandbox version?
> 
> I've noticed some changes here too. Normally this kind of thing has happened
> with QEMU but not Docker (QEMU had issues sometimes more with
> sandbox/usersandbox, but Docker "always" just needed the network/ipc bits
> off, AFIAK).
> 
> (Similar report from a while ago on forums:
> https://forums.gentoo.org/viewtopic-t-1107794.html).
> 
> Could you upload the full build.log & emerge --info? Also any sandbox logs
> although I don't think it would've written one here.
> 
> CCing sandbox@.

I will try to isolate the problem scenario better. Will get back to you on this.
Comment 9 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-03-13 02:48:04 UTC
>* /var/tmp/portage/sys-apps/sandbox-2.25/work/sandbox-2.25/libsandbox/trace.c:do_peekstr():134: failure (Operation not permitted):

I think our issue is that we need to fall back gracefully if we figure we're in an environment without full privileges (a lot like the YAMA bugs we've seen).

There are a bunch of relevant fixes in 3.30+ but that's currently masked.
Comment 10 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-03-13 02:49:22 UTC
(In reply to Sam James from comment #9)
> >* /var/tmp/portage/sys-apps/sandbox-2.25/work/sandbox-2.25/libsandbox/trace.c:do_peekstr():134: failure (Operation not permitted):
> 
> I think our issue is that we need to fall back gracefully if we figure we're
> in an environment without full privileges (a lot like the YAMA bugs we've
> seen).
> 
> There are a bunch of relevant fixes in 3.30+ but that's currently masked.

(... https://jvns.ca/blog/2020/04/29/why-strace-doesnt-work-in-docker/ and the rest of it too)
Comment 11 Kobboi 2022-03-14 18:08:51 UTC
Created attachment 767066 [details]
Dockerfile for a basic stage3 system for reproduction
Comment 12 Kobboi 2022-03-14 18:30:30 UTC
sam_ asked me to log as much information to reproduce, so here we go:

1) Create a simple Docker image from a recent stage 3:

   MIRROR=http://ftp.snt.utwente.nl/pub/os/linux/gentoo
   STAGE_TYPE=stage3-amd64-desktop-systemd
   STAGE_DATE=$(wget ${MIRROR}/releases/amd64/autobuilds/latest-${STAGE_TYPE}.txt -O - 2>/dev/null| grep -v ^# | cut -d'/' -f1)
   STAGE_FILE=${STAGE_TYPE}-${STAGE_DATE}.tar.xz
   STAGE_URL=${MIRROR}/releases/amd64/autobuilds/${STAGE_DATE}/${STAGE_FILE}

   wget ${STAGE_URL} -O - | xzcat --to-stdout | docker import - gentoo-basic2

2) Enable basic core dumps

   echo /%e-%s.core > /proc/sys/kernel/core_pattern

2) Start a Docker container with the generated image

   docker run -it gentoo-basic /bin/bash

3) Run the following at the command prompt

   emerge --sync -q ; echo 'ACCEPT_KEYWORDS="~amd64"' >> /etc/portage/make.conf ; echo 'FEATURES="-ipc-sandbox -network-sandbox -pid-sandbox -usersandbox -userpriv -mount-sandbox"' >> /etc/portage/make.conf ; echo 'CFLAGS="${CFLAGS} -ggdb3 -g"' >> /etc/portage/make.conf ; echo 'sys-libs/ncurses -gpm abi_x86_32' > /etc/portage/package.use/ncurses ; emerge -1q debugedit ; emerge -1q gdb sandbox glibc bash ; emerge -1q ncurses

4) Debug the coredumps (in the container root) with gdb
Comment 13 Kobboi 2022-03-14 18:32:14 UTC
While trying to reproduce, I made the following observations (most will probably not be relevant but posting anyway):

The basic stage3 image currently comes with ncurses-6.2_p20210619[abi_x86_64,-abi_x86_32,gpm]

    1) amd64 with abi_x86_32 = no problem (so basically, sticking to the available version, only adding a 32-bit variant)
    2) ~amd64 with -abi_x86_32 = no problem (upgrading to 6.3_p20211106, sticking to 64-bit only)
    3) ~amd64 with abi_x86_32 and adding FEATURES="-sandbox" = no problem
    4) ~amd64 with abi_x86_32 not adding any of the above FEATURES but running in a chroot = no problem
Comment 14 Kobboi 2022-03-14 18:32:57 UTC
I also tested this with currently masked sandbox-3.1, but the outcome was the same.
Comment 15 Kobboi 2022-03-14 18:34:54 UTC
(In reply to Kobboi from comment #12)

>    emerge --sync -q ; echo 'ACCEPT_KEYWORDS="~amd64"' >>
> /etc/portage/make.conf ; echo 'FEATURES="-ipc-sandbox -network-sandbox
> -pid-sandbox -usersandbox -userpriv -mount-sandbox"' >>
> /etc/portage/make.conf ; echo 'CFLAGS="${CFLAGS} -ggdb3 -g"' >>
> /etc/portage/make.conf ; echo 'sys-libs/ncurses -gpm abi_x86_32' >
> /etc/portage/package.use/ncurses ; emerge -1q debugedit ; emerge -1q gdb
> sandbox glibc bash ; emerge -1q ncurses

For debugging, the FEATURES string is missing the "splitdebug" and "installsources" features.
Comment 16 Gary G. Sparkes Jr. 2022-03-14 18:44:36 UTC
I just want to make a note, my original issue was occurring NOT in sandbox/container, though they may be related issues, however the original issue was bare metal style (Hyper-V VM) installation without docker or any other sandbox/containerization in play.