Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4418209ybl; Mon, 9 Dec 2019 10:28:30 -0800 (PST) X-Google-Smtp-Source: APXvYqypu8s6wCIc0r6iXrzpJZUZk57/mO5QgFr+VSoa0MQfsayBm4g35pYRgsv74EoB5q4Hf7nU X-Received: by 2002:aca:4eca:: with SMTP id c193mr347717oib.37.1575916110627; Mon, 09 Dec 2019 10:28:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575916110; cv=none; d=google.com; s=arc-20160816; b=SirwZNkks60GRKC/9+g4Ar+jw0XNpNWI/pyr5HOtLyQSof8lyybQXOQHdCD6MHKi6f 3XvBC+JLqyA7l2rO2NWrsDaGwVRGl0RBbrwaBWaHTnRXZRVjvgtr4ZkhsmuuknbkTVBd DHvoy0YGHt7BwwzBrOBSwPEYyZrMCizZ4gT6//K9OWhnhdOUtUdcYmVhDq8fE7hZz2fn 9YRSur+Pap7L0YiDOK92UXM3GOymfjoIRIiJLJ9tuDLF4db/rktUnz/2xkZB4b0HRCOQ XTGnsXA+oZ84eUzsMYhsR5UtdL1ojVTL8g0CJCzYd0Fy6cldEAPlNsDVeNyf4iBgnEXz ytvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=tpkudzGZSYe++0WxmWxkh/TyCbkTxlEu9kTAPZhgUFQ=; b=Wb0liOsWTEPoxt4nIsniAWCbCNuhxPouNbIsvvBiJ80revZjjoRxEI5kSgYsEcTpVB tqSyHGNkB4L/+Ks1fM+KX0T1TazH4YGIgdC+n9Gfc+WNUO3k3TOw/Pye2rhGCtqmB1Vq cgKRb/BtOoNwacUKNM3B6CxnMwsSRVJudrsYs3Fhz1UsrlACt2pMQ9zLiVTS1HLpSnkk rdCYhxikHSdwZJofjGPi0j3Pt/YgcdmZFe469x+UlHeeJGf+6KvUIRfRgvef5ieo9Kvh JrAgJCvg4G9k3ZIlSt0rQWBWuX4ZVlg96lhdQYwUIkNGpEvU4yO0B3yregG3eCph3dwu Vamg== 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 q21si302358otn.7.2019.12.09.10.28.18; Mon, 09 Dec 2019 10:28:30 -0800 (PST) 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 S1726646AbfLIS0b (ORCPT + 99 others); Mon, 9 Dec 2019 13:26:31 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:37364 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726408AbfLIS0b (ORCPT ); Mon, 9 Dec 2019 13:26:31 -0500 Received: (qmail 4869 invoked by uid 2102); 9 Dec 2019 13:26:30 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 9 Dec 2019 13:26:30 -0500 Date: Mon, 9 Dec 2019 13:26:30 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Jiri Kosina , Andrey Konovalov cc: syzbot , Benjamin Tissoires , , LKML , USB list , syzkaller-bugs Subject: Re: INFO: rcu detected stall in hub_event In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 25 Nov 2019, Alan Stern wrote: > Jiri: > > On Sat, 23 Nov 2019, Andrey Konovalov wrote: > > > I'm not sure, but the stack trace reminds me of this issue, so this > > report might be related: > > > > https://groups.google.com/d/msg/syzkaller-bugs/X0zVbh8aFEM/NsPcshjxBgAJ > > No, the issue is quite different, although it is also a bug in the HID > parser. The big problem is that the parser assumes all usages will > belong to a collection. > > There's also a second, smaller bug: hid_apply_multipler() assumes every > Resolution Multiplier control is associated with a Logical Collection > (i.e., there's no way the routine can ever set multiplier_collection to > NULL) even though there's a big quotation from the HID Usage Table > manual at the start of the function saying that they don't have to be. > This bug can be fixed easily, though. > > The first bug is more troublesome. hid_add_usage() explicitly sets the > parser->local.collection_index[] entry to 0 if the current collection > stack is empty. But there's no way to distinguish this 0 from a > genuine index value that happens to point to the first collection! > > So what should happen when a usage appears outside of all collections? > Is it a bug in the report descriptor (the current code suggests that it > is not)? > > Or should we use a different sentinel value for the collection_index[] > entry, one that cannot be confused with a genuine value, such as > UINT_MAX? On Tue, 26 Nov 2019, Jiri Kosina wrote: > Alan, did you get a test result from syzbot on this patch? My mailbox > doesn't seem to have it. On Tue, 26 Nov 2019, syzbot wrote: > Hello, > > syzbot has tested the proposed patch and the reproducer did not trigger > crash: > > Reported-and-tested-by: > syzbot+ec5f884c4a135aa0dbb9@syzkaller.appspotmail.com Jiri: Now we've got the answer. The current question is: What should I do with the patch? It seems rather ad-hoc, not a proper solution to the problem. To refresh your memory, here is the patch that syzbot tested: drivers/hid/hid-core.c | 5 +++++ 1 file changed, 5 insertions(+) Index: usb-devel/drivers/hid/hid-core.c =================================================================== --- usb-devel.orig/drivers/hid/hid-core.c +++ usb-devel/drivers/hid/hid-core.c @@ -1057,6 +1057,8 @@ static void hid_apply_multiplier(struct while (multiplier_collection->parent_idx != -1 && multiplier_collection->type != HID_COLLECTION_LOGICAL) multiplier_collection = &hid->collection[multiplier_collection->parent_idx]; + if (multiplier_collection->type != HID_COLLECTION_LOGICAL) + multiplier_collection = NULL; effective_multiplier = hid_calculate_multiplier(hid, multiplier); @@ -1191,6 +1193,9 @@ int hid_open_report(struct hid_device *d } device->collection_size = HID_DEFAULT_NUM_COLLECTIONS; + /* Needed for usages before the first collection */ + device->collection[0].parent_idx = -1; + ret = -EINVAL; while ((start = fetch_item(start, end, &item)) != NULL) { Alan Stern