Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3972120pxb; Tue, 25 Jan 2022 00:19:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQ6/pMTjy4/7l8n6re1XQoTFlLpv7NrLbohBb5coO2yFO0QPz2kWMQ5gMs2d13RUFdqgr/ X-Received: by 2002:a17:902:b218:b0:149:936b:8306 with SMTP id t24-20020a170902b21800b00149936b8306mr18365104plr.134.1643098782357; Tue, 25 Jan 2022 00:19:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643098782; cv=none; d=google.com; s=arc-20160816; b=IUL0L1477bjtkOC/vFel2qVo7lzVlUBSZTDZdiB17D0oi6ULnHTMWWRfOJ6gT+dMpq odTG+5ds5EQuVDAH7OQYnmiRwWKM6+cmnGKDErUE2cfGanJjBrJy4J7tD1yPuu9BVBJV E6w8aXBVYQbdgnewl1/e890cUrK9O6tgnIaTMvovWCNWHZ9OugAfYoGg9GIobQdeQEgs qCRcWCzXjD8M1zUNHpmWZNfmKpAAUnCtUoHt57WYgERutK369O8hCjP9mQ13NBNzcyB4 P9anwhKwNF+0Dhav+oEDg1a3UM8V5mqaxgxC4LBAYYyM5EdCkQzi1igU1rp55shlHX56 z9Ew== 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=ll8ZUP8KoCeynJbTUnUYbKUvJJpS5rLI/t8KybqCNdk=; b=I/uqNk+rkOn/jF97r8gz1laZp7kHdZUSuT8ABA1bccJhRd1VEaw70C0Sw/1JSan63P c3dp8AMoW8ADb6hqu19fTEE3HXDb15lNdAiVUsLbI58FFmnoRA9jHBwgKuVVuno9JgDU Sny9OFtmyFUh5sM6ZkXL8GKNBD1ury2j77RYsjaL3Xq83xFGDDeX+iXJlI0G2qqiBYAY gz+8eP3B7vL6526+Nu6QpYsGKVnU1qDFhoU/LDCbSi59pmPn7k6ZBrkl88cKftO6xy3o GFZMV8Bc6V+Y4UTwBrnHobB1G1PEcA4/AVvqLAax3a4cBcBp/S8s/eRY0t7kjG2H6+yh Enlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YvuT9IPu; 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 i3si13402582pgh.63.2022.01.25.00.19.30; Tue, 25 Jan 2022 00:19:42 -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=YvuT9IPu; 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 S3411425AbiAYAdS (ORCPT + 99 others); Mon, 24 Jan 2022 19:33:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1455372AbiAXVfT (ORCPT ); Mon, 24 Jan 2022 16:35:19 -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 C4AEEC061290; Mon, 24 Jan 2022 12:22:08 -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 64250614FE; Mon, 24 Jan 2022 20:22:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41473C340E8; Mon, 24 Jan 2022 20:22:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055727; bh=cv0Pa7wZHhzM0PkAYVyXMmTiNTOcXS1sEfxPtErB6L0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YvuT9IPueoXAaVjav4CUtYHWQ1DpUAXMzGB7qeidqc4/Dxk32MrQPta7RlOv0jEV7 78qo2EHjfASwKDF4wdVKJxayIlgsaHdhB0KXAasdDYFvV7H6RhlfqU4hE4Sv96aJH6 uxPQ2s+yLhXI4/7U0nKw5/OGvoPkIw7aPoQM7jG4= 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.15 246/846] ath11k: Fix a NULL pointer dereference in ath11k_mac_op_hw_scan() Date: Mon, 24 Jan 2022 19:36:03 +0100 Message-Id: <20220124184109.430050751@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: 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 9dfa77389c4da..f8f973ef150e2 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -2580,9 +2580,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