From patchwork Wed Nov 28 17:29:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 152337 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1365579ljp; Wed, 28 Nov 2018 09:29:59 -0800 (PST) X-Google-Smtp-Source: AJdET5fzfjxU9vTEyGiMZhn/t781i0QYdlNsFP2msWc/f2P4WqwbYHQfh9s4AeCPtu2MeDV25aqh X-Received: by 2002:a62:11c7:: with SMTP id 68mr38138252pfr.21.1543426199635; Wed, 28 Nov 2018 09:29:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543426199; cv=none; d=google.com; s=arc-20160816; b=s1MhfuD29YLJoA1Z9dFinDaZIqYz1RYM0qfd36QetH6/tfluKWLdgPmZ7+3jC1Tf9M mE2BGFdnWh+4c7xBakXvj4ulcrzX7xVQaF18wv6N+ztu9H82eNzsVcfn28ANkv+fAFu6 2ASnYFtZZUc4r52VugRsvSKriM6LSXTm/ZDbpdQrqs6ahbise/HceF/ZATIVGGGJHVN2 Jh0mUFuYJFIQDLJDamDWSQKPomwysFN/Wcq5agIg2LQoO392LhG3pxjDsDArGyclqpcD lhoIpFRU9zmnLQm7ViLc6D3zs2Hu8J3Sy1v4GaXBCbWS+yuVYzM66DiXh92rvJWBzC0t xoMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=C1rOqshDY+v2g7d1Z+TrKygKn6IvxZ+JtAdXXsgB/Go=; b=vi7mra4ZihtcCfR11KdI4Th77X9WtF6hh6rreDNhTIuz7ziKr+PjaVbdrfGe/r04Z4 /23Ev5xlwCbqsNFIJEmaINQ/fiWB2XjuaNzkqD9fRLsiQolGu1V8uBDyrZZv8VTqLJyS UD+bF5te6mx4q6SxpzVX7C2F1acafe7Y2QEu3pFaJwOSFTH4b9r0m4SHuh4iOLLh6GNn 8NULio4C3puOp6Tkd6iJq0cNuvcn6My8Onxu/9pX50wf9uRzsFmTZ4/7vocGEyMzgGrI h8bDP/BRc+gVQrj1MEn0jh5GdM0VAFucr9AM0DAmE1hEatDdrODRxlS2M+L/RTFdktK4 W/Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bGKx5dph; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 44si8357481plb.57.2018.11.28.09.29.57; Wed, 28 Nov 2018 09:29:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.s=google header.b=bGKx5dph; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729269AbeK2EcD (ORCPT + 15 others); Wed, 28 Nov 2018 23:32:03 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37456 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729147AbeK2Ebo (ORCPT ); Wed, 28 Nov 2018 23:31:44 -0500 Received: by mail-pg1-f193.google.com with SMTP id 80so9804394pge.4 for ; Wed, 28 Nov 2018 09:29:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=C1rOqshDY+v2g7d1Z+TrKygKn6IvxZ+JtAdXXsgB/Go=; b=bGKx5dphHGP+r8N2G0QRW/BZk9TfrnGf4OrVIDMXi/1cf7Op7StK7dyw5ccMGegVK4 Orn2/ylrgT7gzRTasEvQjK19iBP9EhIku7EJf/eueQ5yhRc8lk3B24r4B1tTDY4S1TXw z4VbBnXUn7lZf1jXbaTMnY/VyC5FWiP9T6QI4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=C1rOqshDY+v2g7d1Z+TrKygKn6IvxZ+JtAdXXsgB/Go=; b=cYRdWtDGLFhIRi39lANJjpFt+ysLBSOv7U5q0oBwr73oVnqkOvIRhgmA/kiTK80MYE JK5/+X1Yvmdmep18XxU8Emlxyfjf9coXt/3lqtAOz0pZN3aG7xcBOlpKXkVA/NcaRMSn bsQ8zJe4HcIsgasRmL46ug4yN+k/ZtbV35gOcK00TswLRs9lx/MbYzzS2rH+bYMaYVLX LjWSKnG2QOj1MnemxLLG/ILl8gg0iGXq3VY7SA5cRy+rHZLOGrAJc5M2ubMbWmmwsZlR ndN2SoHLWrN5MnIIh50+//xT4gfXrlGlEzD9YfoXtlFM9nyWeIiXumnci+a54wSMqy0R c1Sg== X-Gm-Message-State: AGRZ1gK8VTJi6TujyWg5TFnCvHAa11kwEpMq3ir6rRTpObgLb9fG0W6n WOxkhopO7LsIpOdIejH9bZvEKoCpBkM= X-Received: by 2002:a62:1541:: with SMTP id 62mr38458416pfv.230.1543426161344; Wed, 28 Nov 2018 09:29:21 -0800 (PST) Received: from localhost.localdomain ([49.207.53.6]) by smtp.gmail.com with ESMTPSA id 84sm13624360pfk.134.2018.11.28.09.29.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Nov 2018 09:29:20 -0800 (PST) From: Amit Pundir To: Greg KH Cc: Stable , Amitkumar Karwar , Kalle Valo Subject: [PATCH for-4.4.y 03/10] mwifiex: Fix NULL pointer dereference in skb_dequeue() Date: Wed, 28 Nov 2018 22:59:02 +0530 Message-Id: <1543426149-7269-4-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543426149-7269-1-git-send-email-amit.pundir@linaro.org> References: <1543426149-7269-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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 --- drivers/net/wireless/mwifiex/cfg80211.c | 4 +++- drivers/net/wireless/mwifiex/wmm.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index 9a8982f581c5..6fcaa949b14a 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -2839,8 +2839,10 @@ int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) 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); diff --git a/drivers/net/wireless/mwifiex/wmm.c b/drivers/net/wireless/mwifiex/wmm.c index acccd6734e3b..ed8b69d1d65c 100644 --- 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(struct mwifiex_private *priv, 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_private *priv) 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);