LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Hannes Frederic Sowa <hannes@stressinduktion.org>,
	<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
	David Miller <davem@davemloft.net>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	"Eric Dumazet" <edumazet@google.com>,
	Minmin chen <chenmingmin@huawei.com>
Subject: Re: [PATCH v2] once: Fix panic when module unload
Date: Mon, 9 Aug 2021 09:13:47 +0800	[thread overview]
Message-ID: <25dd38c6-39e7-8fb8-dff3-5062acf959c4@huawei.com> (raw)
In-Reply-To: <7ae60193-0114-46d2-9770-697a2f88b85b@www.fastmail.com>


On 2021/8/6 23:22, Hannes Frederic Sowa wrote:
> On Fri, Aug 6, 2021, at 10:21, Kefeng Wang wrote:
>> DO_ONCE
>> DEFINE_STATIC_KEY_TRUE(___once_key);
>> __do_once_done
>>    once_disable_jump(once_key);
>>      INIT_WORK(&w->work, once_deferred);
>>      struct once_work *w;
>>      w->key = key;
>>      schedule_work(&w->work);                     module unload
>>                                                     //*the key is
>> destroy*
>> process_one_work
>>    once_deferred
>>      BUG_ON(!static_key_enabled(work->key));
>>         static_key_count((struct static_key *)x)    //*access key, crash*
>>
>> When module uses DO_ONCE mechanism, it could crash due to the above
>> concurrency problem, we could reproduce it with link[1].
>>
>> Fix it by add/put module refcount in the once work process.
>>
>> [1]
>> https://lore.kernel.org/netdev/eaa6c371-465e-57eb-6be9-f4b16b9d7cbf@huawei.com/
>>
>> Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
>> Cc: Daniel Borkmann <daniel@iogearbox.net>
>> Cc: David S. Miller <davem@davemloft.net>
>> Cc: Eric Dumazet <edumazet@google.com>
>> Reported-by: Minmin chen <chenmingmin@huawei.com>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Thanks.
>
> Thanks,
> Hannes
> .
>

      reply	other threads:[~2021-08-09  1:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-06  8:21 Kefeng Wang
2021-08-06 13:43 ` Jakub Kicinski
2021-08-06 13:51   ` Greg KH
2021-08-09  1:15     ` Kefeng Wang
2021-08-06 15:22 ` Hannes Frederic Sowa
2021-08-09  1:13   ` Kefeng Wang [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=25dd38c6-39e7-8fb8-dff3-5062acf959c4@huawei.com \
    --to=wangkefeng.wang@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=chenmingmin@huawei.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hannes@stressinduktion.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --subject='Re: [PATCH v2] once: Fix panic when module unload' \
    /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).