| 1 | #!/bin/bash |
| 2 | # SPDX-License-Identifier: GPL-2.0 |
| 3 | # |
| 4 | # Patching a module, where the patched code references a vmlinux symbol which |
| 5 | # needs a klp relocation. |
| 6 | # |
| 7 | # The kernel does not allow a module-targeted klp relocation to reference a |
| 8 | # vmlinux symbol, and a symbol exported with EXPORT_SYMBOL_FOR_MODULES gets a |
| 9 | # klp relocation. Put together, filing that relocation under the patched |
| 10 | # module produces a patch the kernel refuses to apply to its target. |
| 11 | # |
| 12 | # So it goes under vmlinux instead, and is applied when the patch module loads |
| 13 | # rather than when the patched module does. That is the opposite of the rule |
| 14 | # for a reference to a module's symbol, which test-module-object covers; this |
| 15 | # is the other branch of the same decision. |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | # The object being patched is a module ... |
| 21 | |
| 22 | |
| 23 | # ... and the symbol it references belongs to vmlinux, exported in a way that |
| 24 | # still requires a klp relocation. |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | # Filed against vmlinux, applied when the patch loads. |
| 30 | |
| 31 | |
| 32 | |
| 33 | # Not against the patched module: that is the relocation the kernel rejects. |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 |