Commit bd40513
perf/core: Avoid put_page() when GUP fails
commit 4716023 upstream.
PEBS PERF_SAMPLE_PHYS_ADDR events use perf_virt_to_phys() to convert PMU
sampled virtual addresses to physical using get_user_page_fast_only()
and page_to_phys().
Some get_user_page_fast_only() error cases return false, indicating no
page reference, but still initialize the output page pointer with an
unreferenced page. In these error cases perf_virt_to_phys() calls
put_page(). This causes page reference count underflow, which can lead
to unintentional page sharing.
Fix perf_virt_to_phys() to only put_page() if get_user_page_fast_only()
returns a referenced page.
Fixes: fc7ce9c ("perf/core, x86: Add PERF_SAMPLE_PHYS_ADDR")
Signed-off-by: Greg Thelen <gthelen@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20211111021814.757086-1-gthelen@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent df58fb4 commit bd40513
1 file changed
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7036 | 7036 | | |
7037 | 7037 | | |
7038 | 7038 | | |
7039 | | - | |
7040 | 7039 | | |
7041 | 7040 | | |
7042 | 7041 | | |
| |||
7055 | 7054 | | |
7056 | 7055 | | |
7057 | 7056 | | |
| 7057 | + | |
| 7058 | + | |
7058 | 7059 | | |
7059 | | - | |
| 7060 | + | |
7060 | 7061 | | |
| 7062 | + | |
| 7063 | + | |
7061 | 7064 | | |
7062 | 7065 | | |
7063 | | - | |
7064 | | - | |
7065 | | - | |
7066 | 7066 | | |
7067 | 7067 | | |
7068 | 7068 | | |
| |||
0 commit comments