kdb: Fix the putarea helper function
authorDaniel Thompson <daniel.thompson@linaro.org>
Fri, 28 Jan 2022 14:40:55 +0000 (14:40 +0000)
committerDaniel Thompson <daniel.thompson@linaro.org>
Thu, 24 Mar 2022 16:39:47 +0000 (16:39 +0000)
commitc1cb81429df462eca1b6ba615cddd21dd3103c46
tree2aee1cbf8dd28849585f83aab94a9deefba254b8
parent09688c0166e76ce2fb85e86b9d99be8b0084cdf9
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: fe557319aa06 ("maccess: rename probe_kernel_{read,write} to copy_{from,to}_kernel_nofault")
Fixes: 5d5314d6795f ("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
kernel/debug/kdb/kdb_support.c