Commit 6571f2a
committed
create-diff-object: handle .rela__bug_table to avoid pulling in entire __bug_table
When building shadow-pid.patch on a debug kernel, it generates
__bug_table, which contains an array of struct bug_entries.
create-diff-object identifies that .text.kernel_clone has changed and it
includes .rela.text.kernel_clone rela section. Then later, it includes
all symbols (in kpatch_include_symbols()) associated with it, which ends
up including __bug_table and its rela section .rela__bug_table. Then,
all the function symbols associated with .rela__bug_table is included
irrespective of whether it's section is included or not.
The problem occurs since WARN() has been converted to a static call,
which passes a reference to its bug table entry (in __bug_table) to the
static call. That direct reference from a function to a special section
is new, and that's causing create-diff-object to incorrectly pull in the
entire __bug_table. (As mentioned by Josh)
It leads to the following modpost errors with
shadow-pid.patch:
kernel/fork.o: changed function: kernel_clone
kernel/exit.o: changed function: do_exit
fs/proc/array.o: changed function: proc_pid_status
make -C /root/linux M=/root/.kpatch/tmp/patch CFLAGS_MODULE=''
make[1]: Entering directory '/root/linux'
make[2]: Entering directory '/root/.kpatch/tmp/patch'
LDS kpatch.lds
CC [M] patch-hook.o
LD [M] test-shadow-newpid.o
MODPOST Module.symvers
WARNING: modpost: missing MODULE_DESCRIPTION() in test-shadow-newpid.o
ERROR: modpost: "replace_mm_exe_file" [test-shadow-newpid.ko] undefined!
ERROR: modpost: "put_task_stack" [test-shadow-newpid.ko] undefined!
ERROR: modpost: "release_task" [test-shadow-newpid.ko] undefined!
ERROR: modpost: "set_mm_exe_file" [test-shadow-newpid.ko] undefined!
Examining the /root/.kpatch/patch/ directory reveals, these symbols are
never referenced in any relas.
readelf -Ws output.o |
grep -E 'put_task_stack|replace_mm_exe_file|release_task|set_mm_exe_file'
27: 0000000000000000 0 SECTION LOCAL DEFAULT 36 .rodata.release_task.str1.2
45: 0000000000000000 0 SECTION LOCAL DEFAULT 55 .rodata.set_mm_exe_file.str1.2
47: 0000000000000000 0 SECTION LOCAL DEFAULT 57 .rodata.replace_mm_exe_file.str1.2
234: 0000000000000000 0 FUNC GLOBAL DEFAULT UND replace_mm_exe_file
254: 0000000000000000 0 FUNC GLOBAL DEFAULT UND put_task_stack
263: 0000000000000000 0 FUNC GLOBAL DEFAULT UND release_task
269: 0000000000000000 0 FUNC GLOBAL DEFAULT UND set_mm_exe_file
readelf -Wr output.o |
grep -E 'put_task_stack|replace_mm_exe_file|release_task|set_mm_exe_file'
<EMPTY>
Solution:
Skip initial symbol inclusion from .rela__bug_table to prevent unwanted
__bug_table propagation caused by static call WARN() relocations. These
relocations are instead handled later during special section
regeneration.
Also recalculate addends of relocations targeting __bug_table when bug
table entries move, ensuring all references remain consistent.
Signed-off-by: Sumanth Korikkar <sumanthk@linux.ibm.com>1 parent 7552b46 commit 6571f2a
1 file changed
Lines changed: 73 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1886 | 1886 | | |
1887 | 1887 | | |
1888 | 1888 | | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
1889 | 1906 | | |
1890 | 1907 | | |
1891 | 1908 | | |
| |||
1906 | 1923 | | |
1907 | 1924 | | |
1908 | 1925 | | |
| 1926 | + | |
| 1927 | + | |
1909 | 1928 | | |
1910 | 1929 | | |
1911 | 1930 | | |
| |||
2791 | 2810 | | |
2792 | 2811 | | |
2793 | 2812 | | |
| 2813 | + | |
| 2814 | + | |
| 2815 | + | |
| 2816 | + | |
| 2817 | + | |
| 2818 | + | |
| 2819 | + | |
| 2820 | + | |
| 2821 | + | |
| 2822 | + | |
| 2823 | + | |
| 2824 | + | |
| 2825 | + | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
| 2829 | + | |
| 2830 | + | |
| 2831 | + | |
| 2832 | + | |
| 2833 | + | |
| 2834 | + | |
| 2835 | + | |
| 2836 | + | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
| 2850 | + | |
2794 | 2851 | | |
2795 | 2852 | | |
2796 | 2853 | | |
2797 | 2854 | | |
2798 | 2855 | | |
2799 | 2856 | | |
2800 | 2857 | | |
2801 | | - | |
| 2858 | + | |
2802 | 2859 | | |
2803 | 2860 | | |
2804 | 2861 | | |
| |||
2852 | 2909 | | |
2853 | 2910 | | |
2854 | 2911 | | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
| 2917 | + | |
| 2918 | + | |
| 2919 | + | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
2855 | 2927 | | |
2856 | 2928 | | |
2857 | 2929 | | |
| |||
0 commit comments