mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-08 09:39:40 +00:00
ARM: 8986/1: hw_breakpoint: Don't invoke overflow handler on uaccess watchpoints
commiteec13b42d4
upstream. Unprivileged memory accesses generated by the so-called "translated" instructions (e.g. LDRT) in kernel mode can cause user watchpoints to fire unexpectedly. In such cases, the hw_breakpoint logic will invoke the user overflow handler which will typically raise a SIGTRAP back to the current task. This is futile when returning back to the kernel because (a) the signal won't have been delivered and (b) userspace can't handle the thing anyway. Avoid invoking the user overflow handler for watchpoints triggered by kernel uaccess routines, and instead single-step over the faulting instruction as we would if no overflow handler had been installed. Cc: <stable@vger.kernel.org> Fixes:f81ef4a920
("ARM: 6356/1: hw-breakpoint: add ARM backend for the hw-breakpoint framework") Reported-by: Luis Machado <luis.machado@linaro.org> Tested-by: Luis Machado <luis.machado@linaro.org> Signed-off-by: Will Deacon <will@kernel.org> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
8eff5a05f2
commit
2fdddd5914
1 changed files with 22 additions and 5 deletions
|
@ -688,6 +688,12 @@ static void disable_single_step(struct perf_event *bp)
|
|||
arch_install_hw_breakpoint(bp);
|
||||
}
|
||||
|
||||
static int watchpoint_fault_on_uaccess(struct pt_regs *regs,
|
||||
struct arch_hw_breakpoint *info)
|
||||
{
|
||||
return !user_mode(regs) && info->ctrl.privilege == ARM_BREAKPOINT_USER;
|
||||
}
|
||||
|
||||
static void watchpoint_handler(unsigned long addr, unsigned int fsr,
|
||||
struct pt_regs *regs)
|
||||
{
|
||||
|
@ -747,16 +753,27 @@ static void watchpoint_handler(unsigned long addr, unsigned int fsr,
|
|||
}
|
||||
|
||||
pr_debug("watchpoint fired: address = 0x%x\n", info->trigger);
|
||||
|
||||
/*
|
||||
* If we triggered a user watchpoint from a uaccess routine,
|
||||
* then handle the stepping ourselves since userspace really
|
||||
* can't help us with this.
|
||||
*/
|
||||
if (watchpoint_fault_on_uaccess(regs, info))
|
||||
goto step;
|
||||
|
||||
perf_bp_event(wp, regs);
|
||||
|
||||
/*
|
||||
* If no overflow handler is present, insert a temporary
|
||||
* mismatch breakpoint so we can single-step over the
|
||||
* watchpoint trigger.
|
||||
* Defer stepping to the overflow handler if one is installed.
|
||||
* Otherwise, insert a temporary mismatch breakpoint so that
|
||||
* we can single-step over the watchpoint trigger.
|
||||
*/
|
||||
if (is_default_overflow_handler(wp))
|
||||
enable_single_step(wp, instruction_pointer(regs));
|
||||
if (!is_default_overflow_handler(wp))
|
||||
goto unlock;
|
||||
|
||||
step:
|
||||
enable_single_step(wp, instruction_pointer(regs));
|
||||
unlock:
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue