From 64328403b596acc86c216763a1cb9b7f7f7965ed Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Fri, 28 Apr 2017 09:38:54 -0700 Subject: [PATCH] liblog: __android_log_error_write in vndk Also added log_safetynet.h header. This contains a memory sensitive logging function which is used to detect attack attempts. Fixes: 37442967 Test: liblog-unit-tests on internal marlin Test: build liblog with BOARD_VNDK_VERSION := current on aosp_arm Test: libbinder vendor variant links with BOARD_VNDK_VERSION := current Change-Id: Icfcc2b1acbb3712bf4c84403870dc93401eafb15 --- liblog/include/log/log.h | 26 +-------------- liblog/include/log/log_safetynet.h | 44 +++++++++++++++++++++++++ liblog/include_vndk/log/log.h | 1 + liblog/include_vndk/log/log_safetynet.h | 1 + liblog/liblog.map.txt | 1 + 5 files changed, 48 insertions(+), 25 deletions(-) create mode 100644 liblog/include/log/log_safetynet.h create mode 120000 liblog/include_vndk/log/log_safetynet.h diff --git a/liblog/include/log/log.h b/liblog/include/log/log.h index 6758c8415..3a215e976 100644 --- a/liblog/include/log/log.h +++ b/liblog/include/log/log.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include /* helper to define iovec for portability */ @@ -167,31 +168,6 @@ clockid_t android_log_clockid(); /* --------------------------------------------------------------------- */ -#ifndef _ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE -#ifndef __ANDROID_API__ -#define __ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE 1 -#elif __ANDROID_API__ > 22 /* > Lollipop */ -#define __ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE 1 -#else -#define __ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE 0 -#endif -#endif - -#if __ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE - -#define android_errorWriteLog(tag, subTag) \ - __android_log_error_write(tag, subTag, -1, NULL, 0) - -#define android_errorWriteWithInfoLog(tag, subTag, uid, data, dataLen) \ - __android_log_error_write(tag, subTag, uid, data, dataLen) - -int __android_log_error_write(int tag, const char* subTag, int32_t uid, - const char* data, uint32_t dataLen); - -#endif /* __ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE */ - -/* --------------------------------------------------------------------- */ - #ifndef __ANDROID_USE_LIBLOG_CLOSE_INTERFACE #ifndef __ANDROID_API__ #define __ANDROID_USE_LIBLOG_CLOSE_INTERFACE 1 diff --git a/liblog/include/log/log_safetynet.h b/liblog/include/log/log_safetynet.h new file mode 100644 index 000000000..b8ca475ce --- /dev/null +++ b/liblog/include/log/log_safetynet.h @@ -0,0 +1,44 @@ +/* +** +** Copyright 2017, The Android Open Source Project +** +** This file is dual licensed. It may be redistributed and/or modified +** under the terms of the Apache 2.0 License OR version 2 of the GNU +** General Public License. +*/ + +#ifndef _LIBS_LOG_SAFETYNET_H +#define _LIBS_LOG_SAFETYNET_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE +#ifndef __ANDROID_API__ +#define __ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE 1 +#elif __ANDROID_API__ > 22 /* > Lollipop */ +#define __ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE 1 +#else +#define __ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE 0 +#endif +#endif + +#if __ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE + +#define android_errorWriteLog(tag, subTag) \ + __android_log_error_write(tag, subTag, -1, NULL, 0) + +#define android_errorWriteWithInfoLog(tag, subTag, uid, data, dataLen) \ + __android_log_error_write(tag, subTag, uid, data, dataLen) + +int __android_log_error_write(int tag, const char* subTag, int32_t uid, + const char* data, uint32_t dataLen); + +#endif /* __ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE */ + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBS_LOG_SAFETYNET_H */ diff --git a/liblog/include_vndk/log/log.h b/liblog/include_vndk/log/log.h index f93b3770a..01623df22 100644 --- a/liblog/include_vndk/log/log.h +++ b/liblog/include_vndk/log/log.h @@ -8,6 +8,7 @@ #include #include #include +#include #include /* diff --git a/liblog/include_vndk/log/log_safetynet.h b/liblog/include_vndk/log/log_safetynet.h new file mode 120000 index 000000000..a4614e76c --- /dev/null +++ b/liblog/include_vndk/log/log_safetynet.h @@ -0,0 +1 @@ +../../include/log/log_safetynet.h \ No newline at end of file diff --git a/liblog/liblog.map.txt b/liblog/liblog.map.txt index 58fb1486f..3c4c1f10a 100644 --- a/liblog/liblog.map.txt +++ b/liblog/liblog.map.txt @@ -33,6 +33,7 @@ LIBLOG_M { android_logger_get_prune_list; # vndk android_logger_set_prune_list; # vndk android_logger_get_statistics; # vndk + __android_log_error_write; # vndk __android_log_is_loggable; };