Skip to content

Conversation

@RoundofThree
Copy link
Member

If the new base pointer obtained in snl_realloc_msg_buffer does not have the same bounds as the original base pointer, we need to re-derive all the capabilities that are relative to the base. This was found while fuzzing.

Tagging @YiChenChai.

If the new base pointer obtained in snl_realloc_msg_buffer
does not have the same bounds as the original base pointer,
we need to re-derive all the capabilities that are relative to
the base.
Comment on lines +1102 to +1104
int hdr_off = (char *)(nw->hdr) - nw->base;
nw->hdr = (struct nlmsghdr *)
(void *)((char *)nw->base + hdr_off);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
int hdr_off = (char *)(nw->hdr) - nw->base;
nw->hdr = (struct nlmsghdr *)
(void *)((char *)nw->base + hdr_off);
int hdr_off = (char *)(nw->hdr) - nw->base;
nw->hdr = (struct nlmsghdr *)
(void *)((char *)nw->base + hdr_off);

to match existing formatting

}
#ifdef __CHERI_PURE_CAPABILITY__
if (cheri_getlen(new_base) != cheri_getlen(nw->base)) {
nw->base = (char *)cheri_setboundsexact(new_base, nw->size);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't snl_allocz already do this?

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.

3 participants