Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3701828pxb; Mon, 24 Jan 2022 15:47:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJx36wJHJR/gYd9BOglLgK00FbzUTaWSxspBT/TnDer+ij/OdaLIst0/mG8EY+ifs5+z+ZIq X-Received: by 2002:a05:6a00:190a:b0:4c3:a8f8:1e4c with SMTP id y10-20020a056a00190a00b004c3a8f81e4cmr15905311pfi.69.1643067966816; Mon, 24 Jan 2022 15:46:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643067966; cv=none; d=google.com; s=arc-20160816; b=kSErtpgmcnBSAP7S8+rd5hL+pKOs8LhHs/bs+ie1t05IL9osPsLpTfAyk02W+4jShE UgMz4gjY/EdGZkPf+SJW42iYoOBZSwuPGSYtIFrhBWixW51i4EL6wNMCoxG0e7JCFlQ9 C+ITrsWeWP2zvA0JlgxlDjmMNeOj1K3uUREbkP6a85fsAGryRNXhOeYb2Hv8YDBLhJnl 48/xnQgtUppUiJ2vWbkisR6r/AQtrx5emp+L4LVD5yGJrzfH0zBt7kD4r1ejK0TjCxzX b7msyX2XBpJDuhNJP6yJjGrKFL68gI7qKPssNUjUsOAmjTD0uoDVs1TUtrAIVStjT6WL hGSg== 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=4MJE49tBxFzskSSMnQQrXuiGc10UPBes2PpNRKm3g0U=; b=DeSBEP4RWyaNUSU+hyzBc6Z23tPha8XuTHNbJ3dJkSmPzPpbgI3yY1VyxBiHshzDHW uXRc1ETvhkeIQduY/flSBkpssO/Oa5YtkMKPL6nAjRRZf5qGhO9BiXfoF1hIQNVaA3l7 9nL5+Z3kbGqJNjQ8LiPLZyF4oIkTRwLcWTbrJveDVlvVtOYhV1jXzgPHbgtrBbhG8Oob 2f3AW1Y+QHCtCodEECTdzLrLC1mXYy5K3GKOR0whifQPKHi4uVaqzHmjTQyzZ/YwhW7j BzGuKAVBiPYBBQO+PDzAGWV6dR4om4+2WAIBSd8UxIAMdaSu1wxGsTBeNYOUUBmi3YFc vOOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qpqlgGnQ; 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 i15si15503707pgo.387.2022.01.24.15.45.55; Mon, 24 Jan 2022 15:46:06 -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=qpqlgGnQ; 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 S2360206AbiAXXgO (ORCPT + 99 others); Mon, 24 Jan 2022 18:36:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1838727AbiAXWr6 (ORCPT ); Mon, 24 Jan 2022 17:47:58 -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 BA7AEC068091; Mon, 24 Jan 2022 13:07:16 -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 581B161320; Mon, 24 Jan 2022 21:07:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D45FC340E5; Mon, 24 Jan 2022 21:07:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058435; bh=UJoBk2AX7uagF3E4lBveV8DtzXXk/DzkBuDh3DUoHyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qpqlgGnQy+FusC03hE5tN1sdYoIcHwBsl+UVeu4DkcyPhZQwsGQrAa9R0GeXl3F1g /S7n54KU3wWHVEe2G9fLKNBUQIyjCOi6TPTtgjY3Xq0fyneBYIWupp2GJp6naqB7fR sdOEZ2HQPfT+xj9czzSharJFOFpBLfinfgIHuXzw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhou Qingyang , Kalle Valo , Sasha Levin Subject: [PATCH 5.16 0288/1039] ath11k: Fix a NULL pointer dereference in ath11k_mac_op_hw_scan() Date: Mon, 24 Jan 2022 19:34:37 +0100 Message-Id: <20220124184134.963810672@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: Zhou Qingyang [ Upstream commit eccd25136386a04ebf46a64f3a34e8e0fab6d9e1 ] In ath11k_mac_op_hw_scan(), the return value of kzalloc() is directly used in memcpy(), which may lead to a NULL pointer dereference on failure of kzalloc(). Fix this bug by adding a check of arg.extraie.ptr. This bug was found by a static analyzer. The analysis employs differential checking to identify inconsistent security operations (e.g., checks or kfrees) between two code paths and confirms that the inconsistent operations are not recovered in the current function or the callers, so they constitute bugs. Note that, as a bug found by static analysis, it can be a false positive or hard to trigger. Multiple researchers have cross-reviewed the bug. Builds with CONFIG_ATH11K=m show no new warnings, and our static analyzer no longer warns about this code. Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices") Signed-off-by: Zhou Qingyang Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20211202155348.71315-1-zhou1615@umn.edu Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/ath11k/mac.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 67be109eda910..5d49a7ea51fae 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -3241,9 +3241,12 @@ static int ath11k_mac_op_hw_scan(struct ieee80211_hw *hw, arg.scan_id = ATH11K_SCAN_ID; if (req->ie_len) { + arg.extraie.ptr = kmemdup(req->ie, req->ie_len, GFP_KERNEL); + if (!arg.extraie.ptr) { + ret = -ENOMEM; + goto exit; + } arg.extraie.len = req->ie_len; - arg.extraie.ptr = kzalloc(req->ie_len, GFP_KERNEL); - memcpy(arg.extraie.ptr, req->ie, req->ie_len); } if (req->n_ssids) { -- 2.34.1