본문 바로가기

Heap analysis/glibc 2.29

(glibc 2.29) tcache_get

전체 코드 더보기

더보기
/* Caller must ensure that we know tc_idx is valid and there's
   available chunks to remove.  */
static __always_inline void *
tcache_get (size_t tc_idx)
{
  tcache_entry *e = tcache->entries[tc_idx];
  assert (tc_idx < TCACHE_MAX_BINS);
  assert (tcache->entries[tc_idx] > 0);
  tcache->entries[tc_idx] = e->next;
  --(tcache->counts[tc_idx]);
  e->key = NULL;
  return (void *) e;
}

 

 

get address pointer (동일)


glibc 2.26과 동일

check (동일)


glibc 2.26과 동일

returnchunk and set (추가)


  tcache->entries[tc_idx] = e->next;
  --(tcache->counts[tc_idx]);
  e->key = NULL;
  return (void *) e;

재사용될 tcache의 freed chunk를 반환하기 전에 double free를 검증하는 key값을 널로 만들어 주는 코드가 추가 되었다

 

'Heap analysis > glibc 2.29' 카테고리의 다른 글

(glibc 2.29) get_max_fast  (0) 2022.07.30
(glibc 2.29) tcache_put  (0) 2022.05.19
(glibc 2.29) tcache_init  (0) 2022.05.19
(glibc 2.29) _int_free  (0) 2022.05.15
(glibc 2.29) free  (0) 2022.05.15