Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp6379776rwb; Wed, 18 Jan 2023 04:35:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXu5Sfvx+lu1AroMuaK6FVVHsPqmQVXTNB7nfcwu2FfIKdTRjXJNzafxj1Sg4BfHrPI9kN6Z X-Received: by 2002:a05:6a21:3a89:b0:a9:fddb:9eab with SMTP id zv9-20020a056a213a8900b000a9fddb9eabmr5826433pzb.41.1674045345519; Wed, 18 Jan 2023 04:35:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674045345; cv=none; d=google.com; s=arc-20160816; b=e6Cg/eYTS9VFifF6g+TqFaozjYYeknVWTMSwIvW4VSOQXUjOIebPzHngCOVPHQHfTR ltx9F08YGu+Wxmkc7JaRF79WCxiaYbojnjYcM/EvIWgrHlSSU/Wmo8J8tcCsTYixCBQe C0Gz2T1QhYAbOCQ9f+KWyrNVIF21iQyWcwxhGOVfzgC8K7sJucoL7MVbjDIrzi0mVUAy CoHAG0jyhI+l2dtJ2VHBnBPmIV/3ir6/ig7wJ6oP8SGu6faJ6jXeWZ6DINRYC5fP/FAx 3V8SryWV9aDJ9uxcjHDnWeW+L/2b4KqHdX4John2usMBnp68ZRMgtSY7qZ6fOoHNQwXi E5zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=UpkAJCZHKppzGWfR8t9aF7KWnvWaXlXDyisRFpMO7Iw=; b=USIHR+ryNL9kx5SviP0X5awg97uFlyGvk06xR/ckftUzqgv/5FYzSvXz7szm3aXSVW x0XI/05awg4tTD6ZWW7ZQpOvNjK/ehG0eit9fVrryYZWHRi4WDrax+e0Qbde7Bswvhpm 3lpv6JsX2uTQBc9FoXG9cWSw78PVw41srNPh/z7CKFHNQB6a7Jj8DCM2s/sIg2CSXdko OST6Yhe8+T1uOINpFAGHQpWMMSfi47Ct7lnZqNrvuSQdgOqiSNhVtlxz5AAM4a6APgoC qoQYBCdlX4a1sIe0VxjztwYAAtRzPz/zEsqrswbrVuoK4YWbreH7RmoACeot1ArnSBrd 8kPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V9GY2h1P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s12-20020a17090302cc00b0018965944b98si36387175plk.24.2023.01.18.04.35.40; Wed, 18 Jan 2023 04:35:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V9GY2h1P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229765AbjARLys (ORCPT + 45 others); Wed, 18 Jan 2023 06:54:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230338AbjARLwg (ORCPT ); Wed, 18 Jan 2023 06:52:36 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EB096E831; Wed, 18 Jan 2023 03:09:51 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CBF97B81C16; Wed, 18 Jan 2023 11:09:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC90FC433EF; Wed, 18 Jan 2023 11:09:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674040188; bh=NZW9HiYlTqxS3hzsVzUHhCSns2PIpY7e66VoK9HVTLg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=V9GY2h1POWPM4omeBU1RQWCB2P8xzsiyNNn4SDIbh96+c0FJw9PzlpDWU9R9o0Mnl eg7DDc2wABs+Fbiw8FseF24qqKr9sDgLqNUthJjtq25MdasDkU3GxCO2OfPH7FKO1J XDQ1cuwB5qKVCTjOzK+gxK7l4Miif+6KTQhLAp2OQJRMkp1l+FjzEnmTHP6byD/aj2 bCLGvCdbTthkBWATMpGnPkx/afltV13dA3iO5O0XL4hE286F4OuhqRVWrBDDFDLChB fY0Lsh/GE+dBeVLoTI0vQ/JEhwQkXOC43ySr1ZnBc5lwvtyMoztYJ5qimuYcqRkDoN ACi0p1kS9b2HQ== Date: Wed, 18 Jan 2023 11:09:43 +0000 From: Lee Jones To: Jiri Kosina Cc: benjamin.tissoires@redhat.com, avid.rheinsberg@gmail.com, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: Re: [PATCH 1/2] HID: core: Provide new max_buffer_size attribute to over-ride the default Message-ID: References: <20230113150557.1308176-1-lee@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 18 Jan 2023, Jiri Kosina wrote: > On Fri, 13 Jan 2023, Lee Jones wrote: > > > Presently, when a report is processed, its size is compared solely > > against the value specified by user-space. > > While I am generally fine with the idea, I don't understand this sentence. > What exactly do you mean by 'specified by user-space'? It's defined as a > compile-time constant. > > > If the received report ends up being smaller than this, the > > remainder of the buffer is zeroed. Apologies for any ambiguity. "its size" == "compile-time constant" Would "its maximum size" read better? These sentences are an attempt to describe this statement: if (csize < rsize) { dbg_hid("report %d is too short, (%d < %d)\n", report->id, csize, rsize); memset(cdata + csize, 0, rsize - csize); } Where csize is "the [size of the] received report" and rsize is the "value [size] specified by user-space". Thus, if user-space says the report will be 8-Bytes (rsize) and it actually only only submits 6-Bytes (csize), then the subsystem will complain that the "report is too short" and it will attempt to zero the seemingly unused 2-Bytes. -- Lee Jones [李琼斯]