Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp135498lqb; Tue, 4 Jun 2024 07:15:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUEYINjzZXFg9UuDqnny8qNV9RsYPvL1TiO62oyU4Sgyo1NCfH82kGHFtn+1huwqao0nodK6L46F/+oSYV6ZK5H6QExdTximVDe9qJC9w== X-Google-Smtp-Source: AGHT+IHBPJ2GO0GIx9xX7RYijxijRFeKqdJyPRZd2fs+WfczMv54RtA2ubZrT/WKaHnjenvOYIr+ X-Received: by 2002:a17:902:ce82:b0:1f4:a1b3:1b9d with SMTP id d9443c01a7336-1f637080f94mr118097005ad.33.1717510533862; Tue, 04 Jun 2024 07:15:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717510533; cv=pass; d=google.com; s=arc-20160816; b=D7Egauhaw06rlFDxX+ed/W+vAyJ3BGVhtTymUQ/xOlk5o/c9Uqv6yLoFCKQKO+fRfv 6eGMHxlPlh5WXNgSLRvc7O1Wv8Axh38flwoxBDud+nbIn+SxJUU7A0Z3LuAQJqBUK7dn Uv94mETRKIgn7n3WZ18SriMZ1UI8TOaFdNLFULNsxsLHuVDJ6VgnGqdugqTej3Pcn6GW 4HNglnPafZIEosRBezdbjF8PHHepxATeKYM2t3DDhY4qduWO95DMTxbkyLtc1MUjqmLx rIGSuQ1lneDpAfbvLRPcjXKR5Thcy5psNBDDj8TeHhmiE6J+5uWAEtwTRlijqgVYdi9D gKFA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:references:message-id:in-reply-to:subject:cc:to:from :date:dkim-signature; bh=RroqOEgmoyZToF2SB/KJAbh05i4rjAqJIhr57KZAEmY=; fh=gRv5TqCeaTtUo/pB71azqPcLB9t8zKnCcRMr45dSb7k=; b=ZavKRs/rWO5R2mMPTnAFWWx+i8RvYrBfyhRE8hMgPWOXR0rSX8K1FbwHNFPAT8+sDy /1axVCu1qWeDMI2Qk1iwU9e71SheODdSio8edpoQcNW9zWApOQYdqapSxeHGsJh/qhGo rqFMQTVRoHXwhHouK/vu2J2Ibi80NKtoYDw9KmCweaWnA+5X7eFEHlp84vHacgn+yKix mTOtMeTf8i74MawOKXCxQnLDKoiQopDynPVijYUvBfwWYhKRAFbudVdfDgt+P0SEdd4G HpchIs7bpzQA75UEbLNs9HLSNoPpAq5fX0pnPphqD93jK0iJlsMkRQHXBsBplYn32dHn RPhw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hQTUbCPV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-200793-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200793-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 d9443c01a7336-1f67f165297si12352705ad.295.2024.06.04.07.15.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 07:15:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200793-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=@kernel.org header.s=k20201202 header.b=hQTUbCPV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-200793-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200793-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 791B028333B for ; Tue, 4 Jun 2024 14:15:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C83912CDBC; Tue, 4 Jun 2024 14:15:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hQTUbCPV" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B72DC182C5; Tue, 4 Jun 2024 14:15:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717510522; cv=none; b=itO9r+XWDLZRbNh1Ss0v/cYlDVfI6JOlZLHNXJ53J86bheXM3Fg/OZt2f/INM2t4izvqe3SrXPNRclTLhXekSY4OaQLeLkJtuBQN5ddHXS6/HfPPPij5K8MIQKsxFNxXUd4k5krVn6RcbL0zhVTJENe9HkBkzMFUacYPBntoP74= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717510522; c=relaxed/simple; bh=dCYwA2T+wZ6B5AlnOfH1EZwq/LhU73DxcZwcbP3J1KE=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=mM13mTLBXSm96Nst+Gm9rxGsOsx3zqDQFem0QoF/V00kQvr2swPPXB2n1ToHsYUACNyb6kCQeEya4e000TjytXHBXhWIxkX/rba7tpzHdXyVZrgPatEE5ozI20UK0oL/Gt30AtbIJovGaVsVsJscYciXz1Zo60DqENBvnhf9/G0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hQTUbCPV; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 002F2C2BBFC; Tue, 4 Jun 2024 14:15:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717510522; bh=dCYwA2T+wZ6B5AlnOfH1EZwq/LhU73DxcZwcbP3J1KE=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=hQTUbCPVJi1r+pUQWfOjRlDqPUhoGDRQjxa+eKN7HETb6j5lHyQLuQg0n4y4ohkI6 ZXTmSRrZ7fwSaVoyympC+8a7ifj+PDFnJF6UY/oW6GT/kYKHrRK/eOME5MrsvqzTFk BUh0/XDSGSPQhhorYMHqCsI6HQ2wuS87eptzS1bdw+nZ9RZN3hocTuVMbluB1iUqJP Xy6rhCLaVhHsbrMmbNVlyjAI9FYHUWQyC0Gh2fFEPYsLvCIPA5UIkpKqwAEASNVXep U142C/fpa2VN3hjdZ/szAaBBA9mglxngccRNPu07+/5PJmwnpW8iM4F/RIE4UQgOJF gpmLOgBf7pK6Q== Date: Tue, 4 Jun 2024 16:15:18 +0200 (CEST) From: Jiri Kosina To: Kees Cook cc: Nikita Zhandarovich , Benjamin Tissoires , Kees Cook , linux-usb@vger.kernel.org, linux-input@vger.kernel.org, syzkaller-bugs@googlegroups.com, linux-kernel@vger.kernel.org, syzbot+c52569baf0c843f35495@syzkaller.appspotmail.com, linux-hardening@vger.kernel.org Subject: Re: [PATCH] HID: usbhid: fix recurrent out-of-bounds bug in usbhid_parse() In-Reply-To: Message-ID: References: <20240524120112.28076-1-n.zhandarovich@fintech.ru> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) 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 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? -- Jiri Kosina SUSE Labs