diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vsprintf.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index c150d3dafff4..6ff38524ec16 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -936,6 +936,8 @@ char *uuid_string(char *buf, char *end, const u8 *addr, | |||
936 | return string(buf, end, uuid, spec); | 936 | return string(buf, end, uuid, spec); |
937 | } | 937 | } |
938 | 938 | ||
939 | int kptr_restrict = 1; | ||
940 | |||
939 | /* | 941 | /* |
940 | * Show a '%p' thing. A kernel extension is that the '%p' is followed | 942 | * Show a '%p' thing. A kernel extension is that the '%p' is followed |
941 | * by an extra set of alphanumeric characters that are extended format | 943 | * by an extra set of alphanumeric characters that are extended format |
@@ -979,6 +981,7 @@ char *uuid_string(char *buf, char *end, const u8 *addr, | |||
979 | * Implements a "recursive vsnprintf". | 981 | * Implements a "recursive vsnprintf". |
980 | * Do not use this feature without some mechanism to verify the | 982 | * Do not use this feature without some mechanism to verify the |
981 | * correctness of the format string and va_list arguments. | 983 | * correctness of the format string and va_list arguments. |
984 | * - 'K' For a kernel pointer that should be hidden from unprivileged users | ||
982 | * | 985 | * |
983 | * Note: The difference between 'S' and 'F' is that on ia64 and ppc64 | 986 | * Note: The difference between 'S' and 'F' is that on ia64 and ppc64 |
984 | * function pointers are really function descriptors, which contain a | 987 | * function pointers are really function descriptors, which contain a |
@@ -1035,6 +1038,25 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, | |||
1035 | return buf + vsnprintf(buf, end - buf, | 1038 | return buf + vsnprintf(buf, end - buf, |
1036 | ((struct va_format *)ptr)->fmt, | 1039 | ((struct va_format *)ptr)->fmt, |
1037 | *(((struct va_format *)ptr)->va)); | 1040 | *(((struct va_format *)ptr)->va)); |
1041 | case 'K': | ||
1042 | /* | ||
1043 | * %pK cannot be used in IRQ context because its test | ||
1044 | * for CAP_SYSLOG would be meaningless. | ||
1045 | */ | ||
1046 | if (in_irq() || in_serving_softirq() || in_nmi()) { | ||
1047 | if (spec.field_width == -1) | ||
1048 | spec.field_width = 2 * sizeof(void *); | ||
1049 | return string(buf, end, "pK-error", spec); | ||
1050 | } else if ((kptr_restrict == 0) || | ||
1051 | (kptr_restrict == 1 && | ||
1052 | has_capability_noaudit(current, CAP_SYSLOG))) | ||
1053 | break; | ||
1054 | |||
1055 | if (spec.field_width == -1) { | ||
1056 | spec.field_width = 2 * sizeof(void *); | ||
1057 | spec.flags |= ZEROPAD; | ||
1058 | } | ||
1059 | return number(buf, end, 0, spec); | ||
1038 | } | 1060 | } |
1039 | spec.flags |= SMALL; | 1061 | spec.flags |= SMALL; |
1040 | if (spec.field_width == -1) { | 1062 | if (spec.field_width == -1) { |