free
Ucz się i praktykuj Hacking AWS:HackTricks Training AWS Red Team Expert (ARTE) Ucz się i praktykuj Hacking GCP: HackTricks Training GCP Red Team Expert (GRTE)
Podsumowanie darmowego zamówienia
(W tym podsumowaniu nie są wyjaśnione żadne kontrole, a niektóre przypadki zostały pominięte dla zwięzłości)
Jeśli adres jest null, nie rób nic
Jeśli kawałek był zmapowany, odmapuj go i zakończ
Wywołaj
_int_free
:Jeśli to możliwe, dodaj kawałek do tcache
Jeśli to możliwe, dodaj kawałek do fast bin
Wywołaj
_int_free_merge_chunk
, aby skonsolidować kawałek, jeśli jest to konieczne, i dodaj go do listy nieuporządkowanej
__libc_free
Free
wywołuje __libc_free
.
Jeśli przekazany adres to Null (0), nie rób nic.
Sprawdź tag wskaźnika
Jeśli kawałek jest
zmapowany
,odmapuj
go i to wszystkoJeśli nie, dodaj kolor i wywołaj
_int_free
nad nim
_int_free tcache
Najpierw spróbuje zaalokować ten kawałek w powiązanym tcache. Jednakże, wcześniej wykonane są pewne sprawdzenia. Przeiteruje przez wszystkie kawałki tcache o tym samym indeksie co zwolniony kawałek i:
Jeśli jest więcej wpisów niż
mp_.tcache_count
:free(): wykryto zbyt wiele kawałków w tcache
Jeśli wpis nie jest wyrównany:
free(): wykryto niezrównany kawałek w tcache 2
jeśli zwolniony kawałek był już zwolniony i jest obecny jako kawałek w tcache:
free(): wykryto podwójne zwolnienie w tcache 2
Jeśli wszystko pójdzie dobrze, kawałek zostanie dodany do tcache i funkcja zwróci.
_int_free szybki blok
Zacznij od sprawdzenia, czy rozmiar jest odpowiedni dla szybkiego bloku i sprawdź, czy można go ustawić blisko najwyższego fragmentu.
Następnie dodaj zwolniony fragment na górze szybkiego bloku, wykonując pewne kontrole:
Jeśli rozmiar fragmentu jest nieprawidłowy (zbyt duży lub mały), wywołaj:
free(): invalid next size (fast)
Jeśli dodany fragment był już na górze szybkiego bloku:
double free or corruption (fasttop)
Jeśli rozmiar fragmentu na górze ma inny rozmiar niż dodawany fragment:
invalid fastbin entry (free)
_int_free_merge_chunk
Ta funkcja spróbuje połączyć kawałek P o rozmiarze SIZE bajtów z jego sąsiadami. Umieść wynikowy kawałek na liście nieuporządkowanej skrzynki.
Wykonywane są pewne sprawdzenia:
Jeśli kawałek jest kawałkiem górnym:
podwójne zwolnienie lub uszkodzenie (top)
Jeśli następny kawałek znajduje się poza granicami areny:
podwójne zwolnienie lub uszkodzenie (out)
Jeśli kawałek nie jest oznaczony jako używany (w
prev_inuse
z następnego kawałka):podwójne zwolnienie lub uszkodzenie (!prev)
Jeśli następny kawałek ma zbyt mały lub zbyt duży rozmiar:
free(): nieprawidłowy następny rozmiar (normalny)
jeśli poprzedni kawałek nie jest używany, spróbuje go skonsolidować. Ale jeśli prev_size różni się od rozmiaru wskazanego w poprzednim kawałku:
uszkodzony rozmiar vs. prev_size podczas konsolidacji
Last updated