Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1627078rwb; Thu, 8 Dec 2022 13:08:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf6wRgGD9f6UL5b+e0CfyL8pzrWdjYzmqKsWpj5PvMkq0tw61toz36Xfe9A4m5uCBMHa/7KC X-Received: by 2002:a17:906:a843:b0:79e:1059:6d65 with SMTP id dx3-20020a170906a84300b0079e10596d65mr62370039ejb.695.1670533720139; Thu, 08 Dec 2022 13:08:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670533720; cv=none; d=google.com; s=arc-20160816; b=CIF+7QPwygBIY/1t026MKex2WFxwK0SwaZ42Pm7wQem/NHxnor27eeCI6M9k8gBfFb bQKbetWsUrLN0DKtZOfoKzWMbj6jDsKvQU9+HhCjhWNeqq1HMsN9OGqn2bZv5J8DMS+U 4drC03qV2kWr+YzklNpzCeHRaqRj4dMiBZMK6X27lv41nq5GFAxShsJghdZQT0b4FIqj IQ6k5n2+0BwZIlpV0bn98lmhFDDYD5VwdaHGz88mTWDJ1MDCxChWsYfYTMsHA+Un0lZ+ iBM1j8gDacR7X0rIn51Kfq8XQ1NrPoHbGugtpUsBSaexJHHN69uBWvsqLFnBFKOU+fJJ jgsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2uWthW/PoKfC02t1PaCjD6R5HbN1AuXQTJXkZCHE+YY=; b=iG28vN24Sps7K6UHRYO2Q8RA4RiXr+ALtXzSb7pZlY7akyfYA9VlVsB2PSxb9Lq+99 hHbJ0TEV1y/uMIC2qx1SC/oTv7s0YY6TQ3SxIoCJWFhJCT/0vqZ4eA5mGcBZelMg/41b DT9GoV84Tc++wM3lhe9gKU4LBVuWfPjw3goFW1sCDXzNwbATkUX92DiJn0SkKXQ6QnAu Yrje/MWlX19BirIqmrBrE/L6rg8DC4su3z0KPiclVhJVFb126FdRv5jnjVSSKXw8y1yG R4CaN6+ow6fXepj2lz7BKZvhbDWIvK7edz1p+PmNT2eBNihaIR2BW82NalrcOYTmUBMf A5fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MmnxtYap; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg33-20020a170907972100b007a8beb3aa4csi20091294ejc.872.2022.12.08.13.08.22; Thu, 08 Dec 2022 13:08:40 -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=@gmail.com header.s=20210112 header.b=MmnxtYap; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229631AbiLHU7M (ORCPT + 74 others); Thu, 8 Dec 2022 15:59:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229649AbiLHU7H (ORCPT ); Thu, 8 Dec 2022 15:59:07 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9887726FC; Thu, 8 Dec 2022 12:59:06 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id n21so6870515ejb.9; Thu, 08 Dec 2022 12:59:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=2uWthW/PoKfC02t1PaCjD6R5HbN1AuXQTJXkZCHE+YY=; b=MmnxtYapb1tWKOt5UnNiQ50t6JfjSaObmvZa9LHlnCnsyJLPhgzfbg0O+ARqNk1b2T Iibz2OIB+1N9V+0Ptw1fa+ywzBwARGYBCNCLZOyGv3BEba2lXVw+SgGgL8Qz3twBv+uO 5inxZ7C3lgG64UliXO9ETDOP1UzM4HzoCGeMR3Bb7XbrIJYLuaymbfIFcdl3+uuWddAD dnBDfQ6CcbGyc2Wo9j5Aib2LW5kIDOCsDGbadJga9MRYFgJfUWX0LFNeg+J6LqlmsSg0 oKmSSBKI5aBbm/tHxZlPGCVNcJeGVUEuq+cpoRdczZnCXGHlKoT/mIw5Q+emTMhHjgCD SUBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2uWthW/PoKfC02t1PaCjD6R5HbN1AuXQTJXkZCHE+YY=; b=Ua+B6R4KP9TrudNGzHTdYUqUy2j3UhHuJyXRfdKfBNnJKhc8gxhKWcecx4u6+Zg+rK 7KP5vjL7jXwYrmOKpl89F5959zbjfV0deMoCSW//44YCB/G2RtUGLF1svurrH/+tAVH1 YYF+KOar4t7ZsOLMJeitJyHpec+vVYCGrSClqq7dJWmMVTo+C7jP+mUOJZStJRCJzGCX 8AJlxsGNq5vr8hbJMrtFZKIn6LBZhQTtdQglqjhT0Sl9CCCYC9ZMDuzHE8meGDvZgFmh Hobmq7DIOufrenDCNDn1KrvyAOCWzodM6LHsVRQrXZjJzy7B+cGwYQYYmzO8mB8CI9hj Q3Zg== X-Gm-Message-State: ANoB5plRa5vthy94yoMV0slCGXCI6gUWveuAJSWepgK5VNwFoShEKKk8 V909OoF3xI68CTCD/LOGN+ZKVCdKq8gwc4EbjdQ= X-Received: by 2002:a17:906:a083:b0:7b2:b15e:322f with SMTP id q3-20020a170906a08300b007b2b15e322fmr76404842ejy.75.1670533144943; Thu, 08 Dec 2022 12:59:04 -0800 (PST) MIME-Version: 1.0 References: <20221205210354.11846-1-andrew.smirnov@gmail.com> In-Reply-To: From: Andrey Smirnov Date: Thu, 8 Dec 2022 12:58:53 -0800 Message-ID: Subject: Re: [RFC PATCH 0/2] Handling of non-numbered feature reports by hidraw To: David Rheinsberg Cc: linux-input@vger.kernel.org, Jiri Kosina , Benjamin Tissoires , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 Thu, Dec 8, 2022 at 7:46 AM David Rheinsberg wrote: > > Hi > > On Mon, 5 Dec 2022 at 22:04, Andrey Smirnov wrote: > > I'm working on a firmware of a device that exposes a HID interface via > > USB and/or BLE and uses, among other things, non-numbered feature > > reports. Included in this series are two paches I had to create in > > order for hidraw devices created for aforementioned subsystems to > > behave in the same way when exerciesd by the same test tool. > > > > I don't know if the patches are acceptable as-is WRT to not breaking > > existing userspace, hence the RFC tag. > > Can you elaborate why you remove the special handling from USBHID but > add it to UHID? They both operate logically on the same level, so > shouldn't we simply adjust uhid to include the report-id in buf[0]? > > Also, you override buf[0] in UHID, so I wonder what UHID currently > returns there? > > IOW, can you elaborate a bit what the current behavior of each of the > involved modules is, and what behavior you would expect? This would > allow to better understand what you are trying to achieve. The more > context you can give, the easier it is to understand what happens > there. > Sorry it's not very clear, so the difference between the cases is that in the case of UHID the report ID ends up being included as a part of "SET_FEATURE", so BlueZ checks UHID_DEV_NUMBERED_FEATURE_REPORTS, which is not set (correctly) and tries to send the whole payload. This ends up as a maxlen + 1 (extra byte) write to a property that is maxlen long, which gets rejected by device's BLE stack. In the case of USBHID the problem happens in "GET_FEATURE" path. When userspace reads the expected data back it gets an extra 0 prepended to the payload, so all of the actual payload has an offset of 1. This doesn't happen with UHID, which I think is the correct behavior here. Hopefully that explains the difference, let me know if something is unclear