Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp250003lqb; Tue, 4 Jun 2024 10:10:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVPF2xn2D7XQMD4rOYoSXkHhAE74i2bT7uCZK7UUSW8MLJ5Zl87ljkvwfK0uTxFD/zWZiJ3N7aYF/YWBR6bSvnKk9qVJpWLKNtXBC6Krg== X-Google-Smtp-Source: AGHT+IGdlAPt/Jk47knteSmLMTB72sJPbvSyGLI+0JkbdbxOUX2R+T23JGiRnetVDVwu+H8s1UDW X-Received: by 2002:a05:6808:3a8:b0:3c9:7022:7545 with SMTP id 5614622812f47-3d20425b2dcmr6218b6e.8.1717521011940; Tue, 04 Jun 2024 10:10:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717521011; cv=pass; d=google.com; s=arc-20160816; b=Id9s1K2pQA/y5tJtY4N0cGatHs4DyLhM6k8TKrA7h3lbcGLmWFnmoosxoK2oZh1av3 rbnpaetoiKbCA3h5RqaXxXc6egMLd964PoZNOWu4weUav6cTyqDjPpkHPS5aajZsZnD/ W032heXe8xESZLvh/wbPV/qtykV138SMxK+r/7XbNC5S/uamgF8pBqdtCWCuUmY2A14e QUjP1yjrpkiUYJTCyfB9885Ac2ou6lLvT1aBHTFgFKC7tPgqFsRNdJnVCVXiCreApG1c R5ZYfrCs9cJsU58fTjuwUTHF7dvDanRwH9PvFJfpS1HkdCPe1iuc3xm/9vVxP+V1xrUr hD6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=r1SHmxr9K/JFlnh5CEjLi/O7rP7nR+bzBxzaUrsJ1+0=; fh=a0PytwdBuBsiCgycec5SuOmQnvX1bYfnAFy4WC/hpcs=; b=tXqYuIMI50hBeMgO9o4S/YBYM5kP+i5+dKh4/dKIybREcn+J477ym2tqgKfk+0hOMG jgX07EUkSiHNM7UG7Oo1CKiVD2n9vtVziz8KvAsfo3RRzZRpbTlvFYNGVv5oYFGW8H4c P6w8iFb4gSo+1RrXvxiY5yLDnsetiPLAcJG88I4V1iSkcz+5tsw0lFTCQB28sLkdgded GUVACGaEzUa02gIMqnJydxJzJfVvMCrLEg2Wkk2S20yfcaE8sRXhLRoi63xSxlI7jXp5 ksPcgglN1deGfnwBqGmippMYQjxnYrb7lRAv2Ddyps41eTD9XjfYkWzsCuMkLYu/It5q g9JQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=fintech.ru); spf=pass (google.com: domain of linux-kernel+bounces-201138-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201138-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a1e0cc1a2514c-80aded1f875si1671481241.37.2024.06.04.10.10.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 10:10:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201138-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; arc=pass (i=1 spf=pass spfdomain=fintech.ru); spf=pass (google.com: domain of linux-kernel+bounces-201138-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201138-linux.lists.archive=gmail.com@vger.kernel.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id AB6771C22037 for ; Tue, 4 Jun 2024 17:10:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EA777149DEE; Tue, 4 Jun 2024 17:10:01 +0000 (UTC) Received: from exchange.fintech.ru (exchange.fintech.ru [195.54.195.159]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DFD1149018; Tue, 4 Jun 2024 17:09:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.54.195.159 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717521001; cv=none; b=tXSmmVvGqrsG3aysISimoahyMscj7DVLOAVOZz0MfEzM5bNBe5GONiFYB+dagJL03OT5TwCBkSvJ6bReVop17B/R8+VBCCXlHXMpjKXji9Hh1tC+TVgFxrqx3xQlg6+3RHxxkXfRjnc16S/6/E2Sn0XlyYowbxArLM7U2BQlpLA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717521001; c=relaxed/simple; bh=Igv2VV4mugXViOwO29eD/sNySNWKwLk2QAVjhhx/zuI=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=Ri2A89e7/aODHxrLbTozshDjYYM7QpR/Svcd5+8izG5+7nPtFLDNp8FF3DpP+wnFW/klgN0cOZICfGA56MADIZuR/gjq9CHoEseYM31kTg5pG6tTrNtFCQRRy5iMJRHM8OYc2shhXZWuLWjdu34jtKxY418hKhkRbaLvPcEpXhU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fintech.ru; spf=pass smtp.mailfrom=fintech.ru; arc=none smtp.client-ip=195.54.195.159 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fintech.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fintech.ru Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.169) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 4 Jun 2024 20:09:47 +0300 Received: from [192.168.211.130] (10.0.253.138) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Tue, 4 Jun 2024 20:09:47 +0300 Message-ID: <2a38e355-af5c-4b3d-81be-0cc97376c1f5@fintech.ru> Date: Tue, 4 Jun 2024 10:09:43 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] HID: usbhid: fix recurrent out-of-bounds bug in usbhid_parse() To: Jiri Kosina , Kees Cook CC: Benjamin Tissoires , Kees Cook , , , , , , References: <20240524120112.28076-1-n.zhandarovich@fintech.ru> Content-Language: en-US From: Nikita Zhandarovich In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: Ex16-02.fintech.ru (10.0.10.19) To Ex16-01.fintech.ru (10.0.10.18) Hi, On 6/4/24 07:15, Jiri Kosina wrote: > On Tue, 4 Jun 2024, Kees Cook wrote: > >> This isn't the right solution. The problem is that hid_class_descriptor >> is a flexible array but was sized as a single element fake flexible >> array: >> >> struct hid_descriptor { >> __u8 bLength; >> __u8 bDescriptorType; >> __le16 bcdHID; >> __u8 bCountryCode; >> __u8 bNumDescriptors; >> >> struct hid_class_descriptor desc[1]; >> } __attribute__ ((packed)); >> >> This likely needs to be: >> >> struct hid_class_descriptor desc[] __counted_by(bNumDescriptors); >> >> And then check for any sizeof() uses of the struct that might have changed. > > Ah, you are of course right, not sure what I was thinking. Thanks a lot > for catching my brainfart. > > I am dropping the patch for now; Nikita, will you please send a refreshed > one? > Thanks for catching my mistake. I'll gladly send a revised version, hoping to do it very soon. Regards, Nikita