Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2066490imm; Thu, 24 May 2018 05:19:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpvK+lnbVDV6cbWWnVilkDEZARtQd/DnWzyUqVW/Bzp41tAHtKbaR4HD9Wk8C45xK3RYXNo X-Received: by 2002:a65:6151:: with SMTP id o17-v6mr5838608pgv.120.1527164371692; Thu, 24 May 2018 05:19:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527164371; cv=none; d=google.com; s=arc-20160816; b=iscN2FFYr0P2Rk3MJn7NdEKEL6Zi2DgPWzxyOZZICJkERJd5WsM3R2rHRO27EwWTHt zgQUk7RapRfZJCOlXH8PA4MACnQiwBarI8k/VRQnDoRe7WS/G3DZpmatHYoEXKV12roO EjXpnbXM87LeTWnvi/jnGD2wXq7m24Mmvd3QiQATpM4EcmgR9ZkT3z4Uf5ZuN7ywove0 8NtdjSRwF9Sy4ZjjUgsClKNo5ZVNB7471MsOIzzrcNnzeFNRntW8g+hXROAg3+LoAQ4k mwLLaGDR6PN0cm5AZ+od9rN5DnmZwBRq6DN2TeM/fLFrAVJ111FasvYI8QuA7VwadEnx vyEw== 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=c9MSvzkzPKASWz+Gkf6+7einzyggDXXS/mH0JqM2qL8=; b=G+BqmKs2r5pqBu8HQY2cZTOuI8QojhQbdAzRbxebR4ICdvZtsvUq+bsmQGIlcKretb t9JBy467eBXJqCCw4fEaPqmQF9KLA5SG7lOcT3R4tdUhmZmrWmzg7ZykDf/rmwSAnA12 7qcF4XJc8V7TKHHg7Q5ogPI91XyvyjJz7DBZdiZwZg7IuW1D2x2+bbKvvAi59yaMgXlB sUm/bOzBTM2QWXKZRvtHzrXU7zhC8gp1yA7mWEq6Cm8oWtGd8h258uzItWPAGYYQnPya qyn7phGTgo7PoP8AcsbLoQ1+S4rU+VFZn/dI3IP51MlCnx106UzntzSLz1O6vnyaMx87 Pa/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RE5+/L6K; 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 f18-v6si20539839pff.208.2018.05.24.05.19.16; Thu, 24 May 2018 05:19:31 -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=RE5+/L6K; 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 S969944AbeEXMSb (ORCPT + 99 others); Thu, 24 May 2018 08:18:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:53486 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966221AbeEXJlj (ORCPT ); Thu, 24 May 2018 05:41:39 -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 9AE97208A6; Thu, 24 May 2018 09:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527154899; bh=/EoTBjnTo/7miK62T2Mqa+ZU4qMeIrdDxnlRRnLonnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RE5+/L6KYIKnjFfXh27cY95bQAISrIJs/jjrPnMwikeUNGdV7jqwUEHgTHULbVRk7 HTM1sytuxih3sJFdixvUPl+xoYmFCcZz843Dcudj7ck3FUxgtWebH/gMkSBGVsyFQ3 d+d2h9i96kAFRUkwjBkcnw8NCR8RTBlQdQiAotZ0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Shuah Khan (Samsung OSG)" Subject: [PATCH 3.18 28/45] usbip: usbip_host: fix bad unlock balance during stub_probe() Date: Thu, 24 May 2018 11:38:36 +0200 Message-Id: <20180524093124.168539885@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093120.599252450@linuxfoundation.org> References: <20180524093120.599252450@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 3.18-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)