diff options
-rw-r--r-- | arch/x86/kernel/cpu/perf_event_intel_lbr.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/arch/x86/kernel/cpu/perf_event_intel_lbr.c b/arch/x86/kernel/cpu/perf_event_intel_lbr.c index da02e9cc3754..de341d4ec92a 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_lbr.c +++ b/arch/x86/kernel/cpu/perf_event_intel_lbr.c | |||
@@ -442,8 +442,18 @@ static int branch_type(unsigned long from, unsigned long to) | |||
442 | return X86_BR_NONE; | 442 | return X86_BR_NONE; |
443 | 443 | ||
444 | addr = buf; | 444 | addr = buf; |
445 | } else | 445 | } else { |
446 | addr = (void *)from; | 446 | /* |
447 | * The LBR logs any address in the IP, even if the IP just | ||
448 | * faulted. This means userspace can control the from address. | ||
449 | * Ensure we don't blindy read any address by validating it is | ||
450 | * a known text address. | ||
451 | */ | ||
452 | if (kernel_text_address(from)) | ||
453 | addr = (void *)from; | ||
454 | else | ||
455 | return X86_BR_NONE; | ||
456 | } | ||
447 | 457 | ||
448 | /* | 458 | /* |
449 | * decoder needs to know the ABI especially | 459 | * decoder needs to know the ABI especially |