Page MenuHomeFreeBSD

include: de-macro __ssp_overlap(), improve semantics and checking
AcceptedPublic

Authored by kevans on Jul 9 2024, 7:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jan 5, 4:07 AM
Unknown Object (File)
Wed, Dec 25, 3:24 PM
Unknown Object (File)
Tue, Dec 24, 6:54 AM
Unknown Object (File)
Tue, Dec 24, 5:58 AM
Unknown Object (File)
Mon, Dec 23, 7:54 AM
Unknown Object (File)
Dec 5 2024, 2:26 AM
Unknown Object (File)
Nov 22 2024, 8:50 AM
Unknown Object (File)
Nov 2 2024, 1:02 PM
Subscribers

Details

Reviewers
markj
kib
Group Reviewers
Klara
Summary

Switch away from pointer arithmetic to provide more obvious semantics
for checking overlap on pointer ranges. This lets us remove some casts
that need not exist and removes some possible fragility in its use.

While we're here, check for overflow just in case; sometimes we use a
caller-supplied size if __builtin_object_size(3) can't deduce the buffer
size, and we should fail the check if the size is nonsensical for the
provided buffers.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 58596
Build 55484: arc lint + arc unit

Event Timeline

kevans requested review of this revision.Jul 9 2024, 7:51 PM
include/ssp/ssp.h
101

The right <= left condition is redundant, at this point we must have right < left.

include/ssp/wchar.h
34

Extra ws after #define

35

Do we need to check that len * sizeof(wchar_t) doesn't overflow?

kevans marked 3 inline comments as done.

Address review commentary, remove redundant bits and ad an overflow check to
__ssp_wchar_overlap (and make it an inline function as well, instead of a macro).

This revision is now accepted and ready to land.Jul 11 2024, 8:39 PM