Commit 60c6a00
mm: hwpoison: coredump: support recovery from dump_user_range()
dump_user_range() is used to copy the user page to a coredump file, but if
a hardware memory error occurred during copy, which called from
__kernel_write_iter() in dump_user_range(), it crashes,
CPU: 112 PID: 7014 Comm: mca-recover Not tainted 6.3.0-rc2 torvalds#425
pc : __memcpy+0x110/0x260
lr : _copy_from_iter+0x3bc/0x4c8
...
Call trace:
__memcpy+0x110/0x260
copy_page_from_iter+0xcc/0x130
pipe_write+0x164/0x6d8
__kernel_write_iter+0x9c/0x210
dump_user_range+0xc8/0x1d8
elf_core_dump+0x308/0x368
do_coredump+0x2e8/0xa40
get_signal+0x59c/0x788
do_signal+0x118/0x1f8
do_notify_resume+0xf0/0x280
el0_da+0x130/0x138
el0t_64_sync_handler+0x68/0xc0
el0t_64_sync+0x188/0x190
Generally, the '->write_iter' of file ops will use copy_page_from_iter()
and copy_page_from_iter_atomic(), change memcpy() to copy_mc_to_kernel()
in both of them to handle #MC during source read, which stop coredump
processing and kill the task instead of kernel panic, but the source
address may not always a user address, so introduce a new copy_mc flag in
struct iov_iter{} to indicate that the iter could do a safe memory copy,
also introduce the helpers to set/cleck the flag, for now, it's only used
in coredump's dump_user_range(), but it could expand to any other
scenarios to fix the similar issue.
Link: https://lkml.kernel.org/r/20230417045323.11054-1-wangkefeng.wang@huawei.com
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
Cc: Tong Tiangen <tongtiangen@huawei.com>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>1 parent 605d909 commit 60c6a00
3 files changed
+32
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
882 | 882 | | |
883 | 883 | | |
884 | 884 | | |
| 885 | + | |
885 | 886 | | |
886 | 887 | | |
887 | 888 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
234 | 235 | | |
235 | 236 | | |
236 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
237 | 247 | | |
238 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
239 | 254 | | |
240 | 255 | | |
241 | 256 | | |
| |||
358 | 373 | | |
359 | 374 | | |
360 | 375 | | |
| 376 | + | |
361 | 377 | | |
362 | 378 | | |
363 | 379 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
| 437 | + | |
437 | 438 | | |
438 | 439 | | |
439 | 440 | | |
| |||
630 | 631 | | |
631 | 632 | | |
632 | 633 | | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
633 | 642 | | |
634 | 643 | | |
635 | 644 | | |
| |||
639 | 648 | | |
640 | 649 | | |
641 | 650 | | |
642 | | - | |
| 651 | + | |
643 | 652 | | |
644 | 653 | | |
645 | 654 | | |
| |||
862 | 871 | | |
863 | 872 | | |
864 | 873 | | |
865 | | - | |
| 874 | + | |
866 | 875 | | |
867 | 876 | | |
868 | 877 | | |
| |||
1043 | 1052 | | |
1044 | 1053 | | |
1045 | 1054 | | |
| 1055 | + | |
1046 | 1056 | | |
1047 | 1057 | | |
1048 | 1058 | | |
| |||
1059 | 1069 | | |
1060 | 1070 | | |
1061 | 1071 | | |
| 1072 | + | |
1062 | 1073 | | |
1063 | 1074 | | |
1064 | 1075 | | |
| |||
1105 | 1116 | | |
1106 | 1117 | | |
1107 | 1118 | | |
| 1119 | + | |
1108 | 1120 | | |
1109 | 1121 | | |
1110 | 1122 | | |
| |||
1128 | 1140 | | |
1129 | 1141 | | |
1130 | 1142 | | |
| 1143 | + | |
1131 | 1144 | | |
1132 | 1145 | | |
1133 | 1146 | | |
| |||
0 commit comments