Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3558772pxb; Mon, 24 Jan 2022 12:11:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJweiK3iFHMBA93AGWpBW6AbYh0ebrgCPhA0Jxbig8VB/rxC6W6TsZtCQKyXYF7iqXhV39xU X-Received: by 2002:a17:903:2447:b0:14b:20ad:c1b1 with SMTP id l7-20020a170903244700b0014b20adc1b1mr13577819pls.82.1643055111974; Mon, 24 Jan 2022 12:11:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643055111; cv=none; d=google.com; s=arc-20160816; b=oHjjcFcP+cLT+qmzHA0ORhyVmQCDBIdAE3cKN4bs0T+27cyQ6pdM0THJwhdfHZoF4Q Ugnd0kyi/t8LSxWXiwgJVzMqP0bZpRK+RqaCc7NHz2X+HEd0QNU/7U7Vmct4s4cMnns+ cp42u8iDxYfgBuohYSDV9LD+H8D6kuJ4eK0fLvQIeAm4jHxakLKlelKwEh6EOie/smHD G7UnZ3K2WsidfoWQTa+vF3zxdeCWitdx9PkrBSC2stR6j6p4K95KideBmJqNulQFkHQ0 Z0S7v5N09wMF9uGOgC1gT7aM0p3g9DBSEc5p1y5+duke/Rv8vtOYcLoLu5h9hCWRL/K/ VYbQ== 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=RB1FhJp9VDmBmhV2/uW+LjjlpB04Tok4Q+PO9qVbGMI=; b=UAfXNq6Cg4cSdk35Xr2bFDMkNBksUpc+AX5vL+CflY85+EkFgqcM6XypaQ3jJlomTJ za8Dn+h0uKZejcpiTmC4SX+4RlDrXtCDQTNni0SA/KtPrCdCp2+f3HOXufcidIfshlMq Q132gRhp6tytpV18VQBEHWxJ+XMxueNptI7GFyEPo5uTflkG6Oox/FjqF+W9xpbxIk5c 1165/u4NQUKLS3tkJlmploM1GV7bLdPlG/omtx42NXy621k3N1t98py0xV3mZNLD6XVj zIexsDl9eyJxfrrhvmM9lyCDlYGZvCTyqPvQD70t0o7BGsIbvMjzlsvbdpli1Bnkv4Fb MsKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B7cSxSOk; 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 me3si310914pjb.16.2022.01.24.12.11.38; Mon, 24 Jan 2022 12:11:51 -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=B7cSxSOk; 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 S1348317AbiAXTPN (ORCPT + 99 others); Mon, 24 Jan 2022 14:15:13 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:34980 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343792AbiAXTGp (ORCPT ); Mon, 24 Jan 2022 14:06:45 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 3CB3061232; Mon, 24 Jan 2022 19:06:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1805FC340E5; Mon, 24 Jan 2022 19:06:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051203; bh=Rl+seFCLIEA6ePAQhBWREbLa9pE10jUp93g1f8T3wvk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B7cSxSOkBbvB5JX0yXEfziaApWMKOzwlHgNvkKed0cOHvEuI3/0fj10ZTQ6jTYxzH gFIvEptAArVrWEph57wjtFe1DTcREHXSUvmQAzLFf8otEt8FXanvGnGVvd+VLHOeoO yHAqBNVdrEN2CMgNfCDDkS0oH8YZpIh0RRlllbOk= 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 4.14 088/186] ar5523: Fix null-ptr-deref with unexpected WDCMSG_TARGET_START reply Date: Mon, 24 Jan 2022 19:42:43 +0100 Message-Id: <20220124183939.942081372@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@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 e1a1d27427cc9..bf43244f051c5 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