From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 718DBC4338F for ; Mon, 9 Aug 2021 01:15:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 523D1606A5 for ; Mon, 9 Aug 2021 01:15:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232598AbhHIBPy (ORCPT ); Sun, 8 Aug 2021 21:15:54 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:16995 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229977AbhHIBPv (ORCPT ); Sun, 8 Aug 2021 21:15:51 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GjdMr1gwJzZyth; Mon, 9 Aug 2021 09:11:52 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 9 Aug 2021 09:15:10 +0800 Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 9 Aug 2021 09:15:09 +0800 Subject: Re: [PATCH v2] once: Fix panic when module unload To: Greg KH , Jakub Kicinski CC: , , , , , Daniel Borkmann , "Eric Dumazet" , Minmin chen References: <20210806082124.96607-1-wangkefeng.wang@huawei.com> <20210806064328.1b54a7f0@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> From: Kefeng Wang Message-ID: Date: Mon, 9 Aug 2021 09:15:09 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/8/6 21:51, Greg KH wrote: > On Fri, Aug 06, 2021 at 06:43:28AM -0700, Jakub Kicinski wrote: >> 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? > Me? I was not paying attention to this at all, sorry... > >> I think we can take it thru networking since nobody cared to pick up v1. Thanks all ;) > Sure, I trust you :) > . >