[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220822140532.GF2695@kadam>
Date: Mon, 22 Aug 2022 17:05:32 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Khalid Masum <khalid.masum.92@...il.com>
Cc: Hawkins Jiawei <yin31149@...il.com>,
David Howells <dhowells@...hat.com>,
Marc Dionne <marc.dionne@...istor.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
"open list:NETWORKING [GENERAL]" <netdev@...r.kernel.org>,
syzkaller-bugs <syzkaller-bugs@...glegroups.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
syzbot+7f0483225d0c94cb3441@...kaller.appspotmail.com,
Pavel Skripkin <paskripkin@...il.com>,
linux-kernel-mentees
<linux-kernel-mentees@...ts.linuxfoundation.org>,
linux-afs@...ts.infradead.org
Subject: Re: [PATCH] rxrpc: fix bad unlock balance in rxrpc_do_sendmsg
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 do kind of feel the code has a layering violation. I'd prefer instead
of "I am setting this variable to true to reflect the caller blah blah",
the variable could just be set in the caller. I'd probably flip it
around and call it "dropped_lock" instead of "holding_lock".
bool dropped_lock = false;
...
if (!dropped_lock)
mutex_unlock();
That way only the callers and the function which drops the lock need to
be involved with setting the variable.
regards,
dan carpenter
Powered by blists - more mailing lists