NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: GCC stack smashing protection



On Thu, Aug 27, 2009 at 05:55:02PM -0700, Michael Litchard wrote:
> So, I've got this in my /etc/mk.conf.
> USE_SSP=yes
> 
> 
> And I've rebuilt 5.0.1 kernel and userland. How can i verify that the
> gcc stack smashing protection is being used?

If you see SSP-related parameters being passed for the compiler during the
build process, then the protection should be in use.


#include <string.h>

static void
foo(char *str)
{
        char buf[16];

        strcpy(buf, str);
}

int
main()
{
        foo("smashing the stack for fun and profit");

        return 0;
}

$ gcc -Wall -fstack-protector-all foo.c -o foo
$ ./foo
$ egrep overflow /var/log/messages
$ Aug 28 06:32:38 marx foo: stack overflow detected; terminated


But I don't know if there is some generic way to test this. ATF?

- Jukka.


Home | Main Index | Thread Index | Old Index