On Sat, Feb 24, 2024 at 09:59:48AM +0100, Sebastian Ramacher wrote:
> Source: faketime
> Version: 0.9.10-2.1
> Severity: serious
> Tags: ftbfs
> Justification: fails to build from source (but built successfully in the past)
> X-Debbugs-Cc: sramac...@debian.org
> 
> https://buildd.debian.org/status/fetch.php?pkg=faketime&arch=armel&ver=0.9.10-2.1%2Bb1&stamp=1704500126&raw=0
> 
> gcc -c -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong 
> -fstack-clash-protection -Wformat -Werror=format-security -DMULTI_ARCH 
> -DFAKE_RANDOM -DFAKE_PID -std=gnu99 -Wall -DFAKE_STAT -Werror -Wextra  
> timetest.c
> ./testframe.sh functests
> # Begin Test Suites in functests
> 
> # Begin functests/test_exclude_mono.sh
> # PLATFORM=linuxlike
> gcc -o timetest timetest.o -Wl,-z,relro -Wl,-z,now -lrt -lpthread
> out=193535.427098546 When not faking monotonic time, timestamps should be 
> different ref=193536.51863104 - ok
> # functests/test_exclude_mono.sh summary: 1 succeeded, 0 failed
> # End functests/test_exclude_mono.sh - OK

When building faketime on armhf and then run

        make test

this results in:

        ...
        # Begin Test Suites in functests

        # Begin functests/test_exclude_mono.sh
        # PLATFORM=linuxlike
        *** stack smashing detected ***: terminated
        ...

The command that is run there is (a bit simplified):

        $ LD_PRELOAD=src/libfaketime.so.1 /bin/bash -c 'perl -w 
-MTime::HiRes=clock_gettime,CLOCK_MONOTONIC -E     '\''say 
clock_gettime(CLOCK_MONOTONIC)'\'';   '
        *** stack smashing detected ***: terminated
        Aborted

The same happens with

        $ LD_PRELOAD=src/libfaketime.so.1 /bin/bash -c 'true'                   
                                        
        *** stack smashing detected ***: terminated
        Aborted

I think that's because bash still uses 32bit time_t and calls
gettimeofday from libc (which on armhf uses 32bit time_t) but the
gettimeofday that it MITMed by libfaketime.so.1 uses 64bit time_t and so
writes to a bigger memory chunk than is handed in by bash's struct
timeval *tv.

So to get it right faketime must be made aware that on platforms that
have __gettimeofday64 in libc gettimeofday uses 32bit time_t. (And the
same on various other functions.)

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Attachment: signature.asc
Description: PGP signature

Reply via email to