Re: possible circular locking dependency in ISDN PPP

From: Xiaotian Feng
Date: Wed Oct 21 2009 - 22:27:41 EST


On Thu, Oct 22, 2009 at 12:24 AM, Tilman Schmidt <tilman@xxxxxxx> wrote:
> Thanks for your analysis. The patch you propose does indeed prevent the
> "circular locking dependency" message, with no noticeable ill effect.
>
> I cannot say why xmit_lock was taken around isdn_net_lp_busy() in the
> first place. The ISDN4Linux people would be the ones to comment on that.
> If none of them objects, I propose you add a Signed-off-by line to your
> patch and submit it to Karsten Keil, the ISDN maintainer, for inclusion.
> You can also add a "Tested-by: Tilman Schmidt <tilman@xxxxxxx>" line.
>

Sure, I'll prepare a patch and send to Karsten later, Thanks.

> Thanks,
> Tilman
>
> Am 19.10.2009 07:27 schrieb Xiaotian Feng:
>> So there's a circular locking dependency.. Looking into isdn_net_get_locked_lp()
> [...]
>> Why do we need to hold xmit_lock while using
>> isdn_net_lp_busy(nd->queue) ? Can following patch fix this bug?
>>
>> ---
>> diff --git a/drivers/isdn/i4l/isdn_net.h b/drivers/isdn/i4l/isdn_net.h
>> index 74032d0..7511f08 100644
>> --- a/drivers/isdn/i4l/isdn_net.h
>> +++ b/drivers/isdn/i4l/isdn_net.h
>> @@ -83,19 +83,19 @@ static __inline__ isdn_net_local *
>> isdn_net_get_locked_lp(isdn_net_dev *nd)
>>
>> Â Â Â Â spin_lock_irqsave(&nd->queue_lock, flags);
>> Â Â Â Â lp = nd->queue; Â Â Â Â /* get lp on top of queue */
>> - Â Â Â spin_lock(&nd->queue->xmit_lock);
>> Â Â Â Â while (isdn_net_lp_busy(nd->queue)) {
>> - Â Â Â Â Â Â Â spin_unlock(&nd->queue->xmit_lock);
>> Â Â Â Â Â Â Â Â nd->queue = nd->queue->next;
>> Â Â Â Â Â Â Â Â if (nd->queue == lp) { /* not found -- should never happen */
>> Â Â Â Â Â Â Â Â Â Â Â Â lp = NULL;
>> Â Â Â Â Â Â Â Â Â Â Â Â goto errout;
>> Â Â Â Â Â Â Â Â }
>> - Â Â Â Â Â Â Â spin_lock(&nd->queue->xmit_lock);
>> Â Â Â Â }
>> Â Â Â Â lp = nd->queue;
>> Â Â Â Â nd->queue = nd->queue->next;
>> + Â Â Â spin_unlock_irqrestore(&nd->queue_lock, flags);
>> + Â Â Â spin_lock(&lp->xmit_lock);
>> Â Â Â Â local_bh_disable();
>> + Â Â Â return lp;
>> Âerrout:
>> Â Â Â Â spin_unlock_irqrestore(&nd->queue_lock, flags);
>> Â Â Â Â return lp;
>>
>
> --
> Tilman Schmidt          ÂE-Mail: tilman@xxxxxxx
> Bonn, Germany
> Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
> UngeÃffnet mindestens haltbar bis: (siehe RÃckseite)
>
>
--
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/