Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3675125pxb; Mon, 24 Jan 2022 15:04:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+9iQwneMLWEheVhCwYTqcvAM9QQyTsSBrpoSR38FN3eB42eylEjoGgHG7wMBAwLeEeqfg X-Received: by 2002:a17:902:ecc7:b0:14b:1eed:e575 with SMTP id a7-20020a170902ecc700b0014b1eede575mr15476184plh.54.1643065480011; Mon, 24 Jan 2022 15:04:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643065480; cv=none; d=google.com; s=arc-20160816; b=mHdlD+XdxEe5nGrA9P+XLQhWoGg/JsOMYQXNT+bUvdKZ6gPCntZQabtJEiyLLqGKP7 eh3y7qyc8Cz1sQeyVIQ4A2yUm+r7Em1DDAJqTFF3/+ubGwzZvj35CAknLonIGatOzWUo ZsFv00quiCGNUUBHc5PCch8HujpdFQ6kg1gS4IJ0vTTKHCM0ygCTvA5o6aWgLG5RXVjO 98ixtEe43UdUBuMVHcu+UX0AbdyQ6uiAy4Buhdqv7f/zWIY9zuo1het3s4Ha6n4ee8Ex 11BhyJQScgI5rGo/c19zBgeY5uXhf2jTrdVbIXJUmc/iU4DerZzLwIZNYvyMVCRZr/0s hZCw== 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=bJVSluyJVD2s2DxwgDrw1VDNc0dsMkGzcUqL/HtYciA=; b=d/g/YGJsjuPaHjSnQmWGw0DiRyFkB3nZrl7srrgVF6woOylWIWHr2et4JyxwdSOxfu 52dAKftPdf0qPQozUdwzNuJf/uKD6jKN2I2y3oj3sYpxjeg7f6YjtR3q5NHizI4NW1tU M2OEaIVxzo9GIqrOdKErrIJA/zoD5YntNmAh2FlG1TZR4pUnTBpyndlJL7ugBMvTp11Z 4eQoSI6pDvRr7FRl5ltIdP4Lx+sA9jb2GZZzeZZUYSOaK9jSiDCFboO1w36SccqTXrgf YK+7oVSXHPcL7XaOIeZmAXTzPXAppIo4ObOyAP9n/3BGfdQp6ZK7WXU4glXjrPlA/Wr/ mCZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PBQoIgjd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z3si15155641pgc.593.2022.01.24.15.04.27; Mon, 24 Jan 2022 15:04:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PBQoIgjd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1841842AbiAXXAF (ORCPT + 99 others); Mon, 24 Jan 2022 18:00:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1576938AbiAXV5C (ORCPT ); Mon, 24 Jan 2022 16:57:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90FAFC038ADF; Mon, 24 Jan 2022 12:38:20 -0800 (PST) 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 2EDA961540; Mon, 24 Jan 2022 20:38:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5C85C340E7; Mon, 24 Jan 2022 20:38:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056699; bh=0NPR2GEkXmlKshR2DCdw5F1yXLjr3XEZ5JAnE8LMcEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PBQoIgjdMN/u3oImnLMibSOZRbl3B7oXqGpCQgX5nNaqExcSVNUeH0YSChnMh5eQ/ KtjtzY28SNj7tZPW1CVs6sZKJqrFFCNOG5taAk0dAlRdyDckNwbzrvvA/l2SxAyGmO UQymxBA/pzbxhC45Lk64/ibrSk8ceZExFd9oPNYI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Tetsuo Handa , Kalle Valo , Sasha Levin Subject: [PATCH 5.15 570/846] ath9k_htc: fix NULL pointer dereference at ath9k_htc_rxep() Date: Mon, 24 Jan 2022 19:41:27 +0100 Message-Id: <20220124184120.702213299@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tetsuo Handa [ Upstream commit b0ec7e55fce65f125bd1d7f02e2dc4de62abee34 ] syzbot is reporting lockdep warning followed by kernel panic at ath9k_htc_rxep() [1], for ath9k_htc_rxep() depends on ath9k_rx_init() being already completed. Since ath9k_htc_rxep() is set by ath9k_htc_connect_svc(WMI_BEACON_SVC) from ath9k_init_htc_services(), it is possible that ath9k_htc_rxep() is called via timer interrupt before ath9k_rx_init() from ath9k_init_device() is called. Since we can't call ath9k_init_device() before ath9k_init_htc_services(), let's hold ath9k_htc_rxep() no-op until ath9k_rx_init() completes. Link: https://syzkaller.appspot.com/bug?extid=4d2d56175b934b9a7bf9 [1] Reported-by: syzbot Signed-off-by: Tetsuo Handa Tested-by: syzbot Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/2b88f416-b2cb-7a18-d688-951e6dc3fe92@i-love.sakura.ne.jp Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/ath9k/htc.h | 1 + drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h index 0a1634238e673..4f71e962279af 100644 --- a/drivers/net/wireless/ath/ath9k/htc.h +++ b/drivers/net/wireless/ath/ath9k/htc.h @@ -281,6 +281,7 @@ struct ath9k_htc_rxbuf { struct ath9k_htc_rx { struct list_head rxbuf; spinlock_t rxbuflock; + bool initialized; }; #define ATH9K_HTC_TX_CLEANUP_INTERVAL 50 /* ms */ diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c index 8e69e8989f6d3..e7a21eaf3a68d 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c @@ -1130,6 +1130,10 @@ void ath9k_htc_rxep(void *drv_priv, struct sk_buff *skb, struct ath9k_htc_rxbuf *rxbuf = NULL, *tmp_buf = NULL; unsigned long flags; + /* Check if ath9k_rx_init() completed. */ + if (!data_race(priv->rx.initialized)) + goto err; + spin_lock_irqsave(&priv->rx.rxbuflock, flags); list_for_each_entry(tmp_buf, &priv->rx.rxbuf, list) { if (!tmp_buf->in_process) { @@ -1185,6 +1189,10 @@ int ath9k_rx_init(struct ath9k_htc_priv *priv) list_add_tail(&rxbuf->list, &priv->rx.rxbuf); } + /* Allow ath9k_htc_rxep() to operate. */ + smp_wmb(); + priv->rx.initialized = true; + return 0; err: -- 2.34.1