--- zzzz-none-000/linux-5.4.213/lib/vsprintf.c 2022-09-15 10:04:56.000000000 +0000 +++ miami-7690-761/linux-5.4.213/lib/vsprintf.c 2024-05-29 11:20:02.000000000 +0000 @@ -48,6 +48,14 @@ #include /* cpu_to_le16 */ #include + +#if defined(CONFIG_AVM_ENHANCED) +#include +#include +#endif/*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ + +#include + #include "kstrtox.h" static unsigned long long simple_strntoull(const char *startp, size_t max_chars, @@ -767,6 +775,13 @@ } early_initcall(initialize_ptr_random); +#if defined(CONFIG_AVM_ENHANCED) && !defined(CONFIG_RANDOMIZE_BASE) +static char *ptr_to_id(char *buf, char *end, const void *ptr, + struct printf_spec spec) +{ + return pointer_string(buf, end, ptr, spec); +} +#else /* Maps a pointer to a 32 bit unique identifier. */ static char *ptr_to_id(char *buf, char *end, const void *ptr, struct printf_spec spec) @@ -805,6 +820,7 @@ #endif return pointer_string(buf, end, (const void *)hashval, spec); } +#endif int kptr_restrict __read_mostly; @@ -942,8 +958,10 @@ struct printf_spec spec, const char *fmt) { unsigned long value; -#ifdef CONFIG_KALLSYMS char sym[KSYM_SYMBOL_LEN]; +#ifndef CONFIG_KALLSYMS + struct module *mod; + int len; #endif if (fmt[1] == 'R') @@ -954,14 +972,24 @@ if (*fmt == 'B') sprint_backtrace(sym, value); else if (*fmt != 'f' && *fmt != 's') +#if defined(CONFIG_AVM_ENHANCED) + print_memory_classifier(sym, sizeof(sym), value, 1); +#else sprint_symbol(sym, value); +#endif/*--- #if defined(CONFIG_AVM_ENHANCED) ---*/ else sprint_symbol_no_offset(sym, value); return string_nocheck(buf, end, sym, spec); #else - return special_hex_number(buf, end, value, sizeof(void *)); + len = snprintf(sym, sizeof(sym), "0x%lx", value); + mod = __module_address(value); + if (mod) + snprintf(sym + len, sizeof(sym) - len, " [%s@%p+0x%x]", + mod->name, mod->core_layout.base, + mod->core_layout.size); #endif + return string(buf, end, sym, spec); } static const struct printf_spec default_str_spec = {