Date: Mon, 6 Aug 2012 17:11:47 +0800 From: orc <orc@...server.ru> To: musl@...ts.openwall.com Subject: Re: noexecstack On Mon, 6 Aug 2012 10:46:56 +0200 Daniel Cegiełka <daniel.cegielka@...il.com> wrote: > 2012/8/6 orc <orc@...server.ru>: > > On Mon, 6 Aug 2012 09:16:10 +0200 > > Daniel Cegiełka <daniel.cegielka@...il.com> wrote: > > > > >> It would be very nice if we could solve this problem in this way. > >> I'm currently using this patch, but this is not the best solution > >> in my opinion. Ideally if the system (kernel, binutils, libc) > >> enforce noexecstack by default... definitely worth look closer at > >> this issue. > > > > Consider this patch as enforcing binutils' noexecstack by default: > > > > diff -Naur binutils-18.104.22.168.17.o/ld/ldmain.c > > binutils-22.214.171.124.17/ld/ldmain.c --- > > binutils-126.96.36.199.17.o/ld/ldmain.c 2007-06-19 > > 01:31:40.000000000 +0800 +++ binutils-188.8.131.52.17/ld/ldmain.c > > 2012-08-03 19:59:26.658980680 +0800 @@ -281,6 +281,8 @@ > > link_info.pei386_auto_import = -1; link_info.spare_dynamic_tags = 5; > > link_info.sharable_sections = FALSE; > > + link_info.execstack = FALSE; > > + link_info.noexecstack = TRUE; > > > > ldfile_add_arch (""); > > emulation = get_emulation (argc, argv); > > > > (this one for binutils 184.108.40.206.17, recent maybe patched with > > finding where link_info is initialized and appending this two lines) > > > > GCC generates same .note.GNU-stack section definition in it's asm > > output, as seen in your patch, but I don't know when it needs > > executable stack and generates another definition. > > I'm afraid that this option will not work with .S files. Here is a > comment to this feature: > > http://www.cygwin.com/ml/binutils/2003-06/msg00128.html > > Here is another patch: > > http://sourceware.org/ml/binutils/2003-05/msg00741.html > > it's like in the Vasily's patch with stack flags (PF_R | PF_W | PF_X): > > http://www.openwall.com/lists/owl-dev/2012/08/05/3 > > Daniel It seems that this is under GCC control (NEED_INDICATE_EXEC_STACK macro, related subroutine in gcc/varasm.c). If .S has no .note.GNU-stack section definition, than the produced .o file will be clean from it and it will be task of binutils' ld to decide create executable stack segment or not. If you about .S files that are parts of musl, then this patch will be enough. It is the same of -z noexecstack. (Ideal situation here is that all the code can work with non-executable stack and there are no such ugly extensions in ELF)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.