Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4274571rwd; Tue, 23 May 2023 05:49:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ64aoQFmufPGvojp0RheDJ3/XCQMNwc3WKL92QU7lYk/ztM1tt98L6Qbfgu3tKgqQwxfzh6 X-Received: by 2002:a17:902:ab59:b0:1ac:83d1:9246 with SMTP id ij25-20020a170902ab5900b001ac83d19246mr11675955plb.61.1684846182932; Tue, 23 May 2023 05:49:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684846182; cv=none; d=google.com; s=arc-20160816; b=zoPP59K6Z3LSwJhlEDl6jwvLER1wyCi7/C3APECjCi6a7GPFsjvH2d0U16y7x/bHtt fh4xzbbXFvKhxlP+TBgto5gVbvHJ2jI3hmaR7MDsLDlLY/uKIQpznvvbq9GOip3NmWcO tRtE7u9EM4HKQdIfsfho7/OOExCoutVU0agOYgGq73EMfr18Oq6fBmLGbyG2V33+ik7P bEprG5iwiTKYCdsI7GNLyB4+gqTE2ENZLLahuCeTWsbUIBSHNyMwF03aOS/XZO9VlKll iFGwU06pmwts0rzfT85IjUyPlAHEQclPGh8Eypw9dLKmy1OKPaOCQGlMmEgbvMCoYn/E nNVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=MYbIu7RXHDT2OtEYzMJwgIN1/6hg7UIS/vAY008B7ro=; b=ZL4zIze1I4/ZGhs2bgKyvxBj1a7d6Qwud8hESpJ+ADRDCs0gCQB0d6h/OYW//67Sfd WaCn6pBwKbBtDyPkvKq4DZLuNprQ7Eb6FBqsQcOeko18bJZHl5OSZVUXn7sxT4D9HY64 VIamU2HK0fDakMld3Q909A8Bm/V7L5QqBU/v/hdcw7s1LvK0gUebCzoqEVHhb6rMDWcX p06ViYw094KLUhX8fZJjpe9XYgWtHGJyoYVVIcjwtXpsAbA45nEel5KAgJGYn2p1sEnM LPioddgVI1IDaDIYi1ZKTIk3GwY38B7qOz5U7650l13/MWTT/ucUazt3GKwAtm/PBfql O2Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L+0fOCK3; 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 j8-20020a170902da8800b001ac68a1500esi5053116plx.648.2023.05.23.05.49.30; Tue, 23 May 2023 05:49:42 -0700 (PDT) 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=L+0fOCK3; 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 S236856AbjEWMbX (ORCPT + 99 others); Tue, 23 May 2023 08:31:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236863AbjEWMbW (ORCPT ); Tue, 23 May 2023 08:31:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A516D126; Tue, 23 May 2023 05:31:20 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 33F5C631DA; Tue, 23 May 2023 12:31:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4987C433EF; Tue, 23 May 2023 12:31:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684845079; bh=g2m24cQ4gdROItmruRoaFFe92RJLnSrCp+y/ymODJ8s=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=L+0fOCK34D1zmuin8Wl7I2gS8xbpwc+/hTe4sw9jiQW0h2b20dbAJPF0a34lmLh/F XmrAxb1GibB/Dxs3YT6w0dZlJyUOmhUwbidEUmlevoXGzRk38O/ww9tnPxgB0HkyJl ae0ROulk07UdRyR5wjzJ2IbmfQhdWXvdaGIfFRJfllboDOkuiBfNj3dUAQ1GESJcxR 2t2wxumoQwJTHLWFtHU/ZTtOholkBfcBLDm62TGI6it7X1TYjcZWCPeR9PnSccK4nH MgoI7Mi7VM5x6dPhpms9OWUTA4srYIpad+p/SuyT8FPt59/rj/vNoR5hulsmjWYKZn VSPTIjGlA+krQ== Date: Tue, 23 May 2023 14:31:15 +0200 (CEST) From: Jiri Kosina To: Linus Torvalds cc: Linux regressions mailing list , Benjamin Tissoires , Bagas Sanjaya , =?ISO-8859-15?Q?Filipe_La=EDns?= , Bastien Nocera , "open list:HID CORE LAYER" , LKML , guy.b@bluewin.ch Subject: Re: [regression] Since kernel 6.3.1 logitech unify receiver not working properly In-Reply-To: Message-ID: References: <9b987585-0834-bb8c-3414-283c29f3f2ab@leemhuis.info> <55dda0bb-fe42-6dee-28ea-00121554d092@leemhuis.info> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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,T_SCC_BODY_TEXT_LINE 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 Mon, 22 May 2023, Linus Torvalds wrote: > > FWIW, in case anybody is interested in a status update: one reporter > > bisected the problem down to 586e8fede79 ("HID: logitech-hidpp: Retry > > commands when device is busy"); reverting that commit on-top of 6.3 > > fixes the problem for that reporter. For that reporter things also work > > on 6.4-rc; but for someone else that is affected that's not the case. FWIW, I was pretty much away for past few weeks as well, same as Benjamin as Bastien. Which is unfortunate timing, but that's how things pan out sometimes. > Hmm. It's likely timing-dependent. > > But that code is clearly buggy. > > If the wait_event_timeout() returns early, the device hasn't replied, > but the code does > > if (!wait_event_timeout(hidpp->wait, hidpp->answer_available, > 5*HZ)) { > dbg_hid("%s:timeout waiting for response\n", __func__); > memset(response, 0, sizeof(struct hidpp_report)); > ret = -ETIMEDOUT; > } > > and then continues to look at the response _anyway_. Yeah; we are zeroing it out, but that doesn't really make things any better in principle, given all the dereferences later. The issue seems to be existing ever since 2f31c52529 ("HID: Introduce hidpp, a module to handle Logitech hid++ devices") when this whole driver was introduced, as far as I can tell. > Now, depending on out hardening options, that response may have been > initialized by the compiler, or may just be random stack contents. Again, as in case of timeout the buffer is just zeroed out, I'd just much more expect NULL pointer dereference in such case. Which is not what we are seeing here. > That bug is pre-existing (ie the problem was not introduced by that > commit), but who knows if the retry makes things worse (ie if it then > triggers on a retry, the response data will be the *previous* response). > > The whole "goto exit" games should be removed too, because we're in a > for-loop, and instead of "goto exit" it should just do "break". > > IOW, something like this might be worth testing. > > That said, while I think the code is buggy, I doubt this is the actual > cause of the problem people are reporting. But it would be lovely to > hear if the attached patch makes any difference, and I think this is > fixing a real - but unlikely - problem anyway. > > And obviously it might be helpful to actually enable those dbg_hid() > messages, but I didn't look at what the magic config option to do so > was. dbg_hid() is just pr_debug(), which means that on kernels with CONFIG_DYNAMIC_DEBUG, this makes use of the dynamic debug facility; otherwsie it just becomes printk(KERN_DEBUG...). Thanks, -- Jiri Kosina SUSE Labs