Re: [PATCH] rxrpc: fix bad unlock balance in rxrpc_do_sendmsg

From: Hawkins Jiawei
Date: Mon Aug 22 2022 - 11:41:07 EST


On Mon, 22 Aug 2022 at 22:06, Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
>
> On Mon, Aug 22, 2022 at 07:55:27PM +0600, Khalid Masum wrote:
> > >
> > > /*
> > > + * @holding_mutex: An indication whether caller can still holds
> > > + * the call->user_mutex when returned to caller.
> >
> > Maybe we can use mutex_is_locked instead of using the holding_mutex
> > parameter to get whether call->user_mutex is still held.
>
> That doesn't work. What if there is contention for the lock and someone
> else took it. Locks under contention are sort of the whole point of
> locking so it's highly likely.
I trid this before, it doesn't work as Dan points out. I think
it seems that mutex_is_locked() only checks whether there is a task
holding the mutex, but do not check whether it is current task holding
mutex. I also tried lockdep_is_held(), lockdep_is_held() seems can detect
call->user_mutex is still held accurately, although this cannot be the patch.