2005-09-30 06:34:37

by Zhang, Yanmin

[permalink] [raw]
Subject: RE: [discuss] [PATCH] utilization of kprobe_mutex is incorrect on x86_64

>>-----Original Message-----
>>From: Andi Kleen [mailto:[email protected]]
>>Sent: 2005??9??29?? 22:31
>>To: [email protected]
>>Cc: Zhang, Yanmin; [email protected]; [email protected];
>>[email protected]; Keshavamurthy, Anil S
>>Subject: Re: [discuss] [PATCH] utilization of kprobe_mutex is incorrect on
>>x86_64
>>
>>On Thursday 29 September 2005 16:13, Prasanna S Panchamukhi wrote:
>>> >On Thu, Sep 29, 2005 at 08:43:44AM +0800, Zhang, Yanmin wrote:
>>> >> <<kprobe_incorrect_kprobe_mutex_2.6.14-rc2_x86_64.patch>> I found it
>>> >> when reading the source codes. Basically, the bug could break
>>> >> kprobe_insn_pages under multi-thread environment. PPC arch also has the
>>> >> problem.
>>> >
>>> >Can you describe what the problem actually is?
>>>
>>> Andi,
>>>
>>> The up()/down() orders are incorrect in arch/x86_64/kprobes.c file while
>>> trying to get/remove a kprobes instruction slot in arch_prepare_kprobe()
>>> and arch_remove_kprobe() routines. Zhang's patch corrects this.
>>
>>What I meant is that someone should describe why they are incorrect.
>>I could probably figure it out from the code, but in general the standards
>>for changelogs are higher than just "bla is wrong". It should be more like
>>"bla doesn't do X, so bad thing Y happens, which causes crash Z". Please
>>follow this in future patches.

Andy,
Sorry for lack of detailed explanation. What Prasanna said is correct.
The up()/down() orders are incorrect in arch/x86_64/kprobes.c file. kprobe_mutext is used to protect the free kprobe instruction slot list. arch_prepare_kprobe applies for a slot from the free list, and arch_remove_kprobe returns a slot to the free list. The incorrect up()/down() orders to operate on kprobe_mutex fail to protect the free list. If 2 threads try to get/return kprobe instruction slot at the same time, the free slot list might be broken, or a free slot might be applied by 2 threads. My patch fixes it.