Linux Kernel Mentees list
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Khalid Masum <khalid.masum.92@gmail.com>
Cc: "open list:NETWORKING \[GENERAL\]" <netdev@vger.kernel.org>,
	syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-afs@lists.infradead.org,
	David Howells <dhowells@redhat.com>,
	syzbot+7f0483225d0c94cb3441@syzkaller.appspotmail.com,
	Eric Dumazet <edumazet@google.com>,
	Pavel Skripkin <paskripkin@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Marc Dionne <marc.dionne@auristor.com>,
	Hawkins Jiawei <yin31149@gmail.com>,
	Paolo Abeni <pabeni@redhat.com>,
	linux-kernel-mentees
	<linux-kernel-mentees@lists.linuxfoundation.org>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH] rxrpc: fix bad unlock balance in rxrpc_do_sendmsg
Date: Mon, 22 Aug 2022 17:05:32 +0300	[thread overview]
Message-ID: <20220822140532.GF2695@kadam> (raw)
In-Reply-To: <CAABMjtE-XKa-_kW-aREvHDiyGwcs-GZWjtSjZEeF577FKcUTAA@mail.gmail.com>

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

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

  reply	other threads:[~2022-08-22 14:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <000000000000ce327f05d537ebf7@google.com>
2022-08-21 12:57 ` [PATCH] rxrpc: fix bad unlock balance in rxrpc_do_sendmsg Hawkins Jiawei
2022-08-21 15:58   ` Khalid Masum
2022-08-21 16:42     ` Khalid Masum
2022-08-22  5:19       ` Hawkins Jiawei
2022-08-22  8:48   ` David Howells
2022-08-22  9:21     ` David Howells
2022-08-22 11:29       ` Hawkins Jiawei
2022-08-22 11:29       ` Hawkins Jiawei
2022-08-22 13:04         ` Hawkins Jiawei
2022-08-22 13:44           ` Dan Carpenter
2022-08-22 13:55           ` Khalid Masum
2022-08-22 14:05             ` Dan Carpenter [this message]
2022-08-22 15:39               ` Hawkins Jiawei
2022-08-22 16:00                 ` Khalid Masum
2022-08-21 19:17 ` [syzbot] WARNING: " Khalid Masum
2022-08-21 22:29   ` syzbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220822140532.GF2695@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=edumazet@google.com \
    --cc=khalid.masum.92@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.dionne@auristor.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=paskripkin@gmail.com \
    --cc=syzbot+7f0483225d0c94cb3441@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=yin31149@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox