[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <25dd38c6-39e7-8fb8-dff3-5062acf959c4@huawei.com>
Date: Mon, 9 Aug 2021 09:13:47 +0800
From: Kefeng Wang <wangkefeng.wang@...wei.com>
To: Hannes Frederic Sowa <hannes@...essinduktion.org>,
<linux-kernel@...r.kernel.org>, <netdev@...r.kernel.org>,
David Miller <davem@...emloft.net>
CC: Andrew Morton <akpm@...ux-foundation.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Daniel Borkmann <daniel@...earbox.net>,
"Eric Dumazet" <edumazet@...gle.com>,
Minmin chen <chenmingmin@...wei.com>
Subject: Re: [PATCH v2] once: Fix panic when module unload
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@...essinduktion.org>
>> Cc: Daniel Borkmann <daniel@...earbox.net>
>> Cc: David S. Miller <davem@...emloft.net>
>> Cc: Eric Dumazet <edumazet@...gle.com>
>> Reported-by: Minmin chen <chenmingmin@...wei.com>
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@...wei.com>
> Acked-by: Hannes Frederic Sowa <hannes@...essinduktion.org>
Thanks.
>
> Thanks,
> Hannes
> .
>
Powered by blists - more mailing lists