Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp611074lqs; Tue, 5 Mar 2024 10:55:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWklqOw/tS9vNIUqN+1xz6UUuX5YP5k4dGUhKBfwR2pANndSpgs9WSygjpgzRjPBgcIGusZfEsasPNXjCYegm1CawJtOuAaHgsKYo9oWg== X-Google-Smtp-Source: AGHT+IEMnd5YL3GXZc06NKL9+PL0LOyjfk4+FWvrZde9DBxJeRMOMztoUraZhL473FzA+9AiGQL7 X-Received: by 2002:a17:902:bc46:b0:1dc:771f:ae56 with SMTP id t6-20020a170902bc4600b001dc771fae56mr2773361plz.29.1709664950948; Tue, 05 Mar 2024 10:55:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709664950; cv=pass; d=google.com; s=arc-20160816; b=02SzmI9RvkaYTfzMZZfUyhEQsea6WS3IUqq6+YA/w3LNNV1zcAOOse0rrv+aRjK54T 1Yo7I/hBwp8EzhvC1q9GMmcs5YzYNjQtrzqK1mlMiFCCZgsmR9tZLiEZyezDLnALk46c ZmWlPYyi954QBIcZXNTnt3ueRldieKVB9Apfc1/W0QEVAnVVa0L93blY/ojkj3SVEH5A m+OkpI2cIq1z8vtTwJ+1Ty6INVysYWc/enmYCr241Cg/1xyek1uUW/pIBCi5ynALXnNd wgCUsS1UJHF3p4r7WCqNCBmeJ2k6AUvY0ggJAig6cMVlfrrP8QgCBhbQus7OM66qkwQu WSjQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=N6tcpCezM4szO4PrRorLtqFpYFaRv1y6CJa/aon/dew=; fh=t42r4E02uFO/hikGGeqp03YdV6EObHus9OgpLByLJzI=; b=PyVTmuE+sYtgFJNNFfRkoUesRCn0LKbGd2t4urxD7fveyzTVcc7kSiumgP7IYZ2svI bfNNkFGDtgRRKwNpbxtNuuBJ/DNy7JYkcA6qWV12PbRaRMHGFnFRMJFzSl2DoY6tt/iV a4WAwpxpmS8Ir5Kkdoc/3+oqWrzwcyf3F6qDZWBc0MRX6Hyci9SmTtm3auY7+5R1AAUC o1A9UHV4nNSIxQFxITrBwiGMF68u28JltTyJVf0BhwXePoPL5wsnnlZzezKDgSuS6B6K AH36+2V9MAuXXM5ZZX3I5YmsXWvuZurdEWn2BJzpKwOMm56uJXnnW+5aIwJBs9muCMUP FALw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="HawU4/9M"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-92860-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92860-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b17-20020a170902d89100b001dc38eaa5d6si10063549plz.531.2024.03.05.10.55.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 10:55:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-92860-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="HawU4/9M"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-92860-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92860-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D5DF428BD16 for ; Tue, 5 Mar 2024 18:55:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3DF7D1C29B; Tue, 5 Mar 2024 18:55:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="HawU4/9M" Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 E6456199BC for ; Tue, 5 Mar 2024 18:55:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709664931; cv=none; b=RHVATZ0nQ7ct7X0O0jS62jVdkbtQfulnpN/ec9NpnVa2SE5GY4CXw0pobzmDUkWrcTB+6B6tOZdwA0lls2q5RReXVKzC5ZXGhwLX6E5/oAwkh9gF75wJwpeKugGyUkaZ68FiLYE9lcztFFX9Djf6uKxe/tvCHCdYoCDJtxfBgBs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709664931; c=relaxed/simple; bh=iF7k1/BvifiPN9TSkNXOCDncvhbUHkmOoNs4nie4SL0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rid6UsyqHOl0Wt4aDL5j7Y+xhwQkj3i4KPNdcKaRYTMWzNUTRzDZy4JW+achlOEaMqozADC3JZiANPJeCrpWj5cVHRnh8a8E0i6yy+sSNoXVpzvqnFEmvZ2C3+sa4QjbmR0SAgeQU53fIjVyJjamz3voCBLgJco4psgrnWS1vLU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=HawU4/9M; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6e622b46f45so2092790b3a.1 for ; Tue, 05 Mar 2024 10:55:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709664929; x=1710269729; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=N6tcpCezM4szO4PrRorLtqFpYFaRv1y6CJa/aon/dew=; b=HawU4/9M4MnWxQtgipzpt9PqgTG7VjpdQIvAtOzw++aBwYS/ZQuqTtHCND9n0Q8yKZ /WHZ+7vWR7Ycjjoajv4J+3Z8yUzgEzABfRnS4O7jusnCgRtD8YXjdlEixeaqV4xlqlIE n9KibNMgbfLlSjKkMdiojnAqZl5d4jjysuy6Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709664929; x=1710269729; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=N6tcpCezM4szO4PrRorLtqFpYFaRv1y6CJa/aon/dew=; b=gstfQ2CDv/QoQJQnoQcwb72VJR8hv7rwUdwb471WOCx6wQ6e55xPBZocbbWPD12mCO JOKtqTW+njISbEfwSjfQD2AvMKkhBRsFmWrJxE72ExrwlDLALjUxIrM32Qn4/VVwKWuF 7ModGOS3M2Rmj1KdRfHoINy6E7Nv2xAuSjgBiMDem6KEKr809GbvLAyFc1hw6d50ISuL BAjwkscVzbZvklNU9PIGJ+K6p7OXXMZXzraXHH1HOn8ZwautOixEO6VEWPIY2lgLfNSc Ww1RVjdxn/q87ZxLEr92fUvyWRm/kzYA4AfzF/b75Z2WXkzXp1P7mAPxTzjENSiqXwe9 MNqw== X-Gm-Message-State: AOJu0YwD/N5m1eiyK+jUAii1WuLB1en4uSxLjuWka9EE5iRFfz/KVTd4 gU8Kp4luOgFvXgof8Z+E2lqWTjFW5Up4xIUhp6/1skdoWDkKeqv4Mefcjmurkg== X-Received: by 2002:a05:6a00:3908:b0:6e4:dfec:1b0e with SMTP id fh8-20020a056a00390800b006e4dfec1b0emr13080584pfb.19.1709664929226; Tue, 05 Mar 2024 10:55:29 -0800 (PST) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id f6-20020a056a00238600b006e58553e613sm9295684pfc.74.2024.03.05.10.55.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 10:55:28 -0800 (PST) Date: Tue, 5 Mar 2024 10:55:28 -0800 From: Kees Cook To: Jiri Kosina , Benjamin Tissoires , Attreyee Mukherjee Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, syzbot , linux-usb@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [syzbot] [PATCH] usbhid: fix array-index-out-of-bounds in usbhid_parse UBSAN warning Message-ID: <202403051052.DA58CAC19@keescook> References: <000000000000d330500607d85a5f@google.com> <0000000000009ae37b060d32c643@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0000000000009ae37b060d32c643@google.com> Hi, What's happened to getting a new version of this patch? This flaw is still reachable in -next from what I can see? Thanks, -Kees On Sat, Dec 23, 2023 at 11:59:51AM -0800, syzbot wrote: > 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 > -- Kees Cook