From patchwork Sun Feb 11 02:54:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Huang X-Patchwork-Id: 10210653 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1D9AA60594 for ; Sun, 11 Feb 2018 02:55:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 082432932C for ; Sun, 11 Feb 2018 02:55:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0EC12932F; Sun, 11 Feb 2018 02:55:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DAA52932C for ; Sun, 11 Feb 2018 02:55:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751806AbeBKCzD (ORCPT ); Sat, 10 Feb 2018 21:55:03 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:43598 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751149AbeBKCzC (ORCPT ); Sat, 10 Feb 2018 21:55:02 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 532C560A4E; Sun, 11 Feb 2018 02:55:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1518317702; bh=jnRwq2i/XVNUjl+opKVCXQxLJS0i5oOV7SY5a7iEpLc=; h=From:To:Cc:Subject:Date:From; b=jFt6PquqVy9fKIOKWywWa1XD6DecyWbZ9Q5COeE3R4LFedioSB9L8p+6LIAMSpCkU 5bT06U9N7Z5pqYjuvStecOZgwUAufv2/VS5a/AUgxLsYcfi6YDh4s0uxZAqeO05Ug9 xJg1SrA/1JLasA1dlSckJbQ/d+VVi8vrdcsU6YtE= Received: from cjhuang-station.qca.qualcomm.com (unknown [180.166.53.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cjhuang@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2EBF260A4E; Sun, 11 Feb 2018 02:55:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1518317701; bh=jnRwq2i/XVNUjl+opKVCXQxLJS0i5oOV7SY5a7iEpLc=; h=From:To:Cc:Subject:Date:From; b=R7Ap5FyfDOe3IGH0g4T5D6CCTxugzS54L8GrtR6aDodaj7D5AaaEjqJHvv+UWGu9G kH/Ndcb/4VyWftFg7LK0EmJB9eOgydGv1afnPHGY9lr5hhx/YoQ3CllkEqM9hxy+ch RIdVhT85JxaJhas1fbHcCSH3jYIDIholvfkmWvQU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2EBF260A4E Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=cjhuang@codeaurora.org From: Carl Huang To: ath10k@lists.infradead.orr Cc: linux-wireless@vger.kernel.org Subject: [PATCH] ath10k: fix use-after-free in ath10k_wmi_cmd_send_nowait Date: Sun, 11 Feb 2018 10:54:54 +0800 Message-Id: <1518317694-5741-1-git-send-email-cjhuang@codeaurora.org> X-Mailer: git-send-email 2.7.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The skb may be freed in tx completion context before trace_ath10k_wmi_cmd is called. This can be easily captured when KASAN(Kernel Address Sanitizer) is enabled. The fix is to add a reference count to the skb and release it after trace_ath10k_wmi_cmd is called. Signed-off-by: Carl Huang --- drivers/net/wireless/ath/ath10k/wmi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c index 58dc218..e63aedb 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.c +++ b/drivers/net/wireless/ath/ath10k/wmi.c @@ -1,6 +1,7 @@ /* * Copyright (c) 2005-2011 Atheros Communications Inc. * Copyright (c) 2011-2017 Qualcomm Atheros, Inc. + * Copyright (c) 2018, The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -1742,8 +1743,10 @@ int ath10k_wmi_cmd_send_nowait(struct ath10k *ar, struct sk_buff *skb, cmd_hdr->cmd_id = __cpu_to_le32(cmd); memset(skb_cb, 0, sizeof(*skb_cb)); + skb_get(skb); ret = ath10k_htc_send(&ar->htc, ar->wmi.eid, skb); trace_ath10k_wmi_cmd(ar, cmd_id, skb->data, skb->len, ret); + dev_kfree_skb(skb); if (ret) goto err_pull;