| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Change-Id: Ic7391be8575eaaac76914dab62bc41c9773d703d
|
|
|
|
|
|
|
|
|
|
|
| |
We only need one logging API, and I prefer the one that does no
allocation and is thus safe to use in any context.
Also use O_CLOEXEC when opening the /dev/log files.
Move everything logging-related into one header file.
Change-Id: Ic1e3ea8e9b910dc29df351bff6c0aa4db26fbb58
|
|
|
|
|
|
| |
Avoid duplicating huge chunks of code.
Change-Id: Id6145cdfce781c5ffba2abaaa79681d25a7ab28f
|
|
|
|
|
|
| |
This change compliments 049e58369c37fdeacd0380a6bf1e078d9baf819f
Change-Id: I27d015d70a520713c7472558a3c427f546d36ee4
|
|
|
|
|
|
| |
Detect when strchr reads off the end of a buffer.
Change-Id: I0e952eedcff5c36d646a9c3bc4e1337b959224f2
|
|
|
|
| |
Change-Id: Ie0b3f8b3fccef28609eb210434413ebd51d6ef45
|
|
|
|
|
|
|
| |
I'll need at least one more pass, because there's some upstream code
lurking in libc/bionic, but this is still a step in the right direction.
Change-Id: I55927315972da8327ae01c5240ed587db17e8462
|
|
|
|
|
|
| |
psiginfo(3).
Change-Id: I426109db25e907980d6cb3a7a695796e45783b78
|
|
|
|
|
|
|
|
| |
This reverts commit 8793e7c7d21a0434d1b5e63364c88b2b125a3d29,
and fixes the build by building upstream NetBSD source as a
separate library that's then swallowed whole into libc_common.
Change-Id: I6c9317d8c48b5ccaf85a7b185bc07fb31176ff97
|
|
|
|
|
|
| |
This reverts commit be1d78b0dc899a732c0e9d7515d3023e8004e368
Change-Id: I11a95db474796f3da004f27652b081d5ba4ec9b4
|
|
|
|
|
|
|
|
| |
There were two bugs in our implementation. Intel found one, but another
remainined, and tracking upstream is the way forward for functions where
we add no value.
Change-Id: Ida9bac0293fb2c4cbc942b1e0515ee0477c6538b
|
|
|
|
|
|
|
|
| |
Use the system supplied error numbers when mapping error numbers to messages.
Change-Id: I520556fa3e2ff668fdc4eda36ad31491fbb48ea8
Signed-off-by: Chris Dearman <chris@mips.com>
Signed-off-by: Raghu Gandham <raghu@mips.com>
|
|
|
|
|
|
|
|
| |
Performance regressions. Hopefully this is a temporary
rollback.
Bug: 6821003
Change-Id: I84abbb89e1739d506b583f2f1668f31534127764
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This test is designed to detect code such as:
int main() {
char buf[10];
memcpy(buf, "1234567890", sizeof(buf));
size_t len = strlen(buf); // segfault here with _FORTIFY_SOURCE
printf("%d\n", len);
return 0;
}
or anytime strlen reads beyond an object boundary. This should
help address memory leakage vulnerabilities and make other
unrelated vulnerabilities harder to exploit.
Change-Id: I354b425be7bef4713c85f6bab0e9738445e00182
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In our previous FORTIFY_SOURCE change, we started using a custom
inline for memcpy(), rather than using GCC's __builtin_memcpy_chk().
This allowed us to delete our copy of __memcpy_chk(), and replace it
by __memcpy_chk2().
Apparently GCC uses __memcpy_chk() outside of __builtin_memcpy_chk().
Specifically, __memcpy_chk() is used by __builtin__memMOVE_chk() under
certain optimization levels.
Keep the old __memcpy_chk() function around, and have it call into
__memcpy_chk2().
Change-Id: I2453930b24b8a492a3b6ed860e18d92a6b762b80
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Two changes:
1) Detect memory read overruns.
For example:
int main() {
char buf[10];
memcpy(buf, "abcde", sizeof(buf));
sprintf("%s\n", buf);
}
because "abcde" is only 6 bytes, copying 10 bytes from it is a bug.
This particular bug will be detected at compile time. Other similar
bugs may be detected at runtime.
2) Detect overlapping buffers on memcpy()
It is a bug to call memcpy() on buffers which overlap. For
example, the following code is buggy:
char buf3[0x800];
char *first_half = &buf3[0x400];
char *second_half = &buf3[1];
memset(buf3, 0, sizeof(buf3));
memcpy(first_half, second_half, 0x400);
printf("1: %s\n", buf3);
We now detect this at compile and run time.
Change-Id: I092bd89f11f18e08e8a9dda0ca903aaea8e06d91
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
memmove() unconditionally calls memcpy() if "dst" < "src". For
example, in the code below, memmove() would end up calling memcpy(),
even though the regions of memory overlap.
int main() {
char buf3[0x800];
char *dst = &buf3[1];
char *src = &buf3[0x400];
memset(buf3, 0, sizeof(buf3));
memmove(dst, src, 0x400);
printf("1: %s\n", buf3);
return 0;
}
Calling memcpy() on overlaping regions only works if you assume
that memcpy() copies from start to finish. On some architectures,
it's more efficient to call memcpy() from finish to start.
This is also triggering a failure in some of my code.
More reading:
* http://lwn.net/Articles/414467/
* https://bugzilla.redhat.com/show_bug.cgi?id=638477#c31 (comment 31)
Change-Id: I65a51ae3a52dd4af335fe5c278056b8c2cbd8948
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add strlcpy / strlcat support to FORTIFY_SOURCE. This allows
us to do consistency checks on to ensure we don't overflow buffers
when the compiler is able to tell us the size of the buffer we're
dealing with.
Unlike previous changes, this change DOES NOT use the compiler's
builtin support. Instead, we do everything the compiler would
normally do.
Change-Id: I47c099a911382452eafd711f8e9bfe7c2d0a0d22
|
|
|
|
| |
Change-Id: I3bf4fa8678c33187cb8ce4b75e666ddcd24403ab
|
|
|
|
|
|
|
| |
Ensure that strcat / strncat check for integer overflows
when computing the length of the resulting string.
Change-Id: Ib806ad33a0d3b50876f384bc17787a28f0dddc37
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add _FORTIFY_SOURCE support for the following functions:
* memset
* bzero
Move the __BIONIC_FORTIFY_INLINE definition to cdefs.h so it
can be used from multiple header files.
Change-Id: Iead4d5e35de6ec97786d58ee12573f9b11135bb7
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add initial support for -D_FORTIFY_SOURCE to bionic for the
following functions:
* memcpy
* memmove
* strcpy
* strcat
* strncpy
* strncat
This change adds a new version of the above functions which passes
the size of the destination buffer to __builtin___*_chk.
If the compiler can determine, at compile time, that the destination
buffer is large enough, or the destination buffer can point to an object
of unknown size, then the check call is bypassed.
If the compiler can't make a compile time decision, then it calls
the __*_chk() function, which does a runtime buffer size check
These options are only enabled if the code is compiled with
-D_FORTIFY_SOURCE=1 or 2, and only when optimizations are enabled.
Please see
* http://gcc.gnu.org/onlinedocs/gcc/Object-Size-Checking.html
* http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
for additional details on FORTIFY_SOURCE.
Testing: Compiled the entire Android tree with -D_FORTIFY_SOURCE=1,
and verified that everything appears to be working properly.
Also created a test buffer overflow, and verified that it was
caught by this change.
Change-Id: I4fddb445bafe92b16845b22458d72e6dedd24fbc
|
|
|
|
|
|
|
|
| |
Chars are signed for x86 -- correct the comparison semantics.
Change-Id: I2049e98eb063c0b4e83ea973d3fcae49c6817dde
Author: Liubov Dmitrieva <liubov.dmitrieva@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
|
|
|
|
|
|
|
| |
Everyone else's C library says "Success". We say "Unknown error: 0", which
isn't really true.
Change-Id: I9f9054779123eda996634e5f7a277789b6805809
|
|
|
|
|
|
|
|
|
| |
On ARM there is currently no assembler optimized memmove in libc.
There is however a more optimized bcopy which copies long instead
of bytes where possible. This almost doubles the performance in
best case.
Change-Id: I1f1cd27529443358047c385730deaf938ce4e642
|
|
|
|
| |
Change-Id: I90e578fdc82e427caee8fa4157ce3f8c6c99926d
|
|
|
|
|
|
|
|
| |
This reverts commit 80fba9a2fe4eacaabee99cf0bbead872c2792231,
which caused the system to not boot anymore, aborting with:
"java.lang.RuntimeException: Missing static main on com.android.server.SystemServer".
Change-Id: I745e0a23c728cccf5f95a3c7642d544478a4e57e
|
|
|
|
| |
Change-Id: I5652f4f97ca59d95176443fc27c737ef76258183
|
|
|
|
|
|
|
|
| |
Return a valid pointer (not NULL) when the character "c" is at the end of "src".
Change-Id: Iab0b677943f2c8a9fbb255c44689f5d6dc3535d7
Example:
memccpy(dest, "xzy", 'y', 3) should return dest+3 rather than null.
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
It decreases code size:
text data bss dec hex filename
161 0 0 161 a1 strndup-BEFORE.o
153 0 0 153 99 strndup-AFTER.o
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
|
|\ \
| |/
|/|
| |
| |
| | |
* changes:
Correct generic memset implementation
Generic memcpy should define MEMCOPY before including bcopy.c
|
| |
| |
| |
| | |
Signed-off-by: Chris Dearman <chris@mips.com>
|
| |
| |
| |
| | |
Signed-off-by: Chris Dearman <chris@mips.com>
|
|/
|
|
| |
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
|
| |
|
| |
|
| |
|
|
|