Re: [PATCH v2 1/2] MIPS: ptrace: disallow setting watchpoints in kernel address space

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 23 Jan 2017, Marcin Nowakowski wrote:

> With certain EVA configurations it is possible for the kernel address
> space to overlap user address space, which allows the user to set
> watchpoints on kernel addresses via ptrace.
> 
> If a watchpoint is set in the watch exception handling code (after
> exception level has been cleared) then the system will hang in an
> infinite loop when hitting a watchpoint while trying to process it.
> 
> To prevent that simply disallow placing any watchpoints at addresses
> above start of kernel that overlap userspace.

 This can be severely crippling for user debugging.  Is there no better 
way?

 Can't for example the low-level exception handling entry/exit code be 
moved out of the way of the EVA overlap range and then all watchpoints 
masked for the duration of kernel mode execution?  This would be quite 
expensive, however it could only be executed if a task flag indicates 
watchpoints are being used.  Alternatively perhaps we could clobber 
CP0.EntryHi.ASID, at least temporarily; that would be cheaper.

 Overall I think this situation is asking for a watchpoint flag to be 
added to inhibit hits in the kernel mode in hardware; for completeness 
this probably actually ought to be a field to cover the kernel, supervisor 
and user modes separately -- either a plain bitmask for arbitrary control 
or an encoded value similar to CP0.Status.KSU which would indicate the 
most privileged mode to accept a watchpoint in.

 I had a recollection of such a facility already being available for JTAG 
debugging, but I can't track it down in the specification, so perhaps it 
was for another architecture and it would be completely new for ours.

  Maciej




[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux