lkml.org 
[lkml]   [2021]   [Aug]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] once: Fix panic when module unload
On Fri, 6 Aug 2021 16:21:24 +0800 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/

Seems reasonable. Greg does it look good to you?

I think we can take it thru networking since nobody cared to pick up v1.

\
 
 \ /
  Last update: 2021-08-06 15:44    [W:1.026 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site