I have experienced two kind of error,one is segmentation fault, another is Stack smashing detected. I want to know what different between them and the different reasons caused them.
Stack smashing in X86_64 leads to Segmentation fault .
Stack smashing is a form of vulnerability where the stack of a computer application or OS is forced to overflow. This may lead to subverting the program/system and crashing it.
Use debuggers to diagnose segfaults For example, you could use GNU's well-known debugger GDB to view the backtrace of a core file dumped by your program; whenever programs segfault, they usually dump the content of (their section of the) memory at the time of the crash into a core file.
Further, the compiler identifies by comparing with known values that the stack is compromised and generates an error saying: stack smashing detected . To prevent the buffer overflow protection variable and have some insights, we can disable the GCC's protection using the -fno-stack-protector while compiling.
This is typically Undefined behavior.
Segmentation fault is typically when your process is accessing memory location to which it doesn't have permission to access, or that location does not exist.
Stack smashing is an alert (generated by gcc for instance) that warns about an access out of bounds, for instance, on the stack. Typically that happens when the stack is written to where it shouldn't - like a local array written to at an index out of bounds.
There is a problem in your code that produces undefined behavior. Maybe you could share it with us so that we can help you.
Check in particular:
Segmentation fault is a fault raised by hardware with memory protection, notifying an operating system (OS) about a memory access violation. Stack smashing is reported when there is overflow of data in your program's call stack. Generally program's call stack is of fixed length.
stack overflow and stack smashing both problems are related to faulty code or value found in the variables. For example when a loop run as that it run over extras index of the array and overwrite the value of another variable of the code then , it become problem to the function prolog and epilog to continue to next function hence the current function become unable to return to calle function because overrun of llop has just overwrite the return address of calle instruction and hence EIP pointing to somewhere it not allowed to fetch instruction .All codes into OS are run in memory protection schems , hence you get stack overrun or stack smashing . Segmentation fault is problems is normal situation when dealing with array and pointer in Linux OS . Try this http://www.drdobbs.com/security/anatomy-of-a-stack-smashing-attack-and-h/240001832
Both are memory access violation. Segmentation fault is more general, means you are accessing something you are not allowed to. stack smashing is more specific, means something wrong in your stack. Actually, stack smashing can cause segmentation fault. you can refer to: https://en.wikipedia.org/wiki/Segmentation_fault or Stack smashing detected
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With