Received: by 10.192.165.156 with SMTP id m28csp239908imm; Tue, 17 Apr 2018 09:20:05 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/95MaLnS+BK0SxzjS50cKqUEr+RG72kI3f/bn05j6mLIbeBreuOSE20sk5tUIBtg6u6xPM X-Received: by 10.98.102.79 with SMTP id a76mr2558725pfc.162.1523982005812; Tue, 17 Apr 2018 09:20:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523982005; cv=none; d=google.com; s=arc-20160816; b=SrVeLexzmTMnyGU2+9kYYMN6p6AUVZrx5rRUbQqsDOj80S22qFbpSgte2gyKJOYMuY 0TaeStI1r69IIOUmHTLTZS3ZjzSmthAt28SjLu6zJqBAwaDevCQRu9FuUfR8QSs9Ru4b 8Ib8BqS2zbUmYvs7EmMu9p09WRA7sP0EJoNhn2dsJln1XvUwK5vIKNMfWyrL+u+7GqS8 Fl5IKuRAAqT23srauDXiuUzSYRoN/WHzLyDEHy/KH70jK/Z/zGdA99HCQ96QrqQGt11h 6epojRCxiJ3L17+BehvvO6MosLh7AW7HhUPHezRcTEaeq95fOqSZG3sqtubKJKbco7PA QJpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=nVnujKJxYHmI/5ZVVzuc6VzUarJh69aSyZXFybzupz4=; b=v311rVeX7jZhMYSyzNT4lUjjuFd5iQQ7UO3UNyLyXkDdafh3t+ptqDxTajcK6UiIck MwNy0ZPGpsSFmEZ7H+fMFMTFs+z8BR0K9Xrujn3XZCu5NBAdPBuPhJ7zoyeT/dUTAs0C QGk0VdsRGI9o8+YlFKGKPin2E4dav9Fld5Zm9Jky9NM8wzEoamtpRf05xlsCzdJ+i3au xMJKiCfo3uQpsMDXhrvFHguR2pqfkqUF/e5zuC3t4AszxANySWoSjJrG4V5LWt0/dxmV sMk3LJaZMkU8wFbSlQ3zQv+L575AX5SZJYbWjkqABTfUcogvjOdUXELzEE3rEOJetv/9 9FGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j21si13220311pfe.132.2018.04.17.09.19.51; Tue, 17 Apr 2018 09:20:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755868AbeDQQKf (ORCPT + 99 others); Tue, 17 Apr 2018 12:10:35 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36438 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755228AbeDQQKc (ORCPT ); Tue, 17 Apr 2018 12:10:32 -0400 Received: from localhost (unknown [46.44.180.42]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4857DD2D; Tue, 17 Apr 2018 16:10:31 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sudhir Sreedharan , Kalle Valo Subject: [PATCH 4.9 60/66] rtl8187: Fix NULL pointer dereference in priv->conf_mutex Date: Tue, 17 Apr 2018 17:59:33 +0200 Message-Id: <20180417155648.473013232@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180417155645.868055442@linuxfoundation.org> References: <20180417155645.868055442@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sudhir Sreedharan commit 7972326a26b5bf8dc2adac575c4e03ee7e9d193a upstream. 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 Signed-off-by: Kalle Valo Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c +++ b/drivers/net/wireless/realtek/rtl818x/rtl8187/dev.c @@ -1454,6 +1454,7 @@ static int rtl8187_probe(struct usb_inte 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); @@ -1627,7 +1628,6 @@ static int rtl8187_probe(struct usb_inte 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",