Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp31053imm; Fri, 21 Sep 2018 17:27:53 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZwkWzZO2QS+mM36OqI4JV/fNdNk+56/9Oox0FwXmyBYm3F89NJez2WAE9nGzI9Px2ifcow X-Received: by 2002:a62:b0e:: with SMTP id t14-v6mr173665pfi.36.1537576073197; Fri, 21 Sep 2018 17:27:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537576073; cv=none; d=google.com; s=arc-20160816; b=mgzCl4+MxHGLQ25e2ZVyRazdtGo2pK1i6Ry4EN9ljvTxcyZf99G0FB0iB0QPoOpCDj tRoPpIF5+pLrOPS8jmJgk+tEuaYLltX+jUUhBnxBpdgP+vFcWFAg2AiL4cYJOZOQj1rU L6zYu8SO0IUWlvWsRgzrw0YTNL73rDPRXt42BBMMCRm/KXAK2mI5jiyY6wa/krcNPyhi 2Krwm40xzX6l+EAvhUyD1ufB6hR4xS6fZGd03YltYl5Ripi0cbMcCNKUO2bA8CMiZSHh dpB3lp86EeUTnofPJ2TvrvHEBAQ8h+J2qI6B8HWapO2Q9PwC4eRxddAiskDXwpFY/Wwg W/aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=meRoxl3db7RkYxWsvw5v/By+Ds5Hl5scd6RPpe/xsQ4=; b=zaL4+elQEYrfLemUi5A9dxrwDi9qpnQAVYb1ZHboziIhjptohqakBPu7HE05GAFXzl s7BGOe+QLE4YzYCkUdLlmSEXR+AfHa2PcbnKiKZCFYDkc+iTg8nkQyqfDFVlasffqxiB zIfZNNl4xHosbGUgh0jNQt1y2AKPRkomHUScxDqihRjFbm7RPdBZDRCQjdHWsvAXmvp1 VITprizeuMQ7y+88/0fzmzLKY72+eE+6PMMqcqZNsxmiZ3TZqepu1hKi3CdsH8UK5a9p DMC0H2poI8aUTZncHTS1AU4RgpCgiuzBFjlf7G72oYs5qS8UzaaW9JecqGIVmV5YmhlQ KRNA== 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 n11-v6si27658458pgm.509.2018.09.21.17.27.37; Fri, 21 Sep 2018 17:27:53 -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 S2391864AbeIVGKm (ORCPT + 99 others); Sat, 22 Sep 2018 02:10:42 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:44070 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391736AbeIVGKm (ORCPT ); Sat, 22 Sep 2018 02:10:42 -0400 Received: from [2a02:8011:400e:2:cbab:f00:c93f:614] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1g3Vds-0008BW-Hu; Sat, 22 Sep 2018 01:19:24 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1g3Vdn-0000qW-D9; Sat, 22 Sep 2018 01:19:19 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Greg Kroah-Hartman" , "Shuah Khan (Samsung OSG)" Date: Sat, 22 Sep 2018 01:15:42 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 11/63] usbip: usbip_host: fix bad unlock balance during stub_probe() In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:cbab:f00:c93f:614 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.58-rc1 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) Signed-off-by: Greg Kroah-Hartman [bwh: Backported to 3.16: adjust filename] Signed-off-by: Ben Hutchings --- drivers/staging/usbip/stub_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/staging/usbip/stub_main.c +++ b/drivers/staging/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)