|
@@ -442,8 +442,18 @@ static int branch_type(unsigned long from, unsigned long to)
|
|
|
return X86_BR_NONE;
|
|
|
|
|
|
addr = buf;
|
|
|
- } else
|
|
|
- addr = (void *)from;
|
|
|
+ } else {
|
|
|
+ /*
|
|
|
+ * The LBR logs any address in the IP, even if the IP just
|
|
|
+ * faulted. This means userspace can control the from address.
|
|
|
+ * Ensure we don't blindy read any address by validating it is
|
|
|
+ * a known text address.
|
|
|
+ */
|
|
|
+ if (kernel_text_address(from))
|
|
|
+ addr = (void *)from;
|
|
|
+ else
|
|
|
+ return X86_BR_NONE;
|
|
|
+ }
|
|
|
|
|
|
/*
|
|
|
* decoder needs to know the ABI especially
|