Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 376375 - app-crypt/pinentry (pinentry-curses) aborts with SIGSEGV if can't find terminfo
Summary: app-crypt/pinentry (pinentry-curses) aborts with SIGSEGV if can't find terminfo
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Crypto team [DISABLED]
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-25 15:41 UTC by i.Dark_Templar
Modified: 2013-01-12 19:07 UTC (History)
1 user (show)

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


Attachments
script to reproduce my minimal chroot (reproduce_chroot.sh,675 bytes, text/plain)
2011-07-25 15:52 UTC, i.Dark_Templar
Details
My pinentry-curses crash strace log (pinentry-log.txt,1.64 KB, text/plain)
2011-07-25 15:56 UTC, i.Dark_Templar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description i.Dark_Templar 2011-07-25 15:41:35 UTC
pinentry-curses crashes with SIGSEGV if can't find terminfo.


Reproducible: Always

Steps to Reproduce:
1. make chroot with pinentry (static is better), and strace (static too, only for debugging), and busybox (for sh, mount, etc...), and without terminfo
2. chroot, run pinentry
3. make pinentry show password dialog
Actual Results:  
pinentry crashes with SIGSEGV.

Expected Results:  
pinentry should write error something like "couldn't find terminfo, aborting", and abort using proper way, without segmentation fault.

I found this bug when tried to make initrd with gpg2 inside. Normally there is terminfo, but it wasn't present at my initrd.
Bug found in pinentry-curses, but pinentry-gtk and pinentry-qt/qt4 probably affected too.
I know this is upstream bug, but I couldn't post it into app-crypt/pinentry bugzilla - couldn't find a way to register or to post bug without registration. Posted bug here for someone to deliver it to upstream. Or fix it for Gentoo at least.

More information about how to reproduce bug in comments.
Comment 1 i.Dark_Templar 2011-07-25 15:43:30 UTC
# emerge --info
Portage 2.1.10.3 (default/linux/amd64/10.0/no-multilib, gcc-4.4.5, glibc-2.12.2-r0, 2.6.38-gentoo-r2 x86_64)
=================================================================
System uname: Linux-2.6.38-gentoo-r2-x86_64-Pentium-R-_Dual-Core_CPU_T4200_@_2.00GHz-with-gentoo-2.0.3
Timestamp of tree: Sun, 24 Jul 2011 11:45:01 +0000
app-shells/bash:          4.1_p9
dev-lang/python:          2.7.1-r1
dev-util/cmake:           2.8.4-r1
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.0.3
sys-apps/openrc:          0.8.3-r1
sys-apps/sandbox:         2.4
sys-devel/autoconf:       2.13, 2.68
sys-devel/automake:       1.9.6-r3, 1.10.3, 1.11.1
sys-devel/binutils:       2.20.1-r1
sys-devel/gcc:            4.4.5
sys-devel/gcc-config:     1.4.1-r1
sys-devel/libtool:        2.2.10
sys-devel/make:           3.82
sys-kernel/linux-headers: 2.6.36.1 (virtual/os-headers)
sys-libs/glibc:           2.12.2
Repositories: gentoo enlightenment-niifaq lcd-filtering templar
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/splash /etc/terminfo"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--with-bdeps=y --buildpkg --binpkg-respect-use=y --usepkg=y"
FEATURES="binpkg-logs distlocks ebuild-locks fakeroot fixlafiles fixpackages news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS=""
GENTOO_MIRRORS="http://gentoo.bloodhost.ru/ http://ftp.ing.umu.se/linux/gentoo/ ftp://mirror.qubenet.net/mirror/gentoo/ ftp://mirror.bytemark.co.uk/gentoo/ ftp://91.121.124.139/gentoo-distfiles/"
LANG="ru_RU.UTF-8"
LC_ALL=""
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="ru en"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/enlightenment-niifaq /var/lib/layman/lcd-filtering /usr/local/portage"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="X a52 aac acl acpi alsa amd64 amr apm ares bash-completion bidi bluetooth bzip2 cairo caps cdda cdio cdr cleartype cli consolekit cracklib crypt cue cups custom-cflags custom-optimization cxx dbus dga dirac dri dts dvd dvdr encode exif faad fam ffmpeg flac fluidsynth fontconfig fontforge freetype gcrypt gif gmp gnutls gpm gtk iconv icu idn imlib inotify ipv6 jadetex jpeg kde lcms libass libdvdcss lzma lzo mad matroska midi mmap mmx mng modules mp3 mp4 mpeg mplayer mtp mudflap ncurses network nls nptl nptlonly offensive ogg openal opengl openmp pango pch pcmcia pcntl pcre pdf pic plasma png policykit posix postproc ppds pppd private-headers projectm qt3support qt4 raw readline schroedinger session sftp sndfile sockets spell sse sse2 ssl ssse3 startup-notification svg sysfs system-sqlite tcpd tga theora threads tiff truetype udev unicode usb utils v4l v4l2 vaapi vdpau vlc vorbis vpx wavpack wicd wifi wma wxwidgets x264 xcb xcomposite xft xine xorg xpm xscreensaver xv xvid zlib" ALSA_CARDS="hda-intel" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="braindump flow karbon kexi kpresenter krita tables words" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="ru en" PHP_TARGETS="php5-3" RUBY_TARGETS="ruby18" SANE_BACKENDS="hp" USERLAND="GNU" VIDEO_CARDS="vesa vga nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" 
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 2 i.Dark_Templar 2011-07-25 15:52:30 UTC
Created attachment 280929 [details]
script to reproduce my minimal chroot

This script reproduces chroot. Requires app-crypt/pinentry[static,ncurses] (which requires static-libs from ncurses), busybox[static] and strace[static].
It automatically chroots inside.
If you uncomment two lines inside script you'll get chroot with working pinentry.

After that you should do following commands:
mount -t proc none /proc
mount -t sysfs none /sys
busybox mdev -s     #(this can be skipped if you mount /dev or manually create necessary devices)
tty  # output of this command will be used later instead of $TTY_OUTPUT
strace pinentry 2>/pinentry.log

Now inside pinentry write following commands:
RESET
OPTION ttyname=$TTY_OUTPUT  # write output of "tty" command, not $TTY_OUTPUT
OPTION ttytype=linux
GETPIN

Application crashes. Now you can see pinentry.log. Before exiting chroot unmount everything mounted:
umount -a
Comment 3 i.Dark_Templar 2011-07-25 15:56:56 UTC
Created attachment 280931 [details]
My pinentry-curses crash strace log

Log which i got from previously written method. As I said, this is chroot for my initrd, minimally reduced just to reproduce this bug. It should probably be reproduced inside linux console, not X. At least I didn't test it at X, only using console at /dev/tty1.
Comment 4 i.Dark_Templar 2011-07-25 16:02:07 UTC
As I said, if you copy /etc/terminfo inside chroot, pinentry-curses will work. I'll repeat that this bug is about SIGSEGV, pinentry-curses should write understandable error and sanely abort, not just crash. Other pinentry-* (gtk2 and qt4) applications probably affected too, but I didn't test them.
Comment 5 Alon Bar-Lev gentoo-dev 2013-01-12 19:07:54 UTC
Hello,
Please take this to upstream[1].
We will be glad to apply any patch upstream commits, or bump to new version.
Thanks.

[1] http://gnupg.org/