Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3805083ybi; Mon, 29 Jul 2019 12:59:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxAWrwg/SzhFEDFkXwmU6ueNDMqcvMXFZkEwt+Oi/4PErkSt6XlirJEtjc1oFEDBQWIhh8N X-Received: by 2002:a63:f04:: with SMTP id e4mr102935030pgl.38.1564430380842; Mon, 29 Jul 2019 12:59:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430380; cv=none; d=google.com; s=arc-20160816; b=0JRSrvqElqdH2cMNPrwdlhylR2POTTn2DUnF7kJyHW4bSqsgvZ9yFRuNQ/WMcDmURt 0lvbHqcib0oUJ2Ga71fh5O15yFVNTtCvaJNa3tlWrvJV16nZnQg2IIg3RIU6NACwkTK2 hfjqmOTub8mW4SjLEbA80biqv69JJcynfHUw+dQCRqJHWiHkfMUwKPMjxJYf9j5/xe0r TuozVbjb8PbDXq24Sj83q4v09REslOCQ+yatwJrw0iubi885hqI95VtEi2kzGm1xdxNu eHKPQoyb4ULAo0vPTAT5LviAowxUfmrH9K/ofRbzL4K6EmCRLmjTAFz3gbpd9Ouxy18u N1TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pKRdHabJZM9k0nP4MsOpq1jV0a/EpxMODR/YU8b12Gk=; b=UzBJ/NtAF6z85PVwIzWjnBQMtR+FBJWEBvPy9krxgxezRIsVKuTTtsW9egB5swrD+A LcvcGVJswXYc6TmsZbW1F1fDLfWuZ21pABCOWGgw34Gm5DK30lqOdSqTc2BN0K9jw6Ku 3ea3I8Kdhes495Vy7YsTWBY4dNtsagWVHK3kcD1BTVhnC3FQlU9BavssDSHJtNdn7q/d 1/c0OFm2LSksDPAIgMV1i0PDScCOLcISohkruAvjW6iqmk3n75rvKsTN7HwFEEVWZFnO 73GGqpP8l4aZmobcogI3KdBcQhPZprVLwOwW+8oHbl/ral9toPHIr78j8pyOscGDTXbq DcuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jGtXggJO; 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 y82si26839881pfb.58.2019.07.29.12.59.26; Mon, 29 Jul 2019 12:59:40 -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=jGtXggJO; 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 S2390837AbfG2Tx7 (ORCPT + 99 others); Mon, 29 Jul 2019 15:53:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:45948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390679AbfG2Txd (ORCPT ); Mon, 29 Jul 2019 15:53:33 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 E5F5D2171F; Mon, 29 Jul 2019 19:53:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564430012; bh=g3Qa5pRkKnZVNZExxBrPTdWu2N5wP1p8syJV2zVv3rc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jGtXggJOnZiW5nynnQdPuGYzpymwjDuZv5331rYrtDNVHKLj3XJOJKxEWr3WTKHln 6GUJomXWWIgqP3WOb4VvJWBbK5g+E8hAw85bymE7jDrJSprzQVOnWAiiVz3Q4lryFu 2UGqRAz4kWCPvOMUcjwFHgfTT30+SjGx0j9p4EPM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+fd2bd7df88c606eea4ef@syzkaller.appspotmail.com, Phong Tran Subject: [PATCH 5.2 169/215] usb: wusbcore: fix unbalanced get/put cluster_id Date: Mon, 29 Jul 2019 21:22:45 +0200 Message-Id: <20190729190809.186902009@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Phong Tran commit f90bf1ece48a736097ea224430578fe586a9544c upstream. syzboot reported that https://syzkaller.appspot.com/bug?extid=fd2bd7df88c606eea4ef There is not consitency parameter in cluste_id_get/put calling. In case of getting the id with result is failure, the wusbhc->cluster_id will not be updated and this can not be used for wusb_cluster_id_put(). Tested report https://groups.google.com/d/msg/syzkaller-bugs/0znZopp3-9k/oxOrhLkLEgAJ Reproduce and gdb got the details: 139 addr = wusb_cluster_id_get(); (gdb) n 140 if (addr == 0) (gdb) print addr $1 = 254 '\376' (gdb) n 142 result = __hwahc_set_cluster_id(hwahc, addr); (gdb) print result $2 = -71 (gdb) break wusb_cluster_id_put Breakpoint 3 at 0xffffffff836e3f20: file drivers/usb/wusbcore/wusbhc.c, line 384. (gdb) s Thread 2 hit Breakpoint 3, wusb_cluster_id_put (id=0 '\000') at drivers/usb/wusbcore/wusbhc.c:384 384 id = 0xff - id; (gdb) n 385 BUG_ON(id >= CLUSTER_IDS); (gdb) print id $3 = 255 '\377' Reported-by: syzbot+fd2bd7df88c606eea4ef@syzkaller.appspotmail.com Signed-off-by: Phong Tran Cc: stable Link: https://lore.kernel.org/r/20190724020601.15257-1-tranmanphong@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/hwa-hc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/usb/host/hwa-hc.c +++ b/drivers/usb/host/hwa-hc.c @@ -159,7 +159,7 @@ out: return result; error_set_cluster_id: - wusb_cluster_id_put(wusbhc->cluster_id); + wusb_cluster_id_put(addr); error_cluster_id_get: goto out;