mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:04:59 +00:00
LibC: Don't honor LIBC_* malloc debugging flags in AT_SECURE context
Just ignore all these environment flags if the AT_SECURE flag is set in the program's auxiliary vector. This prevents a user from tricking set-uid programs into dumping debug information via environment flags.
This commit is contained in:
parent
9984201634
commit
fc4eae87f8
3 changed files with 35 additions and 6 deletions
|
@ -29,6 +29,7 @@
|
|||
#include <AK/LogStream.h>
|
||||
#include <AK/ScopedValueRollback.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibELF/AuxiliaryVector.h>
|
||||
#include <LibThread/Lock.h>
|
||||
#include <assert.h>
|
||||
#include <mallocdefs.h>
|
||||
|
@ -430,13 +431,14 @@ void* realloc(void* ptr, size_t size)
|
|||
void __malloc_init()
|
||||
{
|
||||
new (&malloc_lock()) LibThread::Lock();
|
||||
if (getenv("LIBC_NOSCRUB_MALLOC"))
|
||||
|
||||
if (secure_getenv("LIBC_NOSCRUB_MALLOC"))
|
||||
s_scrub_malloc = false;
|
||||
if (getenv("LIBC_NOSCRUB_FREE"))
|
||||
if (secure_getenv("LIBC_NOSCRUB_FREE"))
|
||||
s_scrub_free = false;
|
||||
if (getenv("LIBC_LOG_MALLOC"))
|
||||
if (secure_getenv("LIBC_LOG_MALLOC"))
|
||||
s_log_malloc = true;
|
||||
if (getenv("LIBC_PROFILE_MALLOC"))
|
||||
if (secure_getenv("LIBC_PROFILE_MALLOC"))
|
||||
s_profiling = true;
|
||||
|
||||
for (size_t i = 0; i < num_size_classes; ++i) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue