Re: [PATCH] avoid return NULL on root rb_node in rb_next/rb_prev in lib/rbtree.c

From: shenghui
Date: Tue Jun 29 2010 - 03:04:09 EST


2010/6/29 shenghui <crosslonelyover@xxxxxxxxx>:
> 2010/6/28 Peter Zijlstra <peterz@xxxxxxxxxxxxx>:
>> So if ->rb_leftmost is NULL, then the if (!left) check in
>> __pick_next_entity() would return null.
>>
>> As to the NULL deref in in pick_next_task_fair()->set_next_entity() that
>> should never happen because pick_next_task_fair() will bail
>> on !->nr_running.
>>
>> Furthermore, you've failed to mention what kernel version you're looking
>> at.
>>
>
> The kernel version is 2.6.35-rc3, and 2.6.34 has the same code.
>
> For nr->running, if current is the only process in the run queue, then
> nr->running would not be zero.
> 1784 Â Â Â Âif (!cfs_rq->nr_running)
> 1785 Â Â Â Â Â Â Â Âreturn NULL;
> pick_next_task_fair() could pass above check and run to following:
> 1787 Â Â Â Âdo {
> 1788 Â Â Â Â Â Â Â Âse = pick_next_entity(cfs_rq);
> 1789 Â Â Â Â Â Â Â Âset_next_entity(cfs_rq, se);
> 1790 Â Â Â Â Â Â Â Âcfs_rq = group_cfs_rq(se);
> 1791 Â Â Â Â} while (cfs_rq);
>
> Then pick_next_entity will get NULL for current is the root rb_node.
> Then set_next_entity would fail on NULL deference.
>

Sorry, I misunderstood the code. I'll put forward one new patch to
avoid the NULL condition


--


Thanks and Best Regards,
shenghui
--
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/