Browse files

perf/x86/intel/pt: Do validate the size of a kernel address filter

Right now, the kernel address filters in PT are prone to integer overflow
that may happen in adding filter's size to its offset to obtain the end
of the range. Such an overflow would also throw a #GP in the PT event
configuration path.

Fix this by explicitly validating the result of this calculation.

Reported-by: Adrian Hunter <>
Signed-off-by: Alexander Shishkin <>
Acked-by: Peter Zijlstra <>
Cc: Arnaldo Carvalho de Melo <>
Cc: Arnaldo Carvalho de Melo <>
Cc: Jiri Olsa <>
Cc: Linus Torvalds <>
Cc: Peter Zijlstra <>
Cc: Stephane Eranian <>
Cc: Thomas Gleixner <>
Cc: Vince Weaver <>
Cc: # v4.7
Signed-off-by: Ingo Molnar <>
  • Loading branch information...
virtuoso authored and Ingo Molnar committed Sep 15, 2016
1 parent ddfdad9 commit 1155bafcb79208abc6ae234c6e135ac70607755c
Showing with 7 additions and 2 deletions.
  1. +7 −2 arch/x86/events/intel/pt.c
@@ -1089,8 +1089,13 @@ static int pt_event_addr_filters_validate(struct list_head *filters)
if (!filter->range || !filter->size)
if (!filter->inode && !valid_kernel_ip(filter->offset))
return -EINVAL;
if (!filter->inode) {
if (!valid_kernel_ip(filter->offset))
return -EINVAL;
if (!valid_kernel_ip(filter->offset + filter->size))
return -EINVAL;
if (++range > pt_cap_get(PT_CAP_num_address_ranges))

0 comments on commit 1155baf

Please sign in to comment.