Skip to contentSkip to conversation

ptrace bugs and related problems

DISCUSSION Chuck Ebbert 1 participant 1 message Aug 1, 2006

lore
Share & tools
lore
#0 lore raw

In-Reply-To: <[email protected]>

Quoted 7 lines · Albert Cahalan
Quoted 6 lines
Quoted 4 lines

There is also no check
for failure, as when the popf or iret takes an alignment exception or hits an unmapped page.

Can that happen?

Quoted 8 lines

You're at a popf that can not complete.
You single-step.
The kernel sets TF.
The kernel notes the popf.
The kernel assumes that TF will be determined by the popf. The kernel tries to run the popf.
The popf faults, leaving TF unmodified.
The kernel fails to clear TF.

That can be fixed, but it won't be easy.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

There is the pushf problem. Single-stepping this simple code
does not work: pushf ; popf

The debugger needs to mask TF in the pushed flags. Read the comment in is_at_popf().

I think the term is "known bug".

Well at least it's known. :)

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

The is_at_popf function on x86-64 fails to account for instruction set differences. Many prefixes are only valid in 32-bit mode, and many others are only valid in 64-bit mode.

There is a problem with instruction length though. The buffer is 16 bytes long, but should be only 15.

OK.

Quoted 1 line

The 0xf0 (lock) prefix is not valid for popf or iret.

I think it is OK on really old processors (maybe only 386?) If we fix the above problem with faulting instructions then the fault this would cause on newer CPUs should not be a problem.

Signature · 1 line
Chuck