From patchwork Thu Feb 15 07:22:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudhir Sreedharan X-Patchwork-Id: 10220507 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 BC333601E7 for ; Thu, 15 Feb 2018 07:23:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5D73286C4 for ; Thu, 15 Feb 2018 07:23:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 99AC429085; Thu, 15 Feb 2018 07:23:27 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB 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 43CDE286C4 for ; Thu, 15 Feb 2018 07:23:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754856AbeBOHXL (ORCPT ); Thu, 15 Feb 2018 02:23:11 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:37860 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754817AbeBOHXJ (ORCPT ); Thu, 15 Feb 2018 02:23:09 -0500 Received: by mail-pg0-f65.google.com with SMTP id o1so3592514pgn.4 for ; Wed, 14 Feb 2018 23:23:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mvista-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=lk2smMaUA6Xk9Sfo9qvH3lTwAdaLg+WfqYhmEVzJPf8=; b=tP1GslzjaIcTbgehA/3sB6CrRk1seABywFIuJUAsYfl+rpkm8VdpXU0CiIPlUgEadK CJiZ1qDp6Dt8WrKOTwIupi2czF3Trcks7gteSVQXbSfavrKEBVOqTr2ahaZhVC8n5oXe pFIaBTPh03+sVKwUzZZamjztK8CX1KSe1KFjFDWtcxyisWA+pX3dIz/C7PeQ6YYSTvXC UlEnFvWdspmtouWbY24XmLUlflNwrlnIUrYsKmQSWhwPAGZW4L3oJRmjgqyOhvbwvIJE YC5ZbXhRbcR9khPtIhpHTC5gIRaujv0qGU4+kR2ZoEPt4uKDgXqq2u1eNrKYl5LijwL4 5Ogg== 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; bh=lk2smMaUA6Xk9Sfo9qvH3lTwAdaLg+WfqYhmEVzJPf8=; b=rkWPqKPru0ni+1wAiysI7UEO2WGF+J9EZYgvJ+tfrlJ22Pz3pCYjJfJcKv7oFvRnik xY0KMvn1jJS7RwyPFIHyooSgE6OIwGU89ORxvqBKocZ2aK0wRR/tZ+sBhqGHPxBA5+JV JmoDkFAJjis3vccOU/Z9XLMjbcaBlrHvWT4BA+qr3jNX4VPzg3lWpYXaACKehmYf3JGn M/qpKpin74P0FkQEqzaHL0cBkxwJY6JfFsrse51GOpe+RgRYEvhrd0Hb/pWypOGdGKEo wcWFklPXvuz7j4X3gYkOy1mw2CXqdvTSvySl7+SwRh4sOmlN6PddrA7tKsJGfy8t8iz0 oIUw== X-Gm-Message-State: APf1xPAXLPS0uh+ulebqfmCF1jeY5UwdYp1T++D5UqZgyhHtTgqfLWAl /8WkEqGwhSUKB6KxXxMCEXen4w== X-Google-Smtp-Source: AH8x227b7N81xrZzXzfgC7YyBnysfsfaii1If/qgfFf2BwUfMPWbdLmEl5i2QyVx51DwAYxpwrkBVg== X-Received: by 10.101.91.140 with SMTP id i12mr1400347pgr.297.1518679388739; Wed, 14 Feb 2018 23:23:08 -0800 (PST) Received: from sudhir-OptiPlex-9010.mvista.com ([111.93.218.67]) by smtp.gmail.com with ESMTPSA id e23sm40424334pff.144.2018.02.14.23.23.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Feb 2018 23:23:07 -0800 (PST) From: Sudhir Sreedharan To: herton@canonical.com, htl10@users.sourceforge.net, Larry.Finger@lwfinger.net Cc: kvalo@codeaurora.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Sudhir Sreedharan , stable@vger.kernel.org Subject: [PATCH] rtl8187: Fix NULL pointer dereference in priv->conf_mutex Date: Thu, 15 Feb 2018 12:52:45 +0530 Message-Id: <1518679365-15697-1-git-send-email-ssreedharan@mvista.com> X-Mailer: git-send-email 2.6.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 This can be reproduced by bind/unbind the driver multiple times in AM3517 board. Analysis revealed that rtl8187_start() was invoked before probe finishes(ie. before the mutex is initialized). INFO: trying to register non-static key. the code is fine but needs lockdep annotation. turning off the locking correctness validator. CPU: 0 PID: 821 Comm: wpa_supplicant Not tainted 4.9.80-dirty #250 Hardware name: Generic AM3517 (Flattened Device Tree) [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (register_lock_class+0x4f4/0x55c) [] (register_lock_class) from [] (__lock_acquire+0x74/0x1938) [] (__lock_acquire) from [] (lock_acquire+0xfc/0x23c) [] (lock_acquire) from [] (mutex_lock_nested+0x50/0x3b0) [] (mutex_lock_nested) from [] (rtl8187_start+0x2c/0xd54) [] (rtl8187_start) from [] (drv_start+0xa8/0x320) [] (drv_start) from [] (ieee80211_do_open+0x2bc/0x8e4) [] (ieee80211_do_open) from [] (__dev_open+0xb8/0x120) [] (__dev_open) from [] (__dev_change_flags+0x88/0x14c) [] (__dev_change_flags) from [] (dev_change_flags+0x18/0x48) [] (dev_change_flags) from [] (devinet_ioctl+0x738/0x840) [] (devinet_ioctl) from [] (sock_ioctl+0x164/0x2f4) [] (sock_ioctl) from [] (do_vfs_ioctl+0x8c/0x9d0) [] (do_vfs_ioctl) from [] (SyS_ioctl+0x6c/0x7c) [] (SyS_ioctl) from [] (ret_fast_syscall+0x0/0x1c) Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = cd1ec000 [00000000] *pgd=8d1de831, *pte=00000000, *ppte=00000000 Internal error: Oops: 817 [#1] PREEMPT ARM Modules linked in: CPU: 0 PID: 821 Comm: wpa_supplicant Not tainted 4.9.80-dirty #250 Hardware name: Generic AM3517 (Flattened Device Tree) task: ce73eec0 task.stack: cd1ea000 PC is at mutex_lock_nested+0xe8/0x3b0 LR is at mutex_lock_nested+0xd0/0x3b0 Cc: stable@vger.kernel.org Signed-off-by: Sudhir Sreedharan --- drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c b/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c index 121b94f..9a1d15b 100644 --- a/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c +++ b/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c @@ -1450,6 +1450,7 @@ static int rtl8187_probe(struct usb_interface *intf, goto err_free_dev; } mutex_init(&priv->io_mutex); + mutex_init(&priv->conf_mutex); SET_IEEE80211_DEV(dev, &intf->dev); usb_set_intfdata(intf, dev); @@ -1625,7 +1626,6 @@ static int rtl8187_probe(struct usb_interface *intf, printk(KERN_ERR "rtl8187: Cannot register device\n"); goto err_free_dmabuf; } - mutex_init(&priv->conf_mutex); skb_queue_head_init(&priv->b_tx_status.queue); wiphy_info(dev->wiphy, "hwaddr %pM, %s V%d + %s, rfkill mask %d\n",