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

netlink: Re-derive the base capability of the snl msg_buffer in realloc #2281

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions sys/netlink/netlink_snl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1095,9 +1095,19 @@
}
nw->base = (char *)new_base;
}
#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?

if (nw->hdr != NULL) {
int hdr_off = (char *)(nw->hdr) - nw->base;
nw->hdr = (struct nlmsghdr *)
(void *)((char *)nw->base + hdr_off);

Check warning on line 1104 in sys/netlink/netlink_snl.h

View workflow job for this annotation

GitHub Actions / Style Checker

line over 80 characters
Comment on lines +1102 to +1104
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

}
}
#endif

return (true);
}

Check warning on line 1110 in sys/netlink/netlink_snl.h

View workflow job for this annotation

GitHub Actions / Style Checker

Missing Signed-off-by: line

static inline void *
snl_reserve_msg_data_raw(struct snl_writer *nw, size_t sz)
Expand Down
Loading