Skip to content

Commit 1155baf

Browse files
virtuosoIngo Molnar
authored andcommitted
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 <[email protected]> Signed-off-by: Alexander Shishkin <[email protected]> Acked-by: Peter Zijlstra <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vince Weaver <[email protected]> Cc: [email protected] # v4.7 Cc: [email protected]#v4.7 Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent ddfdad9 commit 1155baf

File tree

1 file changed

+7
-2
lines changed
  • arch/x86/events/intel

1 file changed

+7
-2
lines changed

arch/x86/events/intel/pt.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,8 +1089,13 @@ static int pt_event_addr_filters_validate(struct list_head *filters)
10891089
if (!filter->range || !filter->size)
10901090
return -EOPNOTSUPP;
10911091

1092-
if (!filter->inode && !valid_kernel_ip(filter->offset))
1093-
return -EINVAL;
1092+
if (!filter->inode) {
1093+
if (!valid_kernel_ip(filter->offset))
1094+
return -EINVAL;
1095+
1096+
if (!valid_kernel_ip(filter->offset + filter->size))
1097+
return -EINVAL;
1098+
}
10941099

10951100
if (++range > pt_cap_get(PT_CAP_num_address_ranges))
10961101
return -EOPNOTSUPP;

0 commit comments

Comments
 (0)