Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 558946 - >=sys-libs/glibc-2.21: double free or corruption on getmntent
Summary: >=sys-libs/glibc-2.21: double free or corruption on getmntent
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: PPC Linux
: Normal normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL: https://sourceware.org/bugzilla/show_...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-27 16:54 UTC by Michael Weiser
Modified: 2015-08-31 10:50 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Weiser 2015-08-27 16:54:53 UTC
After upgrade to glibc-2.21-r1, openrc's fstabinfo and mountinfo throw "double free or corruption" errors on my Thecus n1200 NAS. I was able to boil it down to a test case as shown below.

Reproducible: Always

Steps to Reproduce:
cat > t.c <<EOF
#include <mntent.h>
int main(void) {
	FILE *fp = setmntent("/etc/fstab", "r");
	getmntent(fp);
	endmntent(fp);
}
EOF

gcc -o t t.c
./t

Actual Results:  
*** Error in `./t': double free or corruption (!prev): 0x102e4008 ***
======= Backtrace: =========
/lib/libc.so.6[0xfe9c6b8]
/lib/libc.so.6[0xfea3e3c]
/lib/libc.so.6[0xfea4be8]
/lib/libc.so.6(fclose+0x1f4)[0xfe8eea4]
/lib/libc.so.6(endmntent+0x2c)[0xff08578]
./t[0x100004a4]
/lib/libc.so.6[0xfe41938]
/lib/libc.so.6[0xfe41ad8]
======= Memory map: ========
00100000-00103000 r-xp 00000000 00:00 0          [vdso]
0fe20000-0ff84000 r-xp 00000000 08:01 7864443    /lib/libc-2.21.so
0ff84000-0ff9c000 ---p 00164000 08:01 7864443    /lib/libc-2.21.so
0ff9c000-0ffa0000 r--p 0016c000 08:01 7864443    /lib/libc-2.21.so
0ffa0000-0ffa1000 rw-p 00170000 08:01 7864443    /lib/libc-2.21.so
0ffa1000-0ffa4000 rw-p 00000000 00:00 0 
0ffb0000-0ffd1000 r-xp 00000000 08:01 7864442    /lib/ld-2.21.so
0ffef000-0fff0000 r--p 0002f000 08:01 7864442    /lib/ld-2.21.so
0fff0000-0fff1000 rw-p 00030000 08:01 7864442    /lib/ld-2.21.so
10000000-10001000 r-xp 00000000 08:01 14418124   /home/michael/t
1001f000-10020000 r--p 0000f000 08:01 14418124   /home/michael/t
10020000-10021000 rw-p 00010000 08:01 14418124   /home/michael/t
102e4000-10305000 rwxp 00000000 00:00 0          [heap]
b7cb1000-b7cb2000 rw-p 00000000 00:00 0 
b7cb7000-b7cb9000 rw-p 00000000 00:00 0 
bfaa3000-bfac4000 rw-p 00000000 00:00 0          [stack]
Aborted



- calling getmntent at least once is necessary to trigger the problem. My guess is that getmntent is actually corrupting something which is only detected on endmntent.
- does not happen on arm or amd64. Corruption might still happen though but not be detected.
- /var/log/rc.log backups show that it did not happen on previous reboots.
- previous glibc version according to /var/log/emerge.log was 2.20-r2.

emerge --info
Portage 2.2.20.1 (python 3.4.3-final-0, default/linux/powerpc/ppc32/13.0, gcc-4.9.3, glibc-2.21-r1, 4.1.6 ppc)
=================================================================
System uname: Linux-4.1.6-ppc-e300c1-with-gentoo-2.2
KiB Mem:      126580 total,     11148 free
KiB Swap:     975532 total,    974296 free
Timestamp of repository gentoo: Wed, 26 Aug 2015 18:30:01 +0000
sh bash 4.3_p39
ld GNU ld (Gentoo 2.25.1 p1.0) 2.25.1
distcc 3.2rc1 powerpc-unknown-linux-gnu [disabled]
app-shells/bash:          4.3_p39::gentoo
dev-lang/perl:            5.22.0::gentoo
dev-lang/python:          2.7.10::gentoo, 3.4.3::gentoo
dev-util/pkgconfig:       0.28-r3::gentoo
sys-apps/baselayout:      2.2::gentoo
sys-apps/openrc:          0.17::gentoo
sys-apps/sandbox:         2.6-r1::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69-r1::gentoo
sys-devel/automake:       1.4_p6-r2::gentoo, 1.5-r2::gentoo, 1.6.3-r2::gentoo, 1.7.9-r3::gentoo, 1.9.6-r4::gentoo, 1.11.6-r1::gentoo, 1.14.1::gentoo, 1.15::gentoo
sys-devel/binutils:       2.25.1::gentoo
sys-devel/gcc:            4.9.3::gentoo
sys-devel/gcc-config:     1.8::gentoo
sys-devel/libtool:        2.4.6-r1::gentoo
sys-devel/make:           4.1-r1::gentoo
sys-kernel/linux-headers: 4.1::gentoo (virtual/os-headers)
sys-libs/glibc:           2.21-r1::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000

local-overlay
    location: /usr/local/portage
    masters: gentoo
    priority: 0

Installed sets: @system
ACCEPT_KEYWORDS="ppc ~ppc"
ACCEPT_LICENSE="* -@EULA"
CBUILD="powerpc-unknown-linux-gnu"
CFLAGS="-O2 -mcpu=603e -fno-strict-aliasing -pipe -fsigned-char"
CHOST="powerpc-unknown-linux-gnu"
CONFIG_PROTECT="/etc /etc/stunnel/stunnel.conf /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -mcpu=603e -fno-strict-aliasing -pipe -fsigned-char"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--jobs=2 --load-average=4 --with-bdeps=y"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs collision-protect config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="ftp://linux.rz.ruhr-uni-bochum.de/gentoo-mirror/ ftp://ftp.uni-erlangen.de/pub/mirrors/gentoo ftp://ftp.join.uni-muenster.de/pub/linux/distributions/gentoo ftp://ftp.wh2.tu-dresden.de/pub/mirrors/gentoo ftp://sunsite.informatik.rwth-aachen.de/pub/Linux/gentoo"
LANG="en_GB.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
USE="bzip2 cracklib crypt cxx hardened iconv ipv6 kerberos mbox modules ncurses nptl nptlonly openssl pam pcre ppc readline recode ssl tcpd truetype unicode xinetd zlib" ABI_PPC="32" ALSA_CARDS="aoa aoa-fabric-layout aoa-onyx aoa-soundbus aoa-soundbus-i2s aoa-tas aoa-toonie powermac usb-audio via82xx" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd 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="kexi words flow plan sheets stage tables krita karbon braindump author" 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 ublox ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby19 ruby20" USERLAND="GNU" VIDEO_CARDS="fbdev glint mach64 mga nv r128 radeon savage tdfx trident dummy v4l" 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:  CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, MAKEOPTS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 1 SpanKY gentoo-dev 2015-08-28 20:36:58 UTC
excellent test case.  this was introduced by this upstream commit:
https://sourceware.org/git/?p=glibc.git;a=commit;h=fb87ee96d7dd0714d52004e4676629f8d9db732f
Comment 2 SpanKY gentoo-dev 2015-08-29 22:46:41 UTC
pushed upstream for 2.23, and to the 2.22 and 2.21 branches

pulled into Gentoo's 2.22 & 2.21 patchsets:
http://sources.gentoo.org/gentoo/src/patchsets/glibc/2.21/00_all_0022-getmntent-fix-memory-corruption-w-blank-lines-BZ-188.patch?revision=1.1
http://sources.gentoo.org/gentoo/src/patchsets/glibc/2.22/00_all_0021-getmntent-fix-memory-corruption-w-blank-lines-BZ-188.patch?revision=1.1

and pushed in our 2.21-r1/2.22 ebuilds:
http://gitweb.gentoo.org/repo/gentoo.git/commit/?id=68ff87d0a0bbe2d5794a0d8d6ac2f10b6ab438c2

no bump as it seems to only come up on a few systems.  hopefully we get a security issue or something for 2.21 and revbump it then ;).
Comment 3 Michael Weiser 2015-08-31 09:42:09 UTC
Awesome! Remerged glibc - problem gone. Thanks!