Re: buffer overflow warning in /bin/sh

From: Conrad Meyer <cem_at_FreeBSD.org>
Date: Thu, 25 Feb 2016 19:31:02 -0800
I have /etc/src.conf:
WITH_DEBUG_FILES=1
WITH_CTF=1

/etc/make.conf:
CFLAGS=-fno-omit-frame-pointer
WITH_CTF=1
WITH_DEBUG=yes

Not sure which of those is relevant (or even correct), but I seem to
get debuginfo in /usr/lib/debug/<PATH/TO/OBJECT>.debug.

Best,
Conrad

On Thu, Feb 25, 2016 at 7:21 PM, Howard Su <howard0su_at_gmail.com> wrote:
> I got the error when compiling GENERIC kernel with address sanitizer
> /bin/sh:
> --- vers.c ---
> MAKE=make sh /usr/home/howardsu/freebsd/sys/conf/newvers.sh
> GENERIC=================================================================
> ==4132==ERROR: AddressSanitizer: stack-buffer-overflow on address
> 0x7fffffffc9c0 at pc 0x00000045fdc7 bp 0x7fffffffc930 sp 0x7fffffffc0f0
> WRITE of size 312 at 0x7fffffffc9c0 thread T0
>     #0 0x45fdc6  (/bin/sh+0x45fdc6)
>     #1 0x801431767  (/lib/libc.so.7+0x7c767)
>     #2 0x42ff5e  (/bin/sh+0x42ff5e)
>     #3 0x4b6b00  (/bin/sh+0x4b6b00)
>     #4 0x49686e  (/bin/sh+0x49686e)
>     #5 0x495572  (/bin/sh+0x495572)
>     #6 0x48c3f9  (/bin/sh+0x48c3f9)
>     #7 0x489920  (/bin/sh+0x489920)
>     #8 0x4acde8  (/bin/sh+0x4acde8)
>     #9 0x4aca4d  (/bin/sh+0x4aca4d)
>     #10 0x40fb0e  (/bin/sh+0x40fb0e)
>     #11 0x80071afff  (<unknown module>)
>
> Address 0x7fffffffc9c0 is located in stack of thread
> T0==4132==AddressSanitizer CHECK failed:
> /usr/home/howardsu/freebsd/lib/libclang_rt/asan/../../../contrib/compiler-rt/lib/asan/asan_thread.cc:246
> "((ptr[0] == kCurrentStackFrameMagic)) != (0)" (0x0, 0x0)
>     #0 0x422b9d  (/bin/sh+0x422b9d)
>     #1 0x41de09  (/bin/sh+0x41de09)
>     #2 0x41f301  (/bin/sh+0x41f301)
>     #3 0x4728be  (/bin/sh+0x4728be)
>     #4 0x474589  (/bin/sh+0x474589)
>     #5 0x47502a  (/bin/sh+0x47502a)
>     #6 0x45fdef  (/bin/sh+0x45fdef)
>     #7 0x801431767  (/lib/libc.so.7+0x7c767)
>     #8 0x42ff5e  (/bin/sh+0x42ff5e)
>     #9 0x4b6b00  (/bin/sh+0x4b6b00)
>     #10 0x49686e  (/bin/sh+0x49686e)
>     #11 0x495572  (/bin/sh+0x495572)
>     #12 0x48c3f9  (/bin/sh+0x48c3f9)
>     #13 0x489920  (/bin/sh+0x489920)
>     #14 0x4acde8  (/bin/sh+0x4acde8)
>     #15 0x4aca4d  (/bin/sh+0x4aca4d)
>     #16 0x40fb0e  (/bin/sh+0x40fb0e)
>     #17 0x80071afff  (<unknown module>)
>
> *** [vers.c] Error code 1
>
> I am using latest -Current and add the following flags to /etc/make.conf.
> # CFLAGS+= -g -fsanitize=address -fno-omit-frame-pointer
>
> I rebuild /bin/sh as a first step. with the /bin/sh I got the above error.
> I would like to understand how to get symbols. The following command
> doesn't work at all.
>  addr2line -e /bin/sh 0x422b9d
>
> Any idea?
>
> --
> -Howard
> _______________________________________________
> freebsd-current_at_freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe_at_freebsd.org"
Received on Fri Feb 26 2016 - 02:31:04 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:03 UTC