Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 925560 - app-misc/gcal terminates with buffer overflow
Summary: app-misc/gcal terminates with buffer overflow
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal
Assignee: Gentoo Shell Tools project
URL:
Whiteboard:
Keywords: PATCH
Depends on: 925564
Blocks: 847148
  Show dependency tree
 
Reported: 2024-02-26 22:03 UTC by Klaus Ethgen
Modified: 2024-02-27 01:04 UTC (History)
2 users (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 Klaus Ethgen 2024-02-26 22:03:27 UTC
~> gcal                   
*** buffer overflow detected ***: terminated
[1]    26406 IOT instruction  gcal

I searched for some hints and found that on fedora they had the same error but just linked to some advisory without providing how they fixed the bug. All I seen there is that it has something to do with fortify source...

Reproducible: Always

Steps to Reproduce:
See above (gcal --version works)
Actual Results:  
*** buffer overflow detected ***: terminated

Expected Results:  
It works

See above about fortify.
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-02-26 22:15:15 UTC
Can you try to grab a backtrace please? See https://wiki.gentoo.org/wiki/Debugging#Per-package.

IIRC Arsen mentioned this to me recently too.

Please also include emerge --info.
Comment 2 Arsen Arsenović gentoo-dev 2024-02-26 22:20:26 UTC
I have.. the codebase is full of questionable constructs.  I didn't have time to go over it and fix it.
Comment 3 Klaus Ethgen 2024-02-26 22:26:23 UTC
~> emerge --info
Portage 3.0.61 (python 3.11.8-final-0, default/linux/amd64/17.1/hardened, gcc-13, glibc-2.38-r10, 6.6.16-gentoo-dist x86_64)
=================================================================
System uname: Linux-6.6.16-gentoo-dist-x86_64-AMD_Ryzen_7_PRO_6850U_with_Radeon_Graphics-with-glibc2.38
KiB Mem:    31589984 total,  23365720 free
KiB Swap:   12582908 total,  12582908 free
Timestamp of repository gentoo: Sun, 25 Feb 2024 15:00:00 +0000
Head commit of repository gentoo: 138d5bfb358022379de23655c3c2db77f229ad72
sh bash 5.1_p16-r6
ld GNU ld (Gentoo 2.41 p5) 2.41.0
ccache version 4.9.1 [enabled]
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.1_p16-r6::gentoo
dev-build/autoconf:        2.71-r6::gentoo
dev-build/automake:        1.16.5-r2::gentoo
dev-build/cmake:           3.27.9::gentoo
dev-build/libtool:         2.4.7-r2::gentoo
dev-build/make:            4.4.1-r1::gentoo
dev-build/meson:           1.3.1-r1::gentoo
dev-lang/perl:             5.38.2-r1::gentoo
dev-lang/python:           3.11.8_p1::gentoo, 3.12.1_p1::gentoo
dev-lang/rust-bin:         1.74.1::gentoo
dev-util/ccache:           4.9.1::gentoo
sys-apps/baselayout:       2.14-r2::gentoo
sys-apps/openrc:           0.53::gentoo
sys-apps/sandbox:          2.38::gentoo
sys-devel/binutils:        2.41-r5::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/gcc:             13.2.1_p20240113-r1::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-devel/llvm:            17.0.6::gentoo
sys-kernel/linux-headers:  6.6::gentoo (virtual/os-headers)
sys-libs/glibc:            2.38-r10::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    volatile: False
    sync-rsync-verify-metamanifest: yes
    sync-rsync-extra-opts: 
    sync-rsync-verify-max-age: 3
    sync-rsync-verify-jobs: 1

Binary Repositories:

gentoobinhost-hardened
    priority: 100
    sync-uri: https://mirror.init7.net/gentoo/releases/amd64/binpackages/17.1/x86-64_hardened

gentoobinhost
    priority: 1
    sync-uri: https://mirror.init7.net/gentoo/releases/amd64/binpackages/17.1/x86-64

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /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/terminfo"
CXXFLAGS="-O2 -pipe"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS=" --usepkg-exclude 'sys-kernel/gentoo-sources virtual/* dev-perl/*'"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live ccache config-protect-if-modified distlocks ebuild-locks fixlafiles getbinpkg ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict suidctl unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="https://mirror.init7.net/gentoo/ https://distfiles.gentoo.org"
LANG="de_DE"
LC_ALL="C"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LEX="flex"
MAKEOPTS="-j17 -l16"
PKGDIR="/var/cache/binpkgs"
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 --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
SHELL="/bin/zsh"
USE="X acl alsa alsa-plugin amd64 bluetooth bzip2 caps cet cli crypt dri fortran gdbm hardened iconv ipv6 jpeg libtirpc multilib ncurses nls openmp pam pcre pcsc-lite pic pie png readline seccomp split-usr ssl ssp test-rust threads udev unicode xattr xtpax zlib zsh-completion" ABI_X86="64" ADA_TARGET="gnat_2021" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_anon authn_dbm authn_file authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir env expires ext_filter file_cache filter headers include info log_config logio mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 ntrip navcom oceanserver oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 tsip tripmate tnt ublox" INPUT_DEVICES="evdev keyboard mouse wacom" KERNEL="linux" L10N="de de-1901 de-DE de-CH" LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-1" POSTGRES_TARGETS="postgres15" PYTHON_SINGLE_TARGET="python3_11" PYTHON_TARGETS="python3_11" RUBY_TARGETS="ruby31" VIDEO_CARDS="amdgpu dummy fbdev radeonsi vesa" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-02-27 00:48:12 UTC
Just from 'gcal':

Program received signal SIGABRT, Aborted.
0x00007ffff7badc7c in ?? () from /usr/lib64/libc.so.6
(gdb) bt
#0  0x00007ffff7badc7c in ?? () from /usr/lib64/libc.so.6
#1  0x00007ffff7b57fc2 in raise () from /usr/lib64/libc.so.6
#2  0x00007ffff7b404f2 in abort () from /usr/lib64/libc.so.6
#3  0x00007ffff7b414f9 in ?? () from /usr/lib64/libc.so.6
#4  0x00007ffff7c283e7 in __fortify_fail () from /usr/lib64/libc.so.6
#5  0x00007ffff7c27d62 in __chk_fail () from /usr/lib64/libc.so.6
#6  0x00007ffff7c29622 in __strcpy_chk () from /usr/lib64/libc.so.6
#7  0x0000555555592068 in strcpy (__dest=<optimized out>, __src=0x5555555fe0fa "May ") at /usr/include/bits/string_fortified.h:79
#8  month_name (month=5) at utils.c:1361
#9  month_name (month=<optimized out>) at utils.c:1314
#10 0x0000555555557553 in eliminate_invalid_data () at gcal.c:7339
#11 main (argc=<optimized out>, argv=<optimized out>) at gcal.c:2825
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-02-27 00:48:40 UTC
(gdb) frame 10
#10 0x0000555555557553 in eliminate_invalid_data () at gcal.c:7339
7339          len = (int) strlen (month_name (i));

... and I see https://git.savannah.gnu.org/cgit/gcal.git/commit/?id=a9d49b3e6535ebf2b5a0b4051e95bb5dc0c27fdb in month_name.
Comment 6 Larry the Git Cow gentoo-dev 2024-02-27 00:58:52 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fc29b9c0f71207121cbf9c93b1f5f131de30b078

commit fc29b9c0f71207121cbf9c93b1f5f131de30b078
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2024-02-27 00:58:05 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-02-27 00:58:40 +0000

    app-misc/gcal: fix crash with _F_S=3, add smoke test
    
    * Fix crash with _F_S=3 using upstream patch
    * Add smoke test to src_test which would've (and does) catch this
    
    Closes: https://bugs.gentoo.org/925560
    Signed-off-by: Sam James <sam@gentoo.org>

 app-misc/gcal/files/gcal-4.1-fortify.patch | 21 ++++++++++
 app-misc/gcal/gcal-4.1-r2.ebuild           | 62 ++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+)
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-02-27 01:04:19 UTC
Upstream report from before, for completeness:
* https://lists.gnu.org/archive/html/bug-gcal/2023-06/msg00000.html