opnsense-src/lib/libc/amd64
Robert Clausecker 953b93cf24 lib/libc/amd64/string/memcmp.S: harden against phony buffer lengths
When memcmp(a, b, len) (or equally, bcmp) is called with a phony length
such that a + len < a, the code would malfunction and not compare the
two buffers correctly.  While such arguments are illegal (buffers do not
wrap around the end of the address space), it is neverthless conceivable
that people try things like memcmp(a, b, SIZE_MAX) to compare a and b
until the first mismatch, in the knowledge that such a mismatch exists,
expecting memcmp() to stop comparing somewhere around the mismatch.
While memcmp() is usually written to confirm to this assumption, no
version of ISO/IEC 9899 guarantees this behaviour (in contrast to
memchr() for which it is).

Neverthless it appears sensible to at least not grossly misbehave on
phony lengths.  This change hardens memcmp() against this case by
comparing at least until the end of the address space if a + len
overflows a 64 bit integer.

Sponsored by:	The FreeBSD Foundation
Approved by:	mjg (blanket, via IRC)
See also:	b2618b651b
MFC after:	1 week
2023-09-16 00:20:32 -04:00
..
gen Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
stdlib Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
string lib/libc/amd64/string/memcmp.S: harden against phony buffer lengths 2023-09-16 00:20:32 -04:00
sys Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
_fpmath.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
amd64_archlevel.h lib/libc/amd64: add archlevel-based simd dispatch framework 2023-08-04 01:53:43 +03:00
arith.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
gd_qnan.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
Makefile.inc Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
static_tls.h Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
Symbol.map Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:23 -06:00
SYS.h Remove $FreeBSD$: one-line .h pattern 2023-08-16 11:54:23 -06:00