From patchwork Mon Nov 14 13:25:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 9427497 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 A45EC6047D for ; Mon, 14 Nov 2016 13:24:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 950AF28932 for ; Mon, 14 Nov 2016 13:24:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89EBE2894E; Mon, 14 Nov 2016 13:24:29 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable 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 87EB428932 for ; Mon, 14 Nov 2016 13:24:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752109AbcKNNXx (ORCPT ); Mon, 14 Nov 2016 08:23:53 -0500 Received: from mail-lf0-f43.google.com ([209.85.215.43]:35655 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751522AbcKNNXt (ORCPT ); Mon, 14 Nov 2016 08:23:49 -0500 Received: by mail-lf0-f43.google.com with SMTP id b14so57966116lfg.2 for ; Mon, 14 Nov 2016 05:23:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id; bh=oeVrDpAoIAjV6Ric3lYPCo5obbZRVD+c2daQa9nNOE4=; b=CNa0b0+2nEt8Dpw5zUWyCqkc3hOcItGJml7lTpklqnQikVpaFqlHw5mjsFy4WQKz/P psI83sjmQ/+g3q0/czWIbuetEKC94csHie0SLmf5VSjRSj2iD2FEu8ccDuiP/eHNVNQD Mzlfv5vRMxdY98LmjsggKnDtMSNEb1TDBxJT4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=oeVrDpAoIAjV6Ric3lYPCo5obbZRVD+c2daQa9nNOE4=; b=cmGrwS5ae0Td4RYib6y8YgJwcSl6HQt16TKijLnhOnkEvvZU7axjGBJNdlDXLibsw6 As2fdHPGlhWjXfkY3Sv/9juFQon2HpS5Rmp0XyMJtH8iYLlL0fXsgKY5WaKzyaT0rW8C j162K1StbFliUufcbGqnygRhkZJ7vhLeE144L2K7a9YjnImpst6ZXsL9WkdnsSNWWjse tfir3O1uu3mbWHsTtq5bpR54mM/mEVuAPn89doJPTGKmeLwm/5G3nPQsZzUlBlw72yly mhptj0jin/0uYBSQuU29kZe7UqhwHrigYl9wX1EDR26a1mXLuXUtjSRYzAoBpt/M9rQY 6hqQ== X-Gm-Message-State: ABUngvdtgkkmFHk8ZGV3pAMS1gLy7mRRi5SthFrG2a5KIE3k4StqHawH4KI/+0HJAcGlf/bZeTqN9IACh9nhtLR6TS3mIkXfFAfffFQvfkZcOJdoIMVDI6Fj5D4HIiCUSTVLPf+1zJutyg== X-Received: by 10.25.204.131 with SMTP id c125mr8373833lfg.105.1479129826224; Mon, 14 Nov 2016 05:23:46 -0800 (PST) Received: from localhost.localdomain ([91.198.246.8]) by smtp.gmail.com with ESMTPSA id y131sm607215lfd.36.2016.11.14.05.23.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Nov 2016 05:23:45 -0800 (PST) From: Michal Kazior To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Michal Kazior Subject: [PATCH] ath10k: fix null deref on wmi-tlv when trying spectral scan Date: Mon, 14 Nov 2016 14:25:23 +0100 Message-Id: <1479129923-11083-1-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 2.1.4 X-DomainID: tieto.com 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 WMI ops wrappers did not properly check for null function pointers for spectral scan. This caused null dereference crash with WMI-TLV based firmware which doesn't implement spectral scan. The crash could be triggered with: ip link set dev wlan0 up echo background > /sys/kernel/debug/ieee80211/phy0/ath10k/spectral_scan_ctl The crash looked like this: [ 168.031989] BUG: unable to handle kernel NULL pointer dereference at (null) [ 168.037406] IP: [< (null)>] (null) [ 168.040395] PGD cdd4067 PUD fa0f067 PMD 0 [ 168.043303] Oops: 0010 [#1] SMP [ 168.045377] Modules linked in: ath10k_pci(O) ath10k_core(O) ath mac80211 cfg80211 [last unloaded: cfg80211] [ 168.051560] CPU: 1 PID: 1380 Comm: bash Tainted: G W O 4.8.0 #78 [ 168.054336] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.7.5-20140531_083030-gandalf 04/01/2014 [ 168.059183] task: ffff88000c460c00 task.stack: ffff88000d4bc000 [ 168.061736] RIP: 0010:[<0000000000000000>] [< (null)>] (null) ... [ 168.100620] Call Trace: [ 168.101910] [] ? ath10k_spectral_scan_config+0x96/0x200 [ath10k_core] [ 168.104871] [] ? filemap_fault+0xb2/0x4a0 [ 168.106696] [] write_file_spec_scan_ctl+0x116/0x280 [ath10k_core] [ 168.109618] [] full_proxy_write+0x51/0x80 [ 168.111443] [] __vfs_write+0x28/0x120 [ 168.113090] [] ? security_file_permission+0x3d/0xc0 [ 168.114932] [] ? percpu_down_read+0x12/0x60 [ 168.116680] [] vfs_write+0xb8/0x1a0 [ 168.118293] [] SyS_write+0x46/0xa0 [ 168.119912] [] entry_SYSCALL_64_fastpath+0x1a/0xa4 [ 168.121737] Code: Bad RIP value. [ 168.123318] RIP [< (null)>] (null) Signed-off-by: Michal Kazior --- drivers/net/wireless/ath/ath10k/wmi-ops.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/wireless/ath/ath10k/wmi-ops.h b/drivers/net/wireless/ath/ath10k/wmi-ops.h index c9a8bb1186f2..c7956e181f80 100644 --- a/drivers/net/wireless/ath/ath10k/wmi-ops.h +++ b/drivers/net/wireless/ath/ath10k/wmi-ops.h @@ -660,6 +660,9 @@ ath10k_wmi_vdev_spectral_conf(struct ath10k *ar, struct sk_buff *skb; u32 cmd_id; + if (!ar->wmi.ops->gen_vdev_spectral_conf) + return -EOPNOTSUPP; + skb = ar->wmi.ops->gen_vdev_spectral_conf(ar, arg); if (IS_ERR(skb)) return PTR_ERR(skb); @@ -675,6 +678,9 @@ ath10k_wmi_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id, u32 trigger, struct sk_buff *skb; u32 cmd_id; + if (!ar->wmi.ops->gen_vdev_spectral_enable) + return -EOPNOTSUPP; + skb = ar->wmi.ops->gen_vdev_spectral_enable(ar, vdev_id, trigger, enable); if (IS_ERR(skb))