Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp1569888rdb; Sat, 23 Dec 2023 12:00:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGrxfJWbxBMXbKRLUc2yCbHl2kgjkcDMd7kTJNZPeK0uE3miWf8ZOlj2uSYnfr7dkyFN9Wc X-Received: by 2002:ac8:7d01:0:b0:427:8e84:f355 with SMTP id g1-20020ac87d01000000b004278e84f355mr7177523qtb.53.1703361602696; Sat, 23 Dec 2023 12:00:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703361602; cv=none; d=google.com; s=arc-20160816; b=aCwFRVUTsvqaYWdtlYGHbZIG+cLhOoVkhetF9hnQ/0JppQx3TymHD48BTMX7Vr37U2 g1MunQl7ys3zuPLsR9H7L0ifEHTA70P24add5IYFLFeQ7AEuSxo6D5fNvyG7gvXnCD/5 NiZgirOTTv2YYJ/fkzc2dFLcFmQXZySNjsmEyh266AayLqRxl8vgDr528JaffMV8okSB JnT61Y/TqUpcb5RSLf6bUAWkMSUyXR+1OIbvxY1BK5UCdkQQMgYJpYxNfpHhdTXY2mM5 xfnzn415XrQiaIOO4bTCiZDiVzf+RvwIrW6Lk3KIn6emYg8gNPWNxoegcwXA5jRDnOIZ 4SkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:message-id:in-reply-to:date:mime-version :list-unsubscribe:list-subscribe:list-id:precedence; bh=1kfJmhJKcf/fccgwHKZPrreJdcdZjh/nguV+pdm7xVY=; fh=uOxEfs73UXnpmsgYZepGR6OauibfyleDeycBITvBwXs=; b=oOMZm875axr9Mr6WZC7aVuyJekldlBRGX7Rddzk7hpL60VtTm3IMxU4ZJndeTZsWAC iM+9XAC7l144GWP64q6X5MLEZfLprpxCrNWKfePYDM6qA2RgE64YC6kMbmdQqD3MobKJ o7u4my0uX55etVubkZofiMzydORfvLYstOB0XkL2OY5KaAJ+7ifbV7QDineJ961wS/wc eQ38/kcWSSDGySvtu7DlJwjg3pTHFK5J8rjKsW+hM4Kn/1keC8jmp1F9nMr7mkneb7hq uhJXrTDwNxYaKavGpp4DhCzg/Tiz3qe8X1W0z/g6cOqzR637alA6l/+luIGx2t7FJeEe TQBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-10575-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10575-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=appspotmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w14-20020a05622a190e00b00423d65e0344si7159339qtc.359.2023.12.23.12.00.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 12:00:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10575-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-10575-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10575-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=appspotmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 556BB1C216D6 for ; Sat, 23 Dec 2023 20:00:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66B2915EB2; Sat, 23 Dec 2023 19:59:54 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E53415E99 for ; Sat, 23 Dec 2023 19:59:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-io1-f69.google.com with SMTP id ca18e2360f4ac-7bac08a97c1so27704339f.0 for ; Sat, 23 Dec 2023 11:59:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703361591; x=1703966391; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1kfJmhJKcf/fccgwHKZPrreJdcdZjh/nguV+pdm7xVY=; b=t36/n60dPvNrg1XPVmeyVXdlT0xGsEEv2DPrU4GGAt24qA/Kb+HDPxNH8w7ERRAFBl 4urpmoPxjlvxMNMNPkzfscG4iw35M76k7fYcL6H0XURtdre0RAu5V1QRydD03WXk3C/i pV8LAyqyUXpfvH7yhHLutf43WKlK0nsAxztEGy8uW3zDGVN90OXaM4gh8Gm9DTLzF5Z4 gvemnlD+mwaUXmudq7KIqkvylh5ZHyr70I/kYsIfIzDwp+56ry1LQXhEiZpdQDjKgdGJ pgWx9cQs/kgAUu2G6OXmuNbe3xpQSaA0LQI49MypwCMD82TxqtFxBn0dhShGRPbHhCRx VJwg== X-Gm-Message-State: AOJu0YzXn1631ER85ZL18e3j9dMEvsOm+VMnIZ8X+1wsXtrE7HuWuo1d Ev8XvPL73DPVwcJ10t9+L1zaAplwfCJl/JMLfavMlouVCFZKUW8= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6e02:20e1:b0:35f:989c:a85b with SMTP id q1-20020a056e0220e100b0035f989ca85bmr310343ilv.6.1703361591827; Sat, 23 Dec 2023 11:59:51 -0800 (PST) Date: Sat, 23 Dec 2023 11:59:51 -0800 In-Reply-To: <000000000000d330500607d85a5f@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <0000000000009ae37b060d32c643@google.com> Subject: Re: [syzbot] [PATCH] usbhid: fix array-index-out-of-bounds in usbhid_parse UBSAN warning From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] usbhid: fix array-index-out-of-bounds in usbhid_parse UBSAN warning Author: tintinm2017@gmail.com #syz test: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master Look at the bug https://syzkaller.appspot.com/bug?extid=c52569baf0c843f35495 reported by syzbot. Tested a patch through syzbot, which gives an error. Requesting help from the maintainers to understand what is really going wrong in the code. Based on my understanding, I believe the value of the number of descriptors is calculated incorrectly before the for loop. Signed-off-by: Attreyee Mukherjee --- drivers/hid/usbhid/hid-core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index a90ed2ceae84..582ddbef448f 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c @@ -1021,6 +1021,8 @@ static int usbhid_parse(struct hid_device *hid) (hdesc->bLength - offset) / sizeof(struct hid_class_descriptor)); for (n = 0; n < num_descriptors; n++) + if (n >= ARRAY_SIZE(hdesc->desc)) + break; if (hdesc->desc[n].bDescriptorType == HID_DT_REPORT) rsize = le16_to_cpu(hdesc->desc[n].wDescriptorLength); -- 2.34.1