| 1 | #!/bin/bash |
| 2 | # SPDX-License-Identifier: GPL-2.0 |
| 3 | # |
| 4 | # What a data object's checksum has to cover. |
| 5 | # |
| 6 | # checksum_update_object() hashes the symbol's length, its bytes (when the |
| 7 | # section has any -- .bss does not), and then |
| 8 | # every relocation it carries -- as the target's name plus the adjusted addend, |
| 9 | # except for a reference into a string section, which contributes the string's |
| 10 | # contents instead. |
| 11 | # |
| 12 | # Each of those is load-bearing, and the failure is always the same shape: a |
| 13 | # checksum that ignores one of them calls a changed object unchanged, klp diff |
| 14 | # leaves it out of the patch, and the patched code goes on reading the |
| 15 | # kernel's old copy. Nothing says so at build time. |
| 16 | # |
| 17 | # The string case is the one that cannot be caught by hashing bytes alone. The |
| 18 | # pointer is identical -- same section, same offset -- and only the text it |
| 19 | # refers to moved. |
| 20 | # |
| 21 | # Covers the same ground as corpus/x86_64/checksum-data-basic, |
| 22 | # checksum-data-func-ptr, checksum-data-string-ptr and checksum-string-reloc in |
| 23 | # Joe Lawrence's klp-build unit test corpus. |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | # check <flag> <symbol> <what changed> |
| 30 | # |
| 31 | # Build the pair with one difference and require that symbol's checksum to move. |
| 32 | |
| 33 | { |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | } |
| 39 | |
| 40 | # The object's own bytes. |
| 41 | |
| 42 | # Its length, for a .bss object whose bytes are not hashed at all. |
| 43 | |
| 44 | # A relocation's target: same bytes in the object, different symbol named. |
| 45 | |
| 46 | |
| 47 | # The contents of a string the object points at, with the pointer untouched. |
| 48 | |
| 49 | # A relocation's addend: same target symbol, different offset into it. |
| 50 | |
| 51 | # The same, for a static reached through its section symbol: the reference has |
| 52 | # to be resolved back to the object before there is a name or offset to hash. |
| 53 | |
| 54 | |
| 55 | # Having shown five things that must change it, show one that must not: an |
| 56 | # unrelated edit elsewhere in the file leaves this object alone. |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 |