public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Fixes for memory allocation bugs
@ 2020-08-11 23:05 Keith Packard
  2020-08-11 23:05 ` [PATCH 1/4] libc/stdlib: Use __builtin_mul_overflow for reallocarray and calloc Keith Packard
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Keith Packard @ 2020-08-11 23:05 UTC (permalink / raw)
  To: newlib

There are two serious bug fixes here:

 1) Check calloc/reallocarray for overflow in the multiply using
    __builtin_mul_overflow (which exists in gcc and clang). reallocarray
    was using some old BSD code for this, but __builtin_mul_overflow is
    both more efficient and more easily checked for correctness.

 2) nano_realloc was copying too many bytes from the existing
    allocation when increasing the allocation size. This could lead to
    information disclosure, or a crash.

And a couple of minor improvements:

 3) When nano_realloc is shrinking "a lot", re-allocate the
    buffer to make the original memory available.

 4) When nano_realloc is shrinking and the new allocation fails,
    just return the old buffer to avoid having applications see
    unnecessary failures.



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-08-17  9:54 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-11 23:05 [PATCH 0/4] Fixes for memory allocation bugs Keith Packard
2020-08-11 23:05 ` [PATCH 1/4] libc/stdlib: Use __builtin_mul_overflow for reallocarray and calloc Keith Packard
2020-08-12  8:13   ` Corinna Vinschen
2020-08-11 23:05 ` [PATCH 2/4] libm/stdlib: don't read past source in nano_realloc Keith Packard
2020-08-12  8:01   ` Corinna Vinschen
2020-08-11 23:05 ` [PATCH 3/4] libm/stdlib: Realloc when shrinking by 2* or more Keith Packard
2020-08-12  8:08   ` Corinna Vinschen
2020-08-12 15:01     ` Keith Packard
2020-08-13  7:59       ` Corinna Vinschen
2020-08-14  0:48         ` Keith Packard
2020-08-17  9:54           ` Corinna Vinschen
2020-08-11 23:05 ` [PATCH 4/4] libm/stdlib: Recover from realloc failure when shrinking Keith Packard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).