Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp11875356rwb; Sat, 26 Nov 2022 00:26:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf4FnMN4UyDei/Fx8yL9UF1Fb7YXVfbQ06Qo3pjBpOGseS+BjaBHPpJVt28wwhXMqSzJsHPz X-Received: by 2002:a62:f24e:0:b0:572:149c:e278 with SMTP id y14-20020a62f24e000000b00572149ce278mr44158463pfl.8.1669451183589; Sat, 26 Nov 2022 00:26:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669451183; cv=none; d=google.com; s=arc-20160816; b=sz3UbT1py8qLN2nIWUFpNBwKJ5d27XOWcPKVEV3sKdJ3EUgrl71loF+UXsdBC5MVDz 34HdYHFMfs+tio1M9VxsDkbY+WSZ7QVlhF6nGDO+FurWvZpoqu6cTpAmWABHLasVl3ij tOsuFYlOAhys9DN6/98FMMCJUW4E3KK17HKTy1lD2aKW0Uv20oH07A9rEmOhmyV50L82 +e8BvXRC66O9TrlqjVva9IlHnsG/LHAok1MTNofDu2gHSAbbZ4xJeXSJ+2QX9xckv6B4 YFK4Zc9V1rWrjBy33pyJvmXLiRyuYj1E8YrjvTHNZ7u0OGCbebWqVRc5VOWeGoXqenQS z6/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:cc:from :references:to:subject:user-agent:mime-version:date:message-id; bh=8eYma9Sc8JNnQ0MMlZR3QTqF5eQmFPAhHMCcNPDTpX0=; b=izp55jSIpSwGV43EnWeI5zBvi8gb/kfjt+mMdhaYMoM2v6vD4+RSlMy8X35fhM3IJ7 fAcSe4EoE/ID2+2wtpRyBJabFucuv6xFwBnMyhrRgPIDJPX4fW1noPKK3BQw1cFnmOuL TIuToPwu5qkAh4CZo0L9PMjnA6uwS92e8r3CVA7VONSzAah4A3uqMS3kDWZUjsmqYsLt sGsf0l4BGF5tf50J+zIWtkKMjOqGDO0/iX/hP8vsyeEXxUzK9H+xehFWBFIIvQ8zL9A5 T5Ijs02JHyhda7Ozhp4WdMRjs5kkeNCmbpbHqTGO8/qiGDG3i8m0mOiEFoBJGlYdDvPq 8TXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o6-20020a1709026b0600b0017f641cac01si5938442plk.27.2022.11.26.00.26.10; Sat, 26 Nov 2022 00:26:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229487AbiKZIOt (ORCPT + 67 others); Sat, 26 Nov 2022 03:14:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbiKZIOs (ORCPT ); Sat, 26 Nov 2022 03:14:48 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B2F226571; Sat, 26 Nov 2022 00:14:46 -0800 (PST) Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NK4JJ4tqnzmW5Q; Sat, 26 Nov 2022 16:14:08 +0800 (CST) Received: from [10.174.176.83] (10.174.176.83) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 26 Nov 2022 16:14:43 +0800 Message-ID: <88650c25-5358-1f03-dc96-fb7fc550fb18@huawei.com> Date: Sat, 26 Nov 2022 16:14:43 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH wireless] wifi: wilc1000: Fix UAF in wilc_netdev_cleanup() when iterator the RCU list To: References: <20221124151349.2386077-1-zhangxiaoxu5@huawei.com> From: "zhangxiaoxu (A)" CC: , , , , , , , In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.176.83] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500023.china.huawei.com (7.185.36.114) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On 2022/11/26 0:17, Ajay.Kathat@microchip.com wrote: > > On 24/11/22 20:43, Zhang Xiaoxu wrote: >> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe >> >> There is a UAF read when remove the wilc1000_spi module: >> >> BUG: KASAN: use-after-free in wilc_netdev_cleanup.cold+0xc4/0xe0 [wilc1000] >> Read of size 8 at addr ffff888116846900 by task rmmod/386 >> >> CPU: 2 PID: 386 Comm: rmmod Tainted: G N 6.1.0-rc6+ #8 >> Call Trace: >> dump_stack_lvl+0x68/0x85 >> print_report+0x16c/0x4a3 >> kasan_report+0x95/0x190 >> wilc_netdev_cleanup.cold+0xc4/0xe0 >> wilc_bus_remove+0x52/0x60 >> spi_remove+0x46/0x60 >> device_remove+0x73/0xc0 >> device_release_driver_internal+0x12d/0x210 >> driver_detach+0x84/0x100 >> bus_remove_driver+0x90/0x120 >> driver_unregister+0x4f/0x80 >> __x64_sys_delete_module+0x2fc/0x440 >> do_syscall_64+0x38/0x90 >> entry_SYSCALL_64_after_hwframe+0x63/0xcd >> >> Since set 'needs_free_netdev=true' when initialize the net device, the >> net device will be freed when unregister, then use the freed 'vif' to >> find the next will UAF read. > > > Did you test this behaviour on the real device. I am seeing a kernel crash when the module is unloaded after the connection with an AP. Thanks Ajay, I have no real device, what kind of crash about your scenario? > As I see, "vif_list" is used to maintain the interface list, so even when one interface is removed, another element is fetched from the "vif_list", not using the freed "vif" For example if the "vif_list" has device A and device B, just like: A->next = &B B->prev = &A When iterator on the vif_list, 1st: Got A and unregister A, A will be freed since needs_free_netdev=true 2nd: Try get B from A->next, A already freed in the first step, UAF occurred. rcu list no implement the interface like "list_for_each_entry_safe". > > Regards, > Ajay >