Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6265202rwb; Tue, 9 Aug 2022 12:03:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Rk1eYrnlsn5Tl/WR0dF3mTB7VNCuQmUGHlcffIO9zQqtK5EItRbsCb7JPvqsgWQ8IMJxH X-Received: by 2002:a17:90b:1e0a:b0:1f5:6554:d502 with SMTP id pg10-20020a17090b1e0a00b001f56554d502mr26718713pjb.101.1660071787159; Tue, 09 Aug 2022 12:03:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660071787; cv=none; d=google.com; s=arc-20160816; b=cvMmcHsrj5fScYl42ovMrR7pbElTIV+hwtsTG+YfGKBhL3H2kq3eav4DAy9ONFES3+ CUPln2lnCikdeA4AdaYQT81JtEVuO8efxYbCgLh8sZw37+Iw+TJ0X2kejWCFPQPV/w7M jaYt0Uy6TzYfj83VrHGljywDFFeBRNJ/kZ0fCiEPc5Pav93j0p10DfXHNrg2bH1vr+Uj KVS2tToLwLKRIB/t1gQLr5T9vc/IQCI5FehGuPdCctoCZ3jVnZ6dRQ2oUrmmouRfXez1 ws08NupRC8hvj+s4sW0Gq9JF2x5EsRqiRijuA/QMQy6RRnYxXGl3oVCV9uelMuse21Le dBQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gLM/prXnC5M3xtrhTSISMfNx3itdtV++znmf1Ky5/gg=; b=oiG0WhkS3JLXeOkjXs6Tn0wg7S9Ke+OPFse3BznaEpPdaPea/C36c4r3cnHQGHZBWs cq5CXWf+ABIWrV6ynr4BTSYZsTvQVQXn6daA7PmVuUAsG0HmFgaGR7pedx/cxpGeP0D2 QYQ9XTyfixKplxLwhIsiVJXPflpvUl5+/s8Ju+KEz6/9J7Y8TI5TvkjnqdQPwJ7b/f8n Bk+qvLd29p2uYhv6PsV7FFhPU3R7eEAs1RC2A4HgHzBLNXBSul2toLLyLy94LjYKDyd2 q7ulJt9z4XliI2YUW8HaPXhWBFGCGnb0rjq6thTLV8lchqCRTmCP2o9kY+kH3jYtPatx 7t8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ErfGOF63; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j9-20020a635949000000b0041288737bc6si2851212pgm.797.2022.08.09.12.02.36; Tue, 09 Aug 2022 12:03:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ErfGOF63; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345000AbiHISJu (ORCPT + 99 others); Tue, 9 Aug 2022 14:09:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345101AbiHISJO (ORCPT ); Tue, 9 Aug 2022 14:09:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6A2329C85; Tue, 9 Aug 2022 11:03:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E6E7E61072; Tue, 9 Aug 2022 18:03:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFF58C433C1; Tue, 9 Aug 2022 18:03:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660068228; bh=QqaSD9DzLVaHHQUaJ4MwWSBM4HNz4sh6eyk4/vYWw4U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ErfGOF63koA6FGVNTHko+eSFJwC1cDMIHDrJaRNcLiSThDE548HcM2yGS8hiNGaG3 bJqFoefTJJ2SkpDiUZ5g+cgtEaNtWvhvKc8PoBcWRg4Zho1xLf5ZkBPJDLdU7m+oqx a0BYMjBcFw7VBeEdhuuZf0siBjRCo+sTga/XLfG4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Tetsuo Handa , Kalle Valo , Fedor Pchelkin Subject: [PATCH 5.10 03/23] ath9k_htc: fix NULL pointer dereference at ath9k_htc_tx_get_packet() Date: Tue, 9 Aug 2022 20:00:21 +0200 Message-Id: <20220809175512.991915877@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220809175512.853274191@linuxfoundation.org> References: <20220809175512.853274191@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org From: Tetsuo Handa commit 8b3046abc99eefe11438090bcc4ec3a3994b55d0 upstream. syzbot is reporting lockdep warning at ath9k_wmi_event_tasklet() followed by kernel panic at get_htc_epid_queue() from ath9k_htc_tx_get_packet() from ath9k_htc_txstatus() [1], for ath9k_wmi_event_tasklet(WMI_TXSTATUS_EVENTID) depends on spin_lock_init() from ath9k_init_priv() being already completed. Since ath9k_wmi_event_tasklet() is set by ath9k_init_wmi() from ath9k_htc_probe_device(), it is possible that ath9k_wmi_event_tasklet() is called via tasklet interrupt before spin_lock_init() from ath9k_init_priv() from ath9k_init_device() from ath9k_htc_probe_device() is called. Let's hold ath9k_wmi_event_tasklet(WMI_TXSTATUS_EVENTID) no-op until ath9k_tx_init() completes. Link: https://syzkaller.appspot.com/bug?extid=31d54c60c5b254d6f75b [1] Reported-by: syzbot Signed-off-by: Tetsuo Handa Tested-by: syzbot Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/77b76ac8-2bee-6444-d26c-8c30858b8daa@i-love.sakura.ne.jp Signed-off-by: Fedor Pchelkin Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/ath/ath9k/htc.h | 1 + drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 5 +++++ drivers/net/wireless/ath/ath9k/wmi.c | 4 ++++ 3 files changed, 10 insertions(+) --- a/drivers/net/wireless/ath/ath9k/htc.h +++ b/drivers/net/wireless/ath/ath9k/htc.h @@ -306,6 +306,7 @@ struct ath9k_htc_tx { DECLARE_BITMAP(tx_slot, MAX_TX_BUF_NUM); struct timer_list cleanup_timer; spinlock_t tx_lock; + bool initialized; }; struct ath9k_htc_tx_ctl { --- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c @@ -808,6 +808,11 @@ int ath9k_tx_init(struct ath9k_htc_priv skb_queue_head_init(&priv->tx.data_vi_queue); skb_queue_head_init(&priv->tx.data_vo_queue); skb_queue_head_init(&priv->tx.tx_failed); + + /* Allow ath9k_wmi_event_tasklet(WMI_TXSTATUS_EVENTID) to operate. */ + smp_wmb(); + priv->tx.initialized = true; + return 0; } --- a/drivers/net/wireless/ath/ath9k/wmi.c +++ b/drivers/net/wireless/ath/ath9k/wmi.c @@ -169,6 +169,10 @@ void ath9k_wmi_event_tasklet(struct task &wmi->drv_priv->fatal_work); break; case WMI_TXSTATUS_EVENTID: + /* Check if ath9k_tx_init() completed. */ + if (!data_race(priv->tx.initialized)) + break; + spin_lock_bh(&priv->tx.tx_lock); if (priv->tx.flags & ATH9K_HTC_OP_TX_DRAIN) { spin_unlock_bh(&priv->tx.tx_lock);