mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	Edward Adam Davis <eadavis@qq.com>,
	syzbot+2b131f51bb4af224ab40@syzkaller.appspotmail.com
Cc: davem@davemloft.net, edumazet@google.com,
	gregkh@linuxfoundation.org, hdanton@sina.com, kuba@kernel.org,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	pabeni@redhat.com, stern@rowland.harvard.edu,
	syzkaller-bugs@googlegroups.com, torvalds@linux-foundation.org
Subject: Re: [PATCH] nfc/nci: fix task hung in nfc_targets_found
Date: Mon, 15 Jan 2024 12:15:52 +0100	[thread overview]
Message-ID: <ddb92cce-911b-48d9-a780-7b319f7491eb@linaro.org> (raw)
In-Reply-To: <199a52ed-59d0-4651-b361-3b3d0692a2bf@I-love.SAKURA.ne.jp>

On 15/01/2024 12:08, Tetsuo Handa wrote:
> On 2024/01/15 18:36, Krzysztof Kozlowski wrote:
>>> diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
>>> index 6c9592d05120..9a277228a875 100644
>>> --- a/net/nfc/nci/core.c
>>> +++ b/net/nfc/nci/core.c
>>> @@ -145,6 +145,8 @@ inline int nci_request(struct nci_dev *ndev,
>>>  {
>>>  	int rc;
>>>  
>>> +	if (test_bit(NCI_UNREG, &ndev->flags))
>>> +		return -ENODEV;
>>
>> nci_close_device() clears the NCI_UP, which is tested here, just after
>> acquiring mutex. And there is explicit comment about it just below your
>> code. Why it is not relevant?
> 
> Because the deadlock happens at mutex_lock(&ndev->req_lock), which is
> before test_bit(NCI_UP, &ndev->flags) is called. Please see
> https://lkml.kernel.org/r/d314e471-0251-461e-988d-70add0c6ebf6@I-love.SAKURA.ne.jp .

I see, yet still this code looks like moving or copying existing
test_bit(NCI_UP) outside of mutex, which is usually not the correct
solution for deadlocks. First of all, flags are supposed to be
manipulated under lock, so the code here can be quite re-ordered. What
stops the CPU to test negative in above (so: !NCI_UNREG) and then
execute nci_close_device before waiting on mutex here? Nothing.

The problem seems to be locking and solution is not to add one if()
outside of locking.

Best regards,
Krzysztof


  reply	other threads:[~2024-01-15 11:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-04  0:59 [syzbot] [net?] [nfc?] INFO: " syzbot
2024-01-04  5:05 ` Hillf Danton
2024-01-04 10:34   ` Tetsuo Handa
2024-01-11 19:08 ` syzbot
2024-01-14  8:20   ` [PATCH] nfc/nci: fix " Edward Adam Davis
2024-01-15  9:36     ` Krzysztof Kozlowski
2024-01-15 11:08       ` Tetsuo Handa
2024-01-15 11:15         ` Krzysztof Kozlowski [this message]
2024-01-13 17:29 ` [syzbot] [net?] [nfc?] INFO: " syzbot
2024-01-14  7:35   ` Edward Adam Davis
2024-01-14  8:05     ` syzbot
2024-06-24 17:54 ` 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=ddb92cce-911b-48d9-a780-7b319f7491eb@linaro.org \
    --to=krzysztof.kozlowski@linaro.org \
    --cc=davem@davemloft.net \
    --cc=eadavis@qq.com \
    --cc=edumazet@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdanton@sina.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=stern@rowland.harvard.edu \
    --cc=syzbot+2b131f51bb4af224ab40@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=torvalds@linux-foundation.org \
    /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

all inboxes | Powered by JetHome®