Skip to content

Commit

Permalink
kenv: Fix preload_delete_name() in purecap kernels
Browse files Browse the repository at this point in the history
It was treating a MODINFO_ADDR token as a capability, but it's a bare
address.  Cast appropriately, like we do in preload_fetch_addr().
  • Loading branch information
markjdb committed Feb 12, 2025
1 parent 725ba63 commit 79cb034
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sys/kern/subr_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ preload_search_info(caddr_t mod, int inf)
void
preload_delete_name(const char *name)
{
caddr_t addr, curp;
caddr_t curp;
vm_offset_t addr;
uint32_t *hdr, sz;
int next;
int clearing;
Expand All @@ -226,7 +227,7 @@ preload_delete_name(const char *name)
if (hdr[0] == MODINFO_NAME || (hdr[0] == 0 && hdr[1] == 0)) {
/* Free memory used to store the file. */
if (addr != 0 && sz != 0)
kmem_bootstrap_free((vm_offset_t)addr, sz);
kmem_bootstrap_free(addr, sz);
addr = 0;
sz = 0;

Expand All @@ -240,7 +241,7 @@ preload_delete_name(const char *name)
}
if (clearing) {
if (hdr[0] == MODINFO_ADDR)
addr = *(caddr_t *)(curp + sizeof(uint32_t) * 2);
addr = *(vm_offset_t *)(curp + sizeof(uint32_t) * 2);
else if (hdr[0] == MODINFO_SIZE)
sz = *(uint32_t *)(curp + sizeof(uint32_t) * 2);
hdr[0] = MODINFO_EMPTY;

Check warning on line 247 in sys/kern/subr_module.c

View workflow job for this annotation

GitHub Actions / Style Checker

Missing Signed-off-by: line
Expand Down

0 comments on commit 79cb034

Please sign in to comment.