Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Wen Gu <guwen@linux.alibaba.com>
To: dust.li@linux.alibaba.com, kgraul@linux.ibm.com,
	davem@davemloft.net, kuba@kernel.org
Cc: linux-s390@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net/smc: Avoid setting clcsock options after clcsock released
Date: Wed, 12 Jan 2022 16:16:58 +0800	[thread overview]
Message-ID: <ac0a2805-c6a0-af05-adc7-780d17003897@linux.alibaba.com> (raw)
In-Reply-To: <20220112071134.GA47613@linux.alibaba.com>



On 2022/1/12 3:11 pm, dust.li wrote:
> On Mon, Jan 10, 2022 at 05:38:25PM +0800, Wen Gu wrote:
>>
>> This patch tries to fix it by holding clcsock_release_lock and
>> checking whether clcsock has already been released. In case that
>> a crash of the same reason happens in smc_getsockopt(), this patch
>> also checkes smc->clcsock in smc_getsockopt().

>> @@ -2509,13 +2515,21 @@ static int smc_getsockopt(struct socket *sock, int level, int optname,
>> 			  char __user *optval, int __user *optlen)
>> {
>> 	struct smc_sock *smc;
>> +	int rc;
>>
>> 	smc = smc_sk(sock->sk);
>> +	mutex_lock(&smc->clcsock_release_lock);
>> +	if (!smc->clcsock) {
>> +		mutex_unlock(&smc->clcsock_release_lock);
>> +		return -EBADF;
>> +	}
>> 	/* socket options apply to the CLC socket */
>> 	if (unlikely(!smc->clcsock->ops->getsockopt))
> Missed a mutex_unlock() here ?
> 
>> 		return -EOPNOTSUPP;

Thanks for pointing it out. Will add an additional mutex_unlock().

Thanks,
Wen Gu


      reply	other threads:[~2022-01-12  8:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10  9:38 Wen Gu
2022-01-11 10:03 ` Karsten Graul
2022-01-11 16:34   ` Wen Gu
2022-01-12  9:38     ` Karsten Graul
2022-01-13  8:23       ` Wen Gu
2022-01-13 15:15       ` Wen Gu
2022-01-11 18:14 ` Jakub Kicinski
2022-01-12  3:32   ` Wen Gu
2022-01-12  7:11 ` dust.li
2022-01-12  8:16   ` Wen Gu [this message]

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=ac0a2805-c6a0-af05-adc7-780d17003897@linux.alibaba.com \
    --to=guwen@linux.alibaba.com \
    --cc=davem@davemloft.net \
    --cc=dust.li@linux.alibaba.com \
    --cc=kgraul@linux.ibm.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --subject='Re: [PATCH net] net/smc: Avoid setting clcsock options after clcsock released' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).