Page MenuHomeFreeBSD

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

Authored by brooks on Thu, Nov 27, 3:33 PM.
Tags
None
Referenced Files
F140032898: D53945.id.diff
Fri, Dec 19, 8:03 AM
Unknown Object (File)
Mon, Dec 15, 2:28 PM
Unknown Object (File)
Mon, Dec 15, 6:14 AM
Unknown Object (File)
Sat, Dec 13, 8:47 PM
Unknown Object (File)
Thu, Dec 4, 3:30 PM
Unknown Object (File)
Thu, Dec 4, 8:17 AM
Unknown Object (File)
Wed, Dec 3, 5:37 PM
Unknown Object (File)
Wed, Dec 3, 7:58 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.Fri, Nov 28, 2:38 PM
This revision was automatically updated to reflect the committed changes.