Skip to content
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

[kernel] Experimental heap_free valitity checks #107

Merged
merged 2 commits into from
Nov 24, 2024
Merged

[kernel] Experimental heap_free valitity checks #107

merged 2 commits into from
Nov 24, 2024

Conversation

Mellvik
Copy link
Owner

@Mellvik Mellvik commented Nov 23, 2024

Adds 'canary' based and 'list' based validity checks for heap_free for discussion, re. #105.

@ghaerr, to me these two variants do exactly the same, which means the first (list based) alternative is due for deletion. Do you agree?

@ghaerr
Copy link

ghaerr commented Nov 23, 2024

which means the first (list based) alternative is due for deletion. Do you agree?

Yes!

tlvc/lib/heap.c Outdated

#ifdef HEAPFREE_VALIDATE_2
//printk("Heap canary %x\n", *((char *)data - 1)&0xff);
if ((*((char *)data - 1)&0xff) != HEAP_CANARY) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you just use if (h->canary != HEAP_CANARY) here rather than using complicated pointer arithmetic that also assumes canary is the last struct member?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not my day! Thanks.

@Mellvik Mellvik merged commit 03292ee into master Nov 24, 2024
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.

2 participants