Skip to content

Clarify the values for list poison #193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2025
Merged

Clarify the values for list poison #193

merged 1 commit into from
Feb 21, 2025

Conversation

jserv
Copy link
Contributor

@jserv jserv commented Feb 21, 2025

In the Linux kernel, LIST_POISON1 (0x00100100) and LIST_POISON2 (0x00200200) mark freed list nodes so that any later access triggers a fault, catching use-after-free errors. These values are chosen because they lie in the kernel’s virtual address space, are unlikely to be valid pointers, and are easily recognizable in crash dumps.

In kernel space this works reliably because the kernel controls the address space and reserves low addresses. In userspace, however, memory is managed differently—with ASLR and possible mappings, these poison addresses might not be unmapped, so dereferencing them may not always fault. For userspace, using NULL (0x0) or custom invalid pointers—and combining poisoning with runtime checks—is a better strategy.

Change-Id: Ifd99e41497d20ce14950826ee20a36170d818e39

In the Linux kernel, LIST_POISON1 (0x00100100) and LIST_POISON2
(0x00200200) mark freed list nodes so that any later access triggers a
fault, catching use-after-free errors. These values are chosen because
they lie in the kernel’s virtual address space, are unlikely to be valid
pointers, and are easily recognizable in crash dumps.

In kernel space this works reliably because the kernel controls the
address space and reserves low addresses. In userspace, however, memory
is managed differently—with ASLR and possible mappings, these poison
addresses might not be unmapped, so dereferencing them may not always
fault. For userspace, using NULL (0x0) or custom invalid pointers—and
combining poisoning with runtime checks—is a better strategy.

Change-Id: Ifd99e41497d20ce14950826ee20a36170d818e39
@jserv jserv merged commit 9013ef3 into master Feb 21, 2025
4 checks passed
@jserv jserv deleted the refine-poison branch February 21, 2025 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant