Skip to content

Commit 6e7c31e

Browse files
Ravi Bangoriagregkh
authored andcommitted
powerpc/watchpoint/ptrace: Fix SETHWDEBUG when CONFIG_HAVE_HW_BREAKPOINT=N
[ Upstream commit 9b6b7c6 ] When kernel is compiled with CONFIG_HAVE_HW_BREAKPOINT=N, user can still create watchpoint using PPC_PTRACE_SETHWDEBUG, with limited functionalities. But, such watchpoints are never firing because of the missing privilege settings. Fix that. It's safe to set HW_BRK_TYPE_PRIV_ALL because we don't really leak any kernel address in signal info. Setting HW_BRK_TYPE_PRIV_ALL will also help to find scenarios when kernel accesses user memory. Reported-by: Pedro Miraglia Franco de Carvalho <pedromfc@linux.ibm.com> Suggested-by: Pedro Miraglia Franco de Carvalho <pedromfc@linux.ibm.com> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20200902042945.129369-4-ravi.bangoria@linux.ibm.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 6dac332 commit 6e7c31e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/powerpc/kernel/ptrace/ptrace-noadv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ long ppc_set_hwdebug(struct task_struct *child, struct ppc_hw_breakpoint *bp_inf
217217
return -EIO;
218218

219219
brk.address = ALIGN_DOWN(bp_info->addr, HW_BREAKPOINT_SIZE);
220-
brk.type = HW_BRK_TYPE_TRANSLATE;
220+
brk.type = HW_BRK_TYPE_TRANSLATE | HW_BRK_TYPE_PRIV_ALL;
221221
brk.len = DABR_MAX_LEN;
222222
brk.hw_len = DABR_MAX_LEN;
223223
if (bp_info->trigger_type & PPC_BREAKPOINT_TRIGGER_READ)

0 commit comments

Comments
 (0)