Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1910108imm; Thu, 24 May 2018 02:46:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqd/2sLwnEi7v8IqDT5DgbWLwpBvS96JU52FDEJBKY5qYjNFWNAx5Tx8et6u8RZdzM72bEe X-Received: by 2002:a17:902:1004:: with SMTP id b4-v6mr6512555pla.82.1527155192199; Thu, 24 May 2018 02:46:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527155192; cv=none; d=google.com; s=arc-20160816; b=Sxhp77r08SFuLJyB2iOZsEmLroJM2w6MsGTkWaOtrJ8CY2P9nlszbyHet4s3Fw9aEC meetw6pT8MDl7MiXXHsVKUk4yWzTHfq1wedv+h1L8MeyLccJaUoSOuGE5W/ET4+tzMvd nF4ns3tq5GxK9fCcJ0R/Vobmqm+FrHCGB8wMGQThxWAWAYEVyTtDlfhj/eUQRK4hkjrC tS//R/7Mesqz0vUSp+jFMc1yZz7cC1UMzn8FZMhgr7W3fJsoDFsegnavCKZ1MSBqbHHA WqZ8dmRinZB6nAC1pGmO3hjuLhEnViNz8tWyOk0qWOZJsItnblH6iTCs9RmCSOC5CsbK fH4w== 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:dkim-signature :arc-authentication-results; bh=N3sDFki5M39jD8qam0YEDJ8oY92ri2WrbwgWow1yh9w=; b=TyxMYPOwHcjn93n2QARD9RsrsMwKSzK50hEhD8d6vMHchuE1Vo4IESwoQcNKzb4BIn fruzLGTROHDMIZcJr+apdsR15g4q5XS0bvbKiUrRVKNiJ9x73RqkjDnv4cJp109Y89Bp CZ2FuvzVCuCSEIWOZs4lVVVlF04eKf8tENSCN2cQao0kv9ZiBjy3n7O3/+l0gOvThWbb EO7XOKULJDtsl7Pkdgg2rn62iZ0xd//D879yVEIghTPKIG4pj/GVR5tS9TML3tTp2qlt 5IyNX9vClhtvd8o4oDs7jCOiQ3lXyhi1jd9pCczWlWDHAT7NrlZrKIN5SrPH/sSCzuOS zibA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dVSM/HmS; 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 j6-v6si21082223pfc.351.2018.05.24.02.46.17; Thu, 24 May 2018 02:46:32 -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; dkim=pass header.i=@kernel.org header.s=default header.b=dVSM/HmS; 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 S966636AbeEXJoW (ORCPT + 99 others); Thu, 24 May 2018 05:44:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:55606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966176AbeEXJoP (ORCPT ); Thu, 24 May 2018 05:44:15 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ABEF3208A6; Thu, 24 May 2018 09:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155055; bh=+KUud0aMjk2VrB/8Xmr5K7baf+BNj6Umew/s/9Gpk6c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dVSM/HmSVfM9WImkoqzAF472pxaZdj3bVUdb70imyVWf2E34pOBqBWJPqOsg9VScR w4QbVEAZABy7ozfpJLpXRTQ4YeJPTL1ey0w+M/iFK/xusl6Nrz9KNy0J8mLUm6kPf+ 0GQfdj65E/pJNCAW0li7CPs1tD4j7cJyqBemoYGs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Shuah Khan (Samsung OSG)" Subject: [PATCH 4.4 37/92] usbip: usbip_host: fix bad unlock balance during stub_probe() Date: Thu, 24 May 2018 11:38:14 +0200 Message-Id: <20180524093202.540404837@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093159.286472249@linuxfoundation.org> References: <20180524093159.286472249@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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shuah Khan (Samsung OSG) commit c171654caa875919be3c533d3518da8be5be966e upstream. stub_probe() calls put_busid_priv() in an error path when device isn't found in the busid_table. Fix it by making put_busid_priv() safe to be called with null struct bus_id_priv pointer. This problem happens when "usbip bind" is run without loading usbip_host driver and then running modprobe. The first failed bind attempt unbinds the device from the original driver and when usbip_host is modprobed, stub_probe() runs and doesn't find the device in its busid table and calls put_busid_priv(0 with null bus_id_priv pointer. usbip-host 3-10.2: 3-10.2 is not in match_busid table... skip! [ 367.359679] ===================================== [ 367.359681] WARNING: bad unlock balance detected! [ 367.359683] 4.17.0-rc4+ #5 Not tainted [ 367.359685] ------------------------------------- [ 367.359688] modprobe/2768 is trying to release lock ( [ 367.359689] ================================================================== [ 367.359696] BUG: KASAN: null-ptr-deref in print_unlock_imbalance_bug+0x99/0x110 [ 367.359699] Read of size 8 at addr 0000000000000058 by task modprobe/2768 [ 367.359705] CPU: 4 PID: 2768 Comm: modprobe Not tainted 4.17.0-rc4+ #5 Fixes: 22076557b07c ("usbip: usbip_host: fix NULL-ptr deref and use-after-free errors") in usb-linus Signed-off-by: Shuah Khan (Samsung OSG) Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/usbip/stub_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/usb/usbip/stub_main.c +++ b/drivers/usb/usbip/stub_main.c @@ -96,7 +96,8 @@ struct bus_id_priv *get_busid_priv(const void put_busid_priv(struct bus_id_priv *bid) { - spin_unlock(&bid->busid_lock); + if (bid) + spin_unlock(&bid->busid_lock); } static int add_match_busid(char *busid)