Skip to content

Commit c1cb814

Browse files
author
Daniel Thompson
committed
kdb: Fix the putarea helper function
Currently kdb_putarea_size() uses copy_from_kernel_nofault() to write *to* arbitrary kernel memory. This is obviously wrong and means the memory modify ('mm') command is a serious risk to debugger stability: if we poke to a bad address we'll double-fault and lose our debug session. Fix this the (very) obvious way. Note that there are two Fixes: tags because the API was renamed and this patch will only trivially backport as far as the rename (and this is probably enough). Nevertheless Christoph's rename did not introduce this problem so I wanted to record that! Fixes: fe55731 ("maccess: rename probe_kernel_{read,write} to copy_{from,to}_kernel_nofault") Fixes: 5d5314d ("kdb: core for kgdb back end (1 of 2)") Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org> Reviewed-by: Douglas Anderson <dianders@chromium.org> Link: https://lore.kernel.org/r/20220128144055.207267-1-daniel.thompson@linaro.org
1 parent 09688c0 commit c1cb814

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/debug/kdb/kdb_support.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ int kdb_getarea_size(void *res, unsigned long addr, size_t size)
291291
*/
292292
int kdb_putarea_size(unsigned long addr, void *res, size_t size)
293293
{
294-
int ret = copy_from_kernel_nofault((char *)addr, (char *)res, size);
294+
int ret = copy_to_kernel_nofault((char *)addr, (char *)res, size);
295295
if (ret) {
296296
if (!KDB_STATE(SUPPRESS)) {
297297
kdb_func_printf("Bad address 0x%lx\n", addr);

0 commit comments

Comments
 (0)