hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/x86/kernel/static_call.c
....@@ -123,6 +123,19 @@
123123 */
124124 bool __static_call_fixup(void *tramp, u8 op, void *dest)
125125 {
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
+
126139 if (memcmp(tramp+5, tramp_ud, 3)) {
127140 /* Not a trampoline site, not our problem. */
128141 return false;