ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
GWP-ASan และ KFENCE
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
GWP-ASan และ KFENCE เป็นเครื่องมือตรวจหาหน่วยความจําแบบน่าจะเป็นสําหรับพื้นที่ผู้ใช้และเคอร์เนลตามลําดับ เมื่อเปิดใช้ จะมีการกันพื้นที่หน่วยความจําจํานวนเล็กน้อยด้วยหน้าหน่วยความจําเพิ่มเติมที่อยู่รอบๆ หน่วยความจําที่กําหนด
ซึ่งช่วยให้ตรวจหาบัฟเฟอร์ที่ล้นและการนําไปใช้หลังจากมีการลบออกได้โดยมีค่าใช้จ่ายด้านประสิทธิภาพเพียงเล็กน้อย แม้จะมีอัตราตัวอย่างขนาดเล็กสำหรับการจัดสรรที่มีการป้องกัน แต่เมื่อนำไปใช้งานในวงกว้าง ก็จะตรวจหาข้อบกพร่องด้านความปลอดภัยของหน่วยความจำได้อย่างมีประสิทธิภาพ
นับตั้งแต่เปิดตัว เครื่องมือเหล่านี้ได้ช่วยระบุข้อบกพร่องของแพลตฟอร์มจำนวนมาก และพิสูจน์แล้วว่าเป็นเครื่องมือที่มีประโยชน์ในการปรับปรุงความเสถียรและความปลอดภัย
เราขอแนะนำให้ผู้ขายเปิดใช้ฟีเจอร์ดังกล่าวและตรวจสอบข้อบกพร่องที่ตรวจพบในอุปกรณ์ของผู้ใช้ปลายทางอย่างใกล้ชิด
นักพัฒนาแอปควรตรวจสอบการขัดข้องโดยดูที่ /data/tombstones
, logcat
หรือตรวจสอบไปป์ไลน์ของผู้ให้บริการ DropboxManager
เพื่อหาข้อบกพร่องของผู้ใช้ปลายทาง
ดูข้อมูลเพิ่มเติมได้ที่เอกสารประกอบเกี่ยวกับการแก้ไขข้อบกพร่องโค้ดเนทีฟของ Android
การแก้ไขข้อบกพร่องโค้ดแพลตฟอร์ม Android เนทีฟarrow_forward
GWP-ASan สำหรับตรวจหาข้อบกพร่องด้านความปลอดภัยของหน่วยความจำในพื้นที่ผู้ใช้
GWP-ASan เปิดตัวใน Android 11 สำหรับการจัดสรรพื้นที่เก็บข้อมูลใน Userspace เมื่อ GWP-ASan ตรวจพบข้อบกพร่อง ระบบจะบันทึกรายงานข้อขัดข้องด้วย Cause: [GWP-ASan]:
และสิ้นสุดกระบวนการ รายงานข้อบกพร่องจะมีข้อมูลการจัดสรรและการยกเลิกการจัดสรรเพิ่มเติม ซึ่งช่วยให้ระบุสาเหตุของปัญหาได้ง่ายขึ้น
GWP-ASan จะเปิดใช้แบบสุ่มเมื่อเริ่มต้นระบบสำหรับ 1% ของกระบวนการหรือแอปของระบบ และสำหรับแอปพลิเคชันที่ตั้งค่า android:gwpAsanMode
ในไฟล์ AndroidManifest.xml
GWP-ASanarrow_forward
KFENCE สำหรับตรวจหาข้อบกพร่องด้านความปลอดภัยของหน่วยความจำเคอร์เนล
Android 12 ได้เปิดตัว KFENCE สำหรับการจองพื้นที่เก็บข้อมูลของเคอร์เนล เมื่อ KFENCE ตรวจพบข้อบกพร่อง ระบบจะบันทึกรายงานข้อขัดข้องโดยขึ้นต้นด้วย BUG: KFENCE,
ปิดใช้หน้าการป้องกันและดำเนินการต่อ
ซึ่งจะเปิดใช้กลไกการตรวจหาข้อบกพร่องของเคอร์เนลที่ส่งผลกระทบต่อประสบการณ์ของผู้ใช้น้อยที่สุด
ดูข้อมูลเพิ่มเติมเกี่ยวกับ KFENCE ได้ในเอกสารประกอบที่ https://www.kernel.org
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-07-27 UTC"],[],[],null,["# GWP-ASan and KFENCE are probabilistic memory detection tools for userspace\nand the kernel, respectively. When enabled, a small number of allocations are\nguarded with additional memory pages that surround the allocated memory.\nThis allows detecting buffer overflows and use-after-frees at a negligible\nperformance overhead. Even with a small sample rate for the guarded allocations,\nwhen deployed at scale they can effectively detect memory safety bugs.\nSince their introduction these tools have helped identify numerous platform\nbugs and have proved to be a valuable tool for improving stability and security.\nWe encourage vendors to enable them and to closely monitor the bugs detected on\nend user devices.\n\n\nDevelopers should check the presence of crashes by checking\n`/data/tombstones`, `logcat` or by monitoring the vendor\n[DropboxManager](https://developer.android.com/reference/android/os/DropBoxManager)\npipeline for end user bugs.\n\n\nFor more information see our docs on debugging Android native\ncode.\n[Debugging Native Android Platform Codearrow_forward](/docs/core/tests/debug)\n\nGWP-ASan for detecting userspace memory safety bugs\n---------------------------------------------------\n\n\nGWP-ASan was introduced in Android 11 for userspace\nheap allocations. When GWP-ASan detects a bug, it records a crash report with\n`Cause: [GWP-ASan]:` and terminates the process. The bug reports\ncontain additional allocation and deallocation information that make it easier\nto identify the root cause.\n\n\nGWP-ASan is randomly enabled, at start-up, for 1% of system processes or\napps and for applications that set the `android:gwpAsanMode` in their\n`AndroidManifest.xml` file.\n[GWP-ASanarrow_forward](https://developer.android.com/ndk/guides/gwp-asan)\n\nKFENCE for detecting kernel memory safety bugs\n----------------------------------------------\n\n\nAndroid 12 introduced KFENCE for kernel heap\nallocations. When KFENCE detects a bug, it records a crash report starting\nwith `BUG: KFENCE,` disables the guard pages and continues execution.\nThis enables a kernel bug detection mechanism that minimally impacts the user\nexperience.\n\n\nTo learn more about KFENCE see the documentation available at [https://www.kernel.org](https://www.kernel.org/doc/html/latest/dev-tools/kfence.html)"]]