X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/3903760236c30e3b5ace7a4eefac3a269d68957c..a39ff7e25e19b3a8c3020042a3872ca9ec9659f1:/libkern/os/log_encode.h?ds=inline diff --git a/libkern/os/log_encode.h b/libkern/os/log_encode.h index 88839fbd7..4f8afae5c 100644 --- a/libkern/os/log_encode.h +++ b/libkern/os/log_encode.h @@ -27,8 +27,9 @@ #include "log_encode_types.h" #include -#if KERNEL +#ifdef KERNEL #define isdigit(ch) (((ch) >= '0') && ((ch) <= '9')) +extern boolean_t doprnt_hide_pointers; #endif static bool @@ -138,7 +139,7 @@ _os_log_parse_annotated(char *annotated, const char **visibility, const char **l OS_ALWAYS_INLINE static inline bool -_os_log_encode_arg(const void *arg, uint16_t arg_len, os_log_value_type_t ctype, bool is_private, os_log_buffer_context_t context) +_os_log_encode_arg(void *arg, uint16_t arg_len, os_log_value_type_t ctype, bool is_private, os_log_buffer_context_t context) { os_log_buffer_value_t content = (os_log_buffer_value_t) &context->buffer->content[context->content_off]; size_t content_sz = sizeof(*content) + arg_len; @@ -146,6 +147,21 @@ _os_log_encode_arg(const void *arg, uint16_t arg_len, os_log_value_type_t ctype, #ifndef KERNEL bool obj_private = true; #endif + +#ifdef KERNEL + /* scrub kernel pointers */ + if (doprnt_hide_pointers && + ctype == OS_LOG_BUFFER_VALUE_TYPE_SCALAR && + arg_len >= sizeof(void *)) { + unsigned long long value = 0; + memcpy(&value, arg, arg_len); + + if (value >= VM_MIN_KERNEL_AND_KEXT_ADDRESS && value <= VM_MAX_KERNEL_ADDRESS) { + is_private = true; + bzero(arg, arg_len); + } + } +#endif content->type = ctype; content->flags = (is_private ? OS_LOG_CONTENT_FLAG_PRIVATE : 0);