Re: [PATCH 2/2] ptrace/x86: dont delay perf_event_disable() tillsecond pass in ptrace_write_dr7()

From: Frederic Weisbecker
Date: Tue Apr 16 2013 - 18:00:23 EST


2013/4/16 Oleg Nesterov <oleg@xxxxxxxxxx>:
> On 04/16, Frederic Weisbecker wrote:
>> > rc = ptrace_modify_breakpoint(bp, len, type, tsk, disabled);
>> > if (rc)
>> > break;
>>
>> It would be nice to warn here:
>>
>> WARN_ON_ONCE(rc && second_pass);
>
> Well, I disagree.
>
> To clarify, I agree with WARN_ON_ONCE(), but afaics it has nothing to
> do with "second_pass",
>
>> And these are indeed supposed
>> to.
>
> Indeed, but this is because ptrace_modify_breakpoint() should not fail.
>
> So, what do you think if I change the main loop above
>
> rc = ptrace_modify_breakpoint(...)
> - if (rc)
> + if (WARN_ON_ONCE(rc))
> break;

It can fail in the first pass if dr7 is incorrect. For example passing
a length of 8 in x86-32 is rejected. The type can be wrong too.
But the second pass shouldn't fail. If it was validated once, then it
should be valid a second time.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/