Linux ?????????????????
???????????? ???????[ 2012/11/7 10:05:08 ] ????????
??????????????漰??????Linux????????????????????????κε???
?????????????????????????????????????????? ???????????????????????pthread_attr_setstack??????????????????С????????task_struct?? mm_struct *mm ?????????????????stack_size???????????????????С???
???????????
????????????????????task_struct ??mm_struct *mm?????????? mm?е???????????????????????????? ?????????????STACK_TOP?? ?????????PF_RANDOMIZE????????????????С?????????????????????????STACK_TOP?? ????????????TASK_SIZE?? ??32λ???????0XC0000000??????????????????????????????????mm->start_stack?У????????cat /proc/xxx/stat ????
?????????????????????????????????????????????mm->mmap_base??mm->mmap_base???????mmap_base????????????????????????mmap?????????????????????????????????????mmap_base????????????£?
#define MIN_GAP (128*1024*1024)
#define MAX_GAP (TASK_SIZE/6*5)
static inline unsigned long mmap_base(struct mm_struct *mm)
{
unsigned long gap = current->signal->rlim[RLIMIT_STACK].rlim_cur; // rlim_cur ????8388608????8M?? ??????? getrlimit(RLIMIT_STACK?? &limit) ??
unsigned long random_factor = 0;
if (current->flags & PF_RANDOMIZE)
random_factor = get_random_int() % (1024*1024);
if (gap < MIN_GAP) // ???MIN_GAP???????????????С?????128MB
gap = MIN_GAP;
else if (gap > MAX_GAP) // ???????TASK_SIZE/6*5?? ??2.5G
gap = MAX_GAP;
return PAGE_ALIGN(TASK_SIZE - gap - random_factor); // ???????random_factor????С?????????????
}
? ? IA-32????????????????????
??????????
??????????????????????л????????????????а????????б?????????ID????????????????????????????????????????errno????????????????????????????????y???????????????????????????е????????????????????????棬???????????????????????mm_struct *mm????????????????mm???????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11