Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3642274pxb; Mon, 24 Jan 2022 14:13:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJyyoac5d1D8V3Lk+3DFPNiCq/+7hrBLih9JfEdB3O3MRWij8zAIKNlRapXF4vvlpRBzuyGP X-Received: by 2002:a17:902:6b8b:b0:149:7cf7:c58e with SMTP id p11-20020a1709026b8b00b001497cf7c58emr15920818plk.135.1643062401128; Mon, 24 Jan 2022 14:13:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643062401; cv=none; d=google.com; s=arc-20160816; b=w0AQbHz1tXhqCCXm/WXe9ZPnZ+gnfAJ+HM2rc46u5TdE4v3I9e3jdA0twtMhfE3K7j dDWSorIwFZbB4+vKHW6FR5hkDOR5nlE9r1pFGjahrb9A3AOE0nNLMCXWqaLNXWI9Fokm fUy+2Sf0wmgpbVIBRDMAU2EYWQAI30Q5xMDwqMUo/Dvc+eY6aPOokpmoESz66idMhK1H LBRNOn+1e7pFekSuLC/kudf2N4Qpzuuso8dPyPHRlsDOMcIVIPZb9FFrVITBhDIDxU3X a+y5asm11RkNbPJzIIB3RMZKPQx05FdZ5AKM5oPeUxD10+jEwSOdtNL3w9l2GPY4U9kU 3gpg== 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=/naE6hxAP0YhteRc0xcNoIn52vx3bDqnJ58Q9rPK4UQ=; b=i5t6FNUUOMoHghtocaZcLTg3B4x0X1cwVW+xfj+RfrELhlXpqXJrAGgd5qmllLtVz+ 5xZ3ZVcNo3XQQh2gJ8is2wr3l3fiV++6ro/obX7AgOahbQYDNSP9Q6NC9t3AowUCNcUU tuNDLKMZ5WH7Pgs9ul3RSt+AZLYqFL9wv8E2n0NwrCm+qd/BfjOdKGNuZ+wphycLPJdu 4E04DKkS0bPAt5IWl95Bj0i/PL3xMqZoSIiyqKGzmVccxiYNtB6PE+0dL3S7sXP455sF p5ew3Wjnj3ITobYpYPC6ftEDy/bEojtp1APc2w/9IJ7PmkkbAcLtBTmT5SdjMYDlVPVy 6vJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O+Z6CTf3; 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 q132si14372568pgq.162.2022.01.24.14.13.08; Mon, 24 Jan 2022 14:13:21 -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=O+Z6CTf3; 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 S1350639AbiAXV6z (ORCPT + 99 others); Mon, 24 Jan 2022 16:58:55 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:39942 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1451244AbiAXVWd (ORCPT ); Mon, 24 Jan 2022 16:22:33 -0500 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 ams.source.kernel.org (Postfix) with ESMTPS id 45B2CB80FA1; Mon, 24 Jan 2022 21:22:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 767F8C340E5; Mon, 24 Jan 2022 21:22:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059350; bh=bz1hqXPikVfXBjdlfFqkzfQekXPW+TQfB3hTk5+n4r0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O+Z6CTf3mrWxcg1M2Lv7aUCDZpD6KItqM6DsXgw7tOrv+BmN+n/ulLdmWyByGsFmz tvM2wrF6Q4dTgTauha3XXMZ6beZA2mIy8AftkqAv25EkQ/MygfIWCWQb0YRVroVVP4 HCePV/rK1UGuBvoy9Tzyfg1rKudBKgq4ra1ld6ws= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zekun Shen , Kalle Valo , Sasha Levin Subject: [PATCH 5.16 0553/1039] ar5523: Fix null-ptr-deref with unexpected WDCMSG_TARGET_START reply Date: Mon, 24 Jan 2022 19:39:02 +0100 Message-Id: <20220124184143.879719547@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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: Zekun Shen [ Upstream commit ae80b6033834342601e99f74f6a62ff5092b1cee ] Unexpected WDCMSG_TARGET_START replay can lead to null-ptr-deref when ar->tx_cmd->odata is NULL. The patch adds a null check to prevent such case. KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] ar5523_cmd+0x46a/0x581 [ar5523] ar5523_probe.cold+0x1b7/0x18da [ar5523] ? ar5523_cmd_rx_cb+0x7a0/0x7a0 [ar5523] ? __pm_runtime_set_status+0x54a/0x8f0 ? _raw_spin_trylock_bh+0x120/0x120 ? pm_runtime_barrier+0x220/0x220 ? __pm_runtime_resume+0xb1/0xf0 usb_probe_interface+0x25b/0x710 really_probe+0x209/0x5d0 driver_probe_device+0xc6/0x1b0 device_driver_attach+0xe2/0x120 I found the bug using a custome USBFuzz port. It's a research work to fuzz USB stack/drivers. I modified it to fuzz ath9k driver only, providing hand-crafted usb descriptors to QEMU. After fixing the code (fourth byte in usb packet) to WDCMSG_TARGET_START, I got the null-ptr-deref bug. I believe the bug is triggerable whenever cmd->odata is NULL. After patching, I tested with the same input and no longer see the KASAN report. This was NOT tested on a real device. Signed-off-by: Zekun Shen Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/YXsmPQ3awHFLuAj2@10-18-43-117.dynapool.wireless.nyu.edu Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/ar5523/ar5523.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/ath/ar5523/ar5523.c b/drivers/net/wireless/ath/ar5523/ar5523.c index 0e9bad33fac85..141c1b5a7b1f3 100644 --- a/drivers/net/wireless/ath/ar5523/ar5523.c +++ b/drivers/net/wireless/ath/ar5523/ar5523.c @@ -153,6 +153,10 @@ static void ar5523_cmd_rx_cb(struct urb *urb) ar5523_err(ar, "Invalid reply to WDCMSG_TARGET_START"); return; } + if (!cmd->odata) { + ar5523_err(ar, "Unexpected WDCMSG_TARGET_START reply"); + return; + } memcpy(cmd->odata, hdr + 1, sizeof(u32)); cmd->olen = sizeof(u32); cmd->res = 0; -- 2.34.1