Page MenuHomeFreeBSD

get*ent: be consistant about _ALIGN(p) - p
ClosedPublic

Authored by brooks on Nov 27 2025, 3:33 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jan 12, 3:31 AM
Unknown Object (File)
Sat, Jan 10, 4:49 PM
Unknown Object (File)
Sat, Jan 10, 4:39 PM
Unknown Object (File)
Sat, Jan 10, 4:39 PM
Unknown Object (File)
Sat, Jan 10, 4:28 PM
Unknown Object (File)
Sat, Jan 10, 5:20 AM
Unknown Object (File)
Sat, Jan 10, 5:07 AM
Unknown Object (File)
Sat, Jan 10, 4:46 AM
Subscribers

Details

Summary

Add an nscache specific inline function to calculate the misalignment
rather than adding and subtracting _ALIGN(p) and p which can take the
buffer far out of bound (undefined behavior in C and unsupported on
CHERI).

Obtained from: CheriBSD
Effort: CHERI upstreaming
Sponsored by: DARPA

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

May be define some inline function in libc/include/libc_private.h, like

static inline ptrdiff_t
misalign_val(void *p)
{
   return (_ALIGN(p) - p);
}

and use it in all places.

Add an inline function to compute the misalignment. To it in nscache.h
rather than libc_private.h as that's also a private header and I don't
want this sort of thing to spread.

This revision is now accepted and ready to land.Nov 28 2025, 2:38 PM
This revision was automatically updated to reflect the committed changes.