# HWASan, ASan, KASAN

## HWASan, ASan, KASAN 란?

Hardware Address Sanitizer(HWASan), Address Sanitizer(ASan), Kernel Address Sanitizer(KASAN)는 개발 중에 사용해야 하는 일련의 메모리 버그 감지 도구입니다.

2x CPU, 15\~30% RAM(ASan: 100% RAM), 50% 코드 크기 등 상당한 오버헤드를 추가하는 각 메모리 작업의 컴파일러 계측을 삽입하므로 프로덕션에 사용하기에 적합하지 않습니다.\
계측은 각 메모리 작업에 삽입되므로 스택 및 전역에 적용되는 것을 포함하여 더 다양한 메모리 안전 버그를 감지합니다. 이는 위의 섹션에서 설명한 힙 감지 도구를 보완합니다.

개발자는 `/data/tombstones` 또는 `logcat`에서 버그 신고를 확인하여 비정상 종료가 있는지 확인해야 합니다.

## 사용자 공간 메모리 안전 버그를 감지하기 위한 HWASan 및 ASan  <a href="#hwasan-asan-detecting-userspace" id="hwasan-asan-detecting-userspace"></a>

`arm64`에서는 **HWASan**을 사용하는 것이 좋고 32비트 `arm` 및 Arm이 아닌 플랫폼의 경우에는 **ASan**을 사용하는 것이 좋습니다. 기능은 동일하며 사용자 공간 코드에서 메모리 안전 버그를 감지하는 데 사용해야 합니다.

사용 설정하려면 별도의 빌드가 필요합니다. 바이너리가 주소가 없는 정리 버전과 호환되지 않기 때문입니다. HWASan을 사용 설정하려면 빌드 환경에서 `SANITIZE_TARGET=hwaddress`를 설정하거나 간단히 `_hwasan-` 접미사가 있는 타겟을 사용합니다.\
HWASan 및 ASan에 관한 자세한 내용은 문서를 참고하세요.

### 커널 메모리 안전 버그를 감지하기 위한 KASAN  <a href="#kasan-kernel-memory-safety" id="kasan-kernel-memory-safety"></a>

KASAN은 위 사용자 공간 도구의 커널 버전입니다. 동일한 컴파일러 구현을 공유합니다. KASAN과 ASan/HWASan은 한 도구가 커널에 적용되고 다른 도구는 사용자 공간에 적용되므로 상호 보완적입니다. 빌드 구성 수를 줄이고 테스트 매트릭스를 줄이려면 두 가지를 동시에 사용 설정하는 것이 좋습니다.

## 출처 : [바로가기 ](https://source.android.com/)

### 참고 : [HWAddress Sanitizerarrow 바로가기](https://source.android.com/docs/security/test/hwasan?hl=ko) <a href="#memory-unsafety" id="memory-unsafety"></a>

### 참고 : [Address Sanitizerarrow 바로가기](https://source.android.com/docs/security/test/asan?hl=ko) <a href="#memory-unsafety" id="memory-unsafety"></a>

{% embed url="<https://doc.skill.or.kr>" %}
NHN Cloud 정보 사이트&#x20;
{% endembed %}

{% embed url="<https://ssv.skill.or.kr>" %}
취약점 진단 분석 평가 방법 사이트
{% endembed %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sul.skill.or.kr/android-security-test/undefined-2/hwasan-asan-kasan.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
