Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2521149imu; Thu, 29 Nov 2018 06:21:05 -0800 (PST) X-Google-Smtp-Source: AFSGD/XEwk+C72T6h4uiQSF4uH9OSh7ZFZlyMYWlKEj0fNSRBSk590BCW0QCZtJoT/wgkwJwsnbb X-Received: by 2002:a63:9809:: with SMTP id q9mr1397859pgd.109.1543501265067; Thu, 29 Nov 2018 06:21:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543501265; cv=none; d=google.com; s=arc-20160816; b=p6pHStttP5sqiZJmuag1A0O0auKomy2m49JS19cWarnydy0r36wLm3Lmwp4bFgAlzk 2BjKWbyHVxpJ3mcCpzqXKNaiW/kauc3JaKHHpFZO/iymWc6gwOBlm30LTYaAM8yIiBTt A34l6MSHzf/BpJhxAeg2R/Kbqv/0EuI1VSSiANDbob4Mtyx8FFdaQu3dcoEc4ipQC2xU 01RQDMsM5Hx3ewjHqi4CoWBGHaT7e4NWnuDRoiD7+Up9YM5Me+dY1R0+IZUNEQ+Zl/Vy i4b415VE6aAlAvMj9aab+eOirWRzXH8/RaZd+aAgwdy69mr2zVy4ARhKp1upuCaYIFmm 7quw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=f+wXdvxaEyAqLn2hOQ/9shJ5pFKHiebmzr49AGau0oM=; b=xQ9pvm+NKdweW9mYAlovNncd/oUqEt5Ku2W8Z/lOXKmLgMWNcMx/QhmW4q0Y6QhT+h LucoDG9A169yEwAk7L6EUPvQaDYO49vpj11HQd+UUeRaF/sZgNY7/vWAGloj9a7xdtUR 9Z7OsI1IgpkTgL12nWMA3OKUyJNbD2uU1l7SrEP3lQjZfISDZpwAc5q/Z8/rpNlDD67K WRT4DX1X6IlkAVOXTjpAmyQS4NpVDKpfwUfGuemAtzF2WfX1zk7rTCPDx1zwuwqjjkCa Tdgbt6HaukRnZ9A1B4Li1iiLybFpEESPBcyNN7elw9MK1mL7+r58MRsIrgOQRjV+Uf/y 60UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=S6RD6gjZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3-v6si2129687plk.419.2018.11.29.06.20.49; Thu, 29 Nov 2018 06:21:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=S6RD6gjZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731108AbeK3BZB (ORCPT + 99 others); Thu, 29 Nov 2018 20:25:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:48194 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729806AbeK3BZA (ORCPT ); Thu, 29 Nov 2018 20:25:00 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 584EF21104; Thu, 29 Nov 2018 14:19:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501169; bh=b82iIQVtNvid4ttStAFnfk8RB448mjrN1mMo8Qh7nOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S6RD6gjZIAwD5+WhYmj3sJslhYBNxNAf8EEyw/0jcSfktE+Ro8i9VamoyvDs2q6zO qj6yY2A/z442F+8ZFBcL9o+v+a1u5P/MeAvqsFnlvwAhq0YaGdy9r0H9jFpj6x7UsK HRc0WBXbCoIHJdKeXCRXek6k1uQ79dt7cT/jxnr8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amitkumar Karwar , Kalle Valo , Amit Pundir Subject: [PATCH 4.4 70/86] mwifiex: Fix NULL pointer dereference in skb_dequeue() Date: Thu, 29 Nov 2018 15:12:35 +0100 Message-Id: <20181129140115.694668828@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140109.832117862@linuxfoundation.org> References: <20181129140109.832117862@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Amitkumar Karwar commit c44c040300d7afd79294710313a4989683e2afb1 upstream. At couple of places in cleanup path, we are just going through the skb queue and freeing them without unlinking. This leads to a crash when other thread tries to do skb_dequeue() and use already freed node. The problem is freed by unlinking skb before freeing it. Signed-off-by: Amitkumar Karwar Signed-off-by: Kalle Valo [AmitP: Refactored to fix driver file path in linux-4.4.y] Signed-off-by: Amit Pundir Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/mwifiex/cfg80211.c | 4 +++- drivers/net/wireless/mwifiex/wmm.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -2839,8 +2839,10 @@ int mwifiex_del_virtual_intf(struct wiph mwifiex_stop_net_dev_queue(priv->netdev, adapter); - skb_queue_walk_safe(&priv->bypass_txq, skb, tmp) + skb_queue_walk_safe(&priv->bypass_txq, skb, tmp) { + skb_unlink(skb, &priv->bypass_txq); mwifiex_write_data_complete(priv->adapter, skb, 0, -1); + } if (netif_carrier_ok(priv->netdev)) netif_carrier_off(priv->netdev); --- a/drivers/net/wireless/mwifiex/wmm.c +++ b/drivers/net/wireless/mwifiex/wmm.c @@ -501,8 +501,10 @@ mwifiex_wmm_del_pkts_in_ralist_node(stru struct mwifiex_adapter *adapter = priv->adapter; struct sk_buff *skb, *tmp; - skb_queue_walk_safe(&ra_list->skb_head, skb, tmp) + skb_queue_walk_safe(&ra_list->skb_head, skb, tmp) { + skb_unlink(skb, &ra_list->skb_head); mwifiex_write_data_complete(adapter, skb, 0, -1); + } } /* @@ -598,11 +600,15 @@ mwifiex_clean_txrx(struct mwifiex_privat priv->adapter->if_ops.clean_pcie_ring(priv->adapter); spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock, flags); - skb_queue_walk_safe(&priv->tdls_txq, skb, tmp) + skb_queue_walk_safe(&priv->tdls_txq, skb, tmp) { + skb_unlink(skb, &priv->tdls_txq); mwifiex_write_data_complete(priv->adapter, skb, 0, -1); + } - skb_queue_walk_safe(&priv->bypass_txq, skb, tmp) + skb_queue_walk_safe(&priv->bypass_txq, skb, tmp) { + skb_unlink(skb, &priv->bypass_txq); mwifiex_write_data_complete(priv->adapter, skb, 0, -1); + } atomic_set(&priv->adapter->bypass_tx_pending, 0); idr_for_each(&priv->ack_status_frames, mwifiex_free_ack_frame, NULL);