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: 10210657 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 8141360329 for ; Sun, 11 Feb 2018 03:10:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 704BA28F29 for ; Sun, 11 Feb 2018 03:10:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6503A28F67; Sun, 11 Feb 2018 03:10:30 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9677928F29 for ; Sun, 11 Feb 2018 03:10:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Owner; bh=w4kfiLcRtNI8KPfXNwMpK+BedpWw92nxslvW+cQRuqI=; b=R0ZSuMXZqRPDiQcOgDgG53Wxvf v71sSorEQ3tqxK1UIJQZ2nJ78chyzsopKS1CsBVSInIakDlgEQlw7VnF7IZXlIu4tPEv2ayZh8RJ7 gvv3uyaOTy3Apr8MhY4OSXGTKdi7wRWJ8sdcmoAhktYOiB+kPUdTvZ79DLfKP4/03k8ZcUBwsTwJc x6ZfQH8Y55EH+pnTMnt1QNlS7+BdlNYuubzJbqO3ZtT0r3cwtsSZDK9vOBPT0THgpJR8NSAjCEObE 8JL1pE6Ii4TOKxdSEC0qL4s2y2da22XdBFPXpQO2ZaSdQlmGJQI21U2pUokiQpmt0djTV4TyTDM8P BSWERfvQ==; Received: from [198.137.202.133] (helo=bombadil.infradead.org) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eki20-0006Re-Gw for patchwork-ath10k@patchwork.kernel.org; Sun, 11 Feb 2018 03:10:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=w4kfiLcRtNI8KPfXNwMpK+BedpWw92nxslvW+cQRuqI=; b=cpE WHDSMWUxJ7NVuj+/4qJBPhwKYIgSKeFCkINfRaT550wCQwuM4Uy8w+4YoJE7PQkd+3Htiigs1F7ne Rtu4RwHP1mOAYsBwGtzwP+hHNGy04m8sin58a48p/upbvMhzANko/BtbBL7bmhiKX95exPQ1E0OAv nTSrXT8eiFzoUPv2PPofH5X9WfdnLe8tZZz6TWeTPRN1EUtrXIpY2xs5XLzDY9aKh76AoYYBxhrAH zjC4/6+6uguua4akVpJA3ptQdu/jmhXWtWEW3cZh9bsvinD0Be1yOxtmCCjF2k+f9HFIZ5/7mclhu rokIOVvtb731sqGOnEOFcSuc0KawuwQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ekhpI-00018B-4V; Sun, 11 Feb 2018 02:57:12 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ekhpE-00017o-5d for ath10k@lists.infradead.org; Sun, 11 Feb 2018 02:57:09 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1CDFD60A66; 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 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 X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-wireless@vger.kernel.org MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.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;