| .. | .. |
|---|
| 123 | 123 | */ |
|---|
| 124 | 124 | bool __static_call_fixup(void *tramp, u8 op, void *dest) |
|---|
| 125 | 125 | { |
|---|
| 126 | + unsigned long addr = (unsigned long)tramp; |
|---|
| 127 | + /* |
|---|
| 128 | + * Not all .return_sites are a static_call trampoline (most are not). |
|---|
| 129 | + * Check if the 3 bytes after the return are still kernel text, if not, |
|---|
| 130 | + * then this definitely is not a trampoline and we need not worry |
|---|
| 131 | + * further. |
|---|
| 132 | + * |
|---|
| 133 | + * This avoids the memcmp() below tripping over pagefaults etc.. |
|---|
| 134 | + */ |
|---|
| 135 | + if (((addr >> PAGE_SHIFT) != ((addr + 7) >> PAGE_SHIFT)) && |
|---|
| 136 | + !kernel_text_address(addr + 7)) |
|---|
| 137 | + return false; |
|---|
| 138 | + |
|---|
| 126 | 139 | if (memcmp(tramp+5, tramp_ud, 3)) { |
|---|
| 127 | 140 | /* Not a trampoline site, not our problem. */ |
|---|
| 128 | 141 | return false; |
|---|