Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8992775ybi; Tue, 23 Jul 2019 19:38:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqxbnJJ8w/J1AdgXDjCBMXiTcvdkdzPUGXUw/iPy8y5wM/rJzvqk77eJzSa+OctVFuuOulxy X-Received: by 2002:a17:902:6a88:: with SMTP id n8mr83738727plk.70.1563935880520; Tue, 23 Jul 2019 19:38:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563935880; cv=none; d=google.com; s=arc-20160816; b=D6w+UNmXVoL8rdR9e9V9kW3CshBEl3lQ/rOz2wx2hzCP+xCyGtpJSiGJ2KeE8FCvU4 DbmiAwAWDK5c4EkhjGh5Iqzr6G3oZaBpaIPK1NHybWsPviT3QdVkCWzaCPOZqZb4aLmm UbCmdJK8dsiM2pWug1FD7HSBmHZCwsMApLj6NkP/D+F2w9DgZKBUUs92vvaC2NEdwdUj 0Zcxm+cJTzNPa2k5M42+ENOTa1JloWf7DaM8SPDrEv320JvfOnfFUC48WbvHbld7sm+4 aXQwyBaxkrUZ/ae3RN/wxXPhqg5UjYf76ma2ZyZqbLqx39QvoT+dW0F5g8AS5moz+oR+ TePQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eUEsu1aJQ43M1dFiRUsIH0xR8QMlq0eMWSMkix2nG/s=; b=g8GHVv+P4+sGlgg9+2FgkPserkkb/td8IXyd0AtdytbP9KI53L9dq7vTwvcY3FmazF Xr58VHM5E8iV5c/fIYpPx0+pS+jWbjAmBNNbe96poInA5OjJHD5D/9EFMPYgs/Q121l6 /6JdNOcpt1b7W2jH2JNUCHTK10rDtOXB4sMh+B9NdCOCUWIO6fiqZ2b1qs0J2y0oeOjH MBiUQ88VY7a6SwZoFgs4z04NyzSOD+eVXkpPM7KrwOyEXakQdiPGZl/+sEXX4+A3znsn 7qwjdu0BbgOZyGqXNh+ggLzNTmzVDK4/jRqGUCdZyQCi4xYnxH2yuy0a78BwYHVmOHBw 79Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SpmUwRuI; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11si13677428pgq.498.2019.07.23.19.37.46; Tue, 23 Jul 2019 19:38:00 -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=@gmail.com header.s=20161025 header.b=SpmUwRuI; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728874AbfGXCGU (ORCPT + 99 others); Tue, 23 Jul 2019 22:06:20 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:45934 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726544AbfGXCGU (ORCPT ); Tue, 23 Jul 2019 22:06:20 -0400 Received: by mail-pg1-f196.google.com with SMTP id o13so20330081pgp.12; Tue, 23 Jul 2019 19:06:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eUEsu1aJQ43M1dFiRUsIH0xR8QMlq0eMWSMkix2nG/s=; b=SpmUwRuIct58AB5vD4iMiE7f2Wp/E4iU/jQyuqwEp/xyS9ElMer8ikqdVjtrNj3EkT Z42ODOk1Yi6RlKG6jAwgXhbFKJawYA6q1E2S5mKgw37wmAJ0dbIOR/7Ng5qdm6DqkK3p HkACORz9DtEO0gLLCRp1IhH1j4jhb0lfpavqRe5LVPc7fMLq1BxTMGMwkHh/0JN4zpBE 6RgXGsITgVOh8i1Vz3e5ucjLC9x6SeWBoWq9ZrUThpLGAtlh52CwWYJdgCXPUWW5BCPb 0VhQPINV/CrfaiEP/V8C2z+Vuz7kYTzXGYtIYijCf0VnuoqEtZBJmf39NE3/tVAcZS36 gTnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eUEsu1aJQ43M1dFiRUsIH0xR8QMlq0eMWSMkix2nG/s=; b=qXoh1otb4BlWYQ1SUNmO9p8zBC+0DGuGgenlgna8iyeXhuXiyMvpITdBY5yXPyGfV3 f4nTREu2Miq6rIi03aFI/2aZSZeRlwvQ7E0cJHsykPjyScSUZT7s8nA0LJg60dfe6lLk GviYKlDZBk12ylzVZeAJPqh6qKBM07DEgOR52U9n4ma71TaaIT24Yt4NL9e6jMQ4DfcX HhC8CsCNLwsZWDdbAIZnlc9Lcc3AG7tlLISsJJvlerLeibUvV6BbasYMJUyjv83+8Wy/ 7VJcNX2VqzSf74QwOncmJv0hwMsVkdEu3S3+jinT6IQij1S9+Ownwl8IqfaTtwxGjzEk xv3A== X-Gm-Message-State: APjAAAVn2SXA8zlxrQ5Me3oMlUrT+s2p58QGecwPsGkSIcDwmdmjcrNR 8rL7uy5VzxZWptcF2jX5JiA= X-Received: by 2002:a62:1d8f:: with SMTP id d137mr8975675pfd.207.1563933979631; Tue, 23 Jul 2019 19:06:19 -0700 (PDT) Received: from debian.net.fpt ([2405:4800:58f7:33d1:2651:be77:cf4e:952]) by smtp.gmail.com with ESMTPSA id 65sm48163919pgf.30.2019.07.23.19.06.16 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 23 Jul 2019 19:06:18 -0700 (PDT) From: Phong Tran To: syzbot+fd2bd7df88c606eea4ef@syzkaller.appspotmail.com Cc: andreyknvl@google.com, gregkh@linuxfoundation.org, joe@perches.com, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, louis@kragniz.eu, syzkaller-bugs@googlegroups.com, benquike@gmail.com, linux-kernel-mentees@lists.linuxfoundation.org, Phong Tran Subject: [PATCH] usb: wusbcore: fix unbalanced get/put cluster_id Date: Wed, 24 Jul 2019 09:06:01 +0700 Message-Id: <20190724020601.15257-1-tranmanphong@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <000000000000d48965058e589a94@google.com> References: <000000000000d48965058e589a94@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reported-by: syzbot+fd2bd7df88c606eea4ef@syzkaller.appspotmail.com 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' Signed-off-by: Phong Tran --- drivers/usb/host/hwa-hc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c index 09a8ebd95588..6968b9f2b76b 100644 --- a/drivers/usb/host/hwa-hc.c +++ b/drivers/usb/host/hwa-hc.c @@ -159,7 +159,7 @@ static int hwahc_op_start(struct usb_hcd *usb_hcd) return result; error_set_cluster_id: - wusb_cluster_id_put(wusbhc->cluster_id); + wusb_cluster_id_put(addr); error_cluster_id_get: goto out; -- 2.20.1