callstack

How do canary words allow gcc to detect buffer overflows?

喜欢而已 提交于 2020-07-03 09:45:18
问题 I could test using strncpy() with larger source string then the destination: int main() { char *ptr = malloc(12); strcpy(ptr,"hello world!"); return 0; } Compiling with the flag -fstack-protector and using the -S option I got: .file "malloc.c" .text .globl main .type main, @function main: .LFB2: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 movq %rsp, %rbp .cfi_def_cfa_register 6 subq $32, %rsp movl %edi, -20(%rbp) movq %rsi, -32(%rbp) movq %fs:40, %rax movq %rax, -8(

explanation about push ebp and pop ebp instruction in assembly

放肆的年华 提交于 2020-06-24 02:34:08
问题 i used stack in assembly but i didn't got idea about push ebp and pop ebp. .intel_syntax noprefix .include "console.i" .text askl: .asciz "Enter length: " askb: .asciz "Enter breadth: " ans: .asciz "Perimeter = " _entry: push ebp # establishing stack-frame mov ebp, esp sub esp, 12 Prompt askl GetInt [ebp-4] # length Prompt askb GetInt [ebp-8] # breadth mov eax, [ebp-4] # eax = l add eax, [ebp-8] # eax = l + b add eax, eax # eax = 2 * (l + b) mov [ebp-12], eax Prompt ans PutInt [ebp-12] PutEoL

How to properly setup SS, BP and SP in x86 Real Mode?

泄露秘密 提交于 2020-05-09 05:11:48
问题 I want to know how to properly do it, because the way I'm doing it isn't working. When setting the BP register with 7C00h, then setting the SP register with BP , then pushing some ASCII, then getting the data from the memory to print it with INT 10h , it works just fine. mov ax, 7C00h mov bp, ax mov sp, bp push 'A' mov ah, 0Eh mov al, [7BFEh] int 10h The actual output is A But when I do this: mov ax, 7C00h mov ss, ax mov bp, ax mov sp, bp ... It stops working. The interrupt is called, the

Linux process stack overrun by local variables (stack guarding)

核能气质少年 提交于 2020-04-10 08:44:09
问题 From What is the purpose of the _chkstk() function?: At the end of the stack, there is one guard page mapped as inaccessible memory -- if the program accesses it (because it is trying to use more stack than is currently mapped), there's an access violation. _chkstk() is a special compiler-helper function which ensures that there is enough space for the local variables i.e. it's doing some stack probing (here is an LLVM example). This case is Windows-specific. So Windows has some solution to

Recursive promises can cause stack overflow?

China☆狼群 提交于 2020-03-16 05:43:26
问题 For example I found some api library that is based on promises, and I need to issue api requests using this library in some interval, infinite times (like usual back-end loop). This api requests - actually chain of promises. So, if I write function like: function r(){ return api .call(api.anotherCall) .then(api.anotherCall) .then(api.anotherCall) ... .then(r) } Will it cause stack overflow? Solutions that I come up with is to use setTimeout for a call of r recursively. function r(){ return

Recursive promises can cause stack overflow?

我与影子孤独终老i 提交于 2020-03-16 05:40:06
问题 For example I found some api library that is based on promises, and I need to issue api requests using this library in some interval, infinite times (like usual back-end loop). This api requests - actually chain of promises. So, if I write function like: function r(){ return api .call(api.anotherCall) .then(api.anotherCall) .then(api.anotherCall) ... .then(r) } Will it cause stack overflow? Solutions that I come up with is to use setTimeout for a call of r recursively. function r(){ return

How Windows thread stack guard page mechanism works in case of uninitialized local variables?

生来就可爱ヽ(ⅴ<●) 提交于 2020-02-27 07:55:23
问题 On Windows OS for x86-32/x86-64 architecture thread stack virtual memory consist of "Reserved Part" "Commit Part", "Guard Page" and "Reserved Page". Question: Imagine that I have 1 page of commit memory, and 1MB of reserve memory for thread stack. I allocate on the stack some memory equal to K Pages without initialization. K is equal for example 10. It seems that in start of stack frame memory on the stack will be allocated by user space code like this: sub esp, K*4096 Guard Page mechanism

How Windows thread stack guard page mechanism works in case of uninitialized local variables?

≯℡__Kan透↙ 提交于 2020-02-27 07:51:35
问题 On Windows OS for x86-32/x86-64 architecture thread stack virtual memory consist of "Reserved Part" "Commit Part", "Guard Page" and "Reserved Page". Question: Imagine that I have 1 page of commit memory, and 1MB of reserve memory for thread stack. I allocate on the stack some memory equal to K Pages without initialization. K is equal for example 10. It seems that in start of stack frame memory on the stack will be allocated by user space code like this: sub esp, K*4096 Guard Page mechanism

.STACK is not allocating the correct size in MASM

≡放荡痞女 提交于 2020-01-24 09:27:05
问题 Based on Microsoft MASM Documentation, the usage of .STACK directive is When used with .MODEL, defines a stack segment (with segment name STACK). The optional size specifies the number of bytes for the stack (default 1,024). The .STACK directive automatically closes the stack statement. (32-bit MASM only.) For the sake of experimentation, I made the .STACK to allocate 1,073,741,824 bytes (1 GB) Note that I'm running the code in Visual Studio 2013, console project. .586 .MODEL FLAT .STACK

Call Stack limitation in C# [duplicate]

偶尔善良 提交于 2020-01-24 05:21:09
问题 This question already has answers here : Stack capacity in C# (5 answers) Closed 4 years ago . i wonder how much calls we can perform in stack in c# before we get stack overflow exception so i decided to write the following code static void Method2(int Calls) { if(!Calls.Equals(0)) Method1(--Calls);//if more calls remain call method1 and reduce counter } static void Method1(int Calls) { if (!Calls.Equals(0))//if more calls remain call method2 and reduce counter Method2(--Calls); } static void