POSIX Thread Stack Memory. Can we have different stack sizes and security concerns?

I have questions regarding the size of the POSIX thread stack stack and their security issues:

A) Can we have different stack sizes (for each set of threads using: pthread_attr_getstacksize )?

B) When a thread dies (disconnects / exits), does the operating system restore its memory pages?

C) Can a thread continue to write to the stack segment of other threads if they are next to each other when displaying virtual memory?

+4
source share
1 answer

A) Yes, of course, the goal is pthread_attr_setstacksize .

B) Yes, calling pthread_detach or pthread_join causes thread resources to recover after completion.

C) Theoretically, yes, but since on most systems the stack grows in the opposite direction (from high to low), you will need to do some kind of buffer overflow to get out of your current stack space.

+3
source

Source: https://habr.com/ru/post/1400033/


All Articles