Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp805314imm; Mon, 21 May 2018 14:50:05 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrPXQo3ImZI013A4KDzFqAqpE1htxSYj5q/Rw+q42DZ0bPcBV0tAAMCvmVHAzuTvkNY2ngV X-Received: by 2002:a62:8dc9:: with SMTP id p70-v6mr21526400pfk.72.1526939405438; Mon, 21 May 2018 14:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526939405; cv=none; d=google.com; s=arc-20160816; b=eETUf7NLMoNKf8lWiAwTDNPzGwB7Wof5wwuiJQZWZE6TnnX4xfB5Nuia7iwbAd+ulb Q0kiDSfaSdDwDNwR2qpS+C44mzhCom82Ck54VSD+5PhiUbX6kfEi2b1k8xjJRnA800OI fQ1muo1nwKI3cuU38MVFKAEa37QnHw5Y5VD8ialNqZAG0QjBW+vFBsqFZ83OE7yYDguJ 8TrPqHGbAmg4RbR+zdnVO5pv04SRt8SKCkMWO+wvHqTwnfPZ8dScqaCccUFkq2zTI9PK 25FbXl8jLjTeaGG//O4f/pKnj6pYQ0BMdvSSvV3iOuVAqZdKsTRdXze2Fu58ClyJLkOY +Ifg== 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=RzluvsJGlIe8zYEEoNuNfr6V0Ey2eLNN7T2skHPtf6A=; b=ZwWOKBju3iBtCntUoEiTkfQ02e27WZQ4UWZhGxirsRGJ8fkTkrCF/QP6AK+xW1X8NW cGfneHy75DjpHzs94xnjGcpuVe4zE7VYhKYrQivOpf3ja0hDGQ0mXJ8DjVKnIhu1fAQB Cg2J/f/4LSsQW3Y2a2/FL6TdVkmKFwFfnVhkhN6PltxsFL072n8bY+Jfuojoyzh5/7E2 ScqykMMDVo/psnAPvNhrpe1DTzOWImJzonoTxUKAQOuDnw+Z7Q0rkTOLzX6dY4z/8mXd jNlh5hxz4D5igYwiBnucn1jbYuYj4Mkg6CqCq8Bxi8AGq1hUzTNY3HGr2Tcpu9075Dva pLQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OMXt06P/; 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 j5-v6si11916994pgt.449.2018.05.21.14.49.50; Mon, 21 May 2018 14:50: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; dkim=pass header.i=@kernel.org header.s=default header.b=OMXt06P/; 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 S932248AbeEUVtK (ORCPT + 99 others); Mon, 21 May 2018 17:49:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:38256 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932136AbeEUVXZ (ORCPT ); Mon, 21 May 2018 17:23:25 -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 E9B232075C; Mon, 21 May 2018 21:23:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526937804; bh=dXoJFCv+azQTF4xi6u3n+S3PPM6n8L9N4l71jw7+SZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OMXt06P/lMpvfpboD9GUovJB3aCYwpGCoBTB2BREC+24UFNNNHbMMk49ebLglAu8w DTHz4KJOok3KElV+agr2KoGgwCFY0lDai/b92ST0lFM2xTJ2RZSpGA2judQsNmp3Rl v1qlMbKnw48+fVPn1zESuoHMnEK/ZtVEroRSIZws= 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.16 006/110] usbip: usbip_host: fix bad unlock balance during stub_probe() Date: Mon, 21 May 2018 23:11:03 +0200 Message-Id: <20180521210504.433346601@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180521210503.823249477@linuxfoundation.org> References: <20180521210503.823249477@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.16-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 @@ -82,7 +82,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)