flat assembler
Message board for the users of flat assembler.

flat assembler > Programming Language Design > [fasmg] gnu-stack

Author
Thread Post new topic Reply to topic
_shura



Joined: 22 May 2015
Posts: 60
Ohai,
I suggest to add
Code:
PT_GNU_EH_FRAME = 0x6474e550 PT_GNU_STACK = 0x6474e551

at the start of fasmg/examples/x86/include/format/elfexe.inc (the constant is from https://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/progheader.html) and
Code:
else match =gnustack?, attribute SEGMENT_TYPE = PT_GNU_STACK else match =gnuehframe?, attribute SEGMENT_TYPE = PT_GNU_EH_FRAME

in the macro segment? attributes*. Without the GNU-_STACK-segment it is possible to execute data by accident or malicious influence. Even if you try to protect it with mprotect!
Here is an example:
Code:
include 'format/format.inc' format ELF64 executable entry _start segment executable _start: jmp outside return: mov rax, 60 syscall segment readable writeable msg db 'hello world', 10 msg.size = ( $ - msg ) outside: mov rdx, msg.size lea rsi, [ msg ] mov rdi, 1 mov rax, 1 syscall jmp return segment readable writeable gnustack

Just try with and without the last segment.
I do not know the purpose of the GNU_EH_FRAME-segment, but it may be usefull for someone.[/i]

_shura
(this was posted somewhere else by accident, sorry)
Post 26 Sep 2016, 16:18
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6876
Location: Kraków, Poland
Thank you, I'm going to add it (and also a "note" setting for the PT_NOTE type).

I think that this also shows in a way how easy it is to modify fasmg's formatters.
Post 26 Sep 2016, 17:55
View user's profile Send private message Visit poster's website Reply with quote
_shura



Joined: 22 May 2015
Posts: 60
yay, thank you.
I would be nice , if you implement it in fasm too.
Post 26 Sep 2016, 18:45
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6876
Location: Kraków, Poland
_shura wrote:
I would be nice , if you implement it in fasm too.
It is a little bit harder to add it there, but I will look into it.
Post 26 Sep 2016, 19:06
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6876
Location: Kraków, Poland
OK, got it done for fasm, too.
Post 26 Sep 2016, 20:09
View user's profile Send private message Visit poster's website Reply with quote
_shura



Joined: 22 May 2015
Posts: 60
btw. could you add an gnustack-segment to the fasmg itself? I guess, it is not really necessary for the compiler, but it may prevent some vulnerabilities. A compiler is not really such an attack surface, but who knows?
Post 21 Aug 2017, 00:43
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 2004-2018, Tomasz Grysztar.

Powered by rwasa.