From patchwork Sun Feb 11 02:56:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Huang X-Patchwork-Id: 10210655 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 ADB4560594 for ; Sun, 11 Feb 2018 02:57:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9586329328 for ; Sun, 11 Feb 2018 02:57:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 883102932D; Sun, 11 Feb 2018 02:57:00 +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 E48C529328 for ; Sun, 11 Feb 2018 02:56:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752054AbeBKC44 (ORCPT ); Sat, 10 Feb 2018 21:56:56 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:44136 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751921AbeBKC4z (ORCPT ); Sat, 10 Feb 2018 21:56:55 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 36ACD60A4E; Sun, 11 Feb 2018 02:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1518317815; bh=jnRwq2i/XVNUjl+opKVCXQxLJS0i5oOV7SY5a7iEpLc=; h=From:To:Cc:Subject:Date:From; b=Bw+r7C6KOPN8yXS/op5vCCbtbL3FlqIG+PwKVm6q4+r2aVM7l0/usYqbYYLZi9GH0 R3Rdzl5EcWXSvrZ95l/WLmyoNcKWBPT9XuDUC3J1hf97d6M9Y7BafzMOplcwTW7/Cj 8Pafn1b5HETZxszWC4lpN88O4TcNIcTYRY+C8TvM= 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 1B58760A4E; Sun, 11 Feb 2018 02:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1518317814; bh=jnRwq2i/XVNUjl+opKVCXQxLJS0i5oOV7SY5a7iEpLc=; h=From:To:Cc:Subject:Date:From; b=gxpRfxS/VvM1wrX6Nt4ltShroX4KcMb5/6H3m3bgMnAR9fH82lwqFXu+soFmdmC0X s6aGmOdoNbT2WI6IagTvjJBBCkl3f9WuvPegEClZbzWYarkDuo4dhMvtqQZhyc6me7 /ml0oGwacJyeRrQFgSW5ZUnA/5BNTZQnvruO/3Xo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 1B58760A4E 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.org 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:56:45 +0800 Message-Id: <1518317805-5796-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 Tested-by: Brian Norris --- 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;