Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp396002rdb; Thu, 5 Oct 2023 08:58:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwFT7MzQPMxdUl16eTWNjTN53y5dpzK3uMUwzJCkBFRuY66jxEOq7jKZKeisN1RaiZZiI4 X-Received: by 2002:a05:6808:1a27:b0:3af:6c91:275f with SMTP id bk39-20020a0568081a2700b003af6c91275fmr7321321oib.2.1696521514761; Thu, 05 Oct 2023 08:58:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696521514; cv=none; d=google.com; s=arc-20160816; b=hvfwEhDg45p4dqh1stzZsbPIYNFV1Q1d93oiRgI5MVPecD7cKcY2BSB5GxSSG/XLWd 3kBEJPYM1X8HQVsoYJWLWObuJSkX3kOMGzvxhW9+YyI2xyWMV4k+u0oZORZr5wCTaz++ tQpeKS2qpfjrjIxJjEI01Ab05ohbnj/AgZtVmLUOPbEMj3M0OBVSQL5vMQ50CYK3NI/a aQ3qGxezmSMfv9DMuUbyVSx8QmM60WcbpG/fYVkP8gETDR3Adm61GtQB4LGEA+CKwF2x bPqs9FWTEdmyMmJUTUKFiyuM+fzeC9bpDwEU4cCikgiyEYw7Fkft4u8qK4LgqAwSq+px nLPw== 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=rbLAifRzq9khd6znL7P7jMaciJCBAAmCTYoew8AAlqg=; fh=ATEBROlmvrvvHzOo8FfIW33AQuJxtrwlNS07ZQfwZYk=; b=PDu56ErGOYwm/cwQH9bTm5FZrQiO+BEUnm2lkrngguNT9EcIbQOtN4XEATtCd7IqWH ZTtKWOEzWWcGtZt7dB5/hO9/i/VmJ2tmk3Hfet+U5Gi3fY1iLLbbotLD5N34IkdfhD2v 5toeCv5+gbLlMjykH+msvGGUvQ8h8U/J1U9H/pLymwq8tCZXN+dDDjYtmXMlyiGv/vT9 IZLoGySvidfxieC8vInew6vRMr/Og/nAqJHecinUouI6oVZr402le4iQl9EW9lTEABdW UsAEm2ARsSEWqOsPtHhi9D7Z9C4PjG4yAII4bkwWE8IKl+YUxGgC/x3bCyI3hNli1OtD Qopw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UR6p4R+e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id 38-20020a630f66000000b00577448019b5si1677748pgp.276.2023.10.05.08.58.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 08:58:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UR6p4R+e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7DC1382E7507; Thu, 5 Oct 2023 08:58:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238034AbjJEP6L (ORCPT + 99 others); Thu, 5 Oct 2023 11:58:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233815AbjJEP4n (ORCPT ); Thu, 5 Oct 2023 11:56:43 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 467335253; Thu, 5 Oct 2023 06:52:33 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E89CDC116B6; Thu, 5 Oct 2023 09:03:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696496596; bh=Oh6z41EHlAHzegiycj3Z6oYPy1RmyXl7393yq+axU3s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UR6p4R+erialbPxyVBaJL+VX62WIR8Bz2v9JB71U/XVJSIIQNHrns0+nTXBeM8g/T OGobN5quUApdhCidM5WG1cGtuaVNuyZm1hgS0ooqQeBuMocA3OIyhrif+bhiZA9VK4 UzRz3RrM8dyxiqc0zwCiXekiZ/6GkQB4rV7UykluYzCVh2JpW9/WzkI7qyRrKhNPqa rewZKIro45kQa8b7gAmzOPI55uN/c6gMX7gj3QZw5XjQaUW9nz1seXnl36NdPyU6xB a+SY1heOfrZEAtGvJ8GDdhUZqaBYEe/G6YOizxJSyvh5idHP3xKofDFx4KlCcvm5DJ xvmaIT3sCP3Og== Date: Thu, 5 Oct 2023 10:03:11 +0100 From: Lee Jones To: Greg Kroah-Hartman Cc: "Starke, Daniel" , "linux-kernel@vger.kernel.org" , Fedor Pchelkin , Jiri Slaby , "linux-serial@vger.kernel.org" , "syzbot+5f47a8cea6a12b77a876@syzkaller.appspotmail.com" Subject: Re: [PATCH 1/1] tty: n_gsm: Avoid sleeping during .write() whilst atomic Message-ID: <20231005090311.GD83257@google.com> References: <20231003170020.830242-1-lee@kernel.org> <2023100320-immorally-outboard-573a@gregkh> <2023100421-negotiate-stammer-1b35@gregkh> <20231004085720.GA9374@google.com> <2023100448-cotton-safehouse-aca2@gregkh> <20231004125704.GA83257@google.com> <2023100435-xerox-idiocy-5cf0@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2023100435-xerox-idiocy-5cf0@gregkh> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 05 Oct 2023 08:58:33 -0700 (PDT) On Wed, 04 Oct 2023, Greg Kroah-Hartman wrote: > On Wed, Oct 04, 2023 at 01:57:04PM +0100, Lee Jones wrote: > > On Wed, 04 Oct 2023, Greg Kroah-Hartman wrote: > > > > > On Wed, Oct 04, 2023 at 09:57:20AM +0100, Lee Jones wrote: > > > > On Wed, 04 Oct 2023, Greg Kroah-Hartman wrote: > > > > > > > > > On Wed, Oct 04, 2023 at 05:59:09AM +0000, Starke, Daniel wrote: > > > > > > > Daniel, any thoughts? > > > > > > > > > > > > Our application of this protocol is only with specific modems to enable > > > > > > circuit switched operation (handling calls, selecting/querying networks, > > > > > > etc.) while doing packet switched communication (i.e. IP traffic over PPP). > > > > > > The protocol was developed for such use cases. > > > > > > > > > > > > Regarding the issue itself: > > > > > > There was already an attempt to fix all this by switching from spinlocks to > > > > > > mutexes resulting in ~20% performance loss. However, the patch was reverted > > > > > > as it did not handle the T1 timer leading into sleep during atomic within > > > > > > gsm_dlci_t1() on every mutex lock there. > > > > > > > > That's correct. When I initially saw this report, my initial thought > > > > was to replace the spinlocks with mutexts, but having read the previous > > > > accepted attempt and it's subsequent reversion I started to think of > > > > other ways to solve this issue. This solution, unlike the last, does > > > > not involve adding sleep inducing locks into atomic contexts, nor > > > > should it negatively affect performance. > > > > > > > > > > There was also a suggestion to fix this in do_con_write() as > > > > > > tty_operations::write() appears to be documented as "not allowed to sleep". > > > > > > The patch for this was rejected. It did not fix the issue within n_gsm. > > > > > > > > > > > > Link: https://lore.kernel.org/all/20221203215518.8150-1-pchelkin@ispras.ru/ > > > > > > Link: https://lore.kernel.org/all/20221212023530.2498025-1-zengheng4@huawei.com/ > > > > > > Link: https://lore.kernel.org/all/5a994a13-d1f2-87a8-09e4-a877e65ed166@kernel.org/ > > > > > > > > > > Ok, I thought I remembered this, I'll just drop this patch from my > > > > > review queue and wait for a better solution if it ever comes up as this > > > > > isn't a real issue that people are seeing on actual systems, but just a > > > > > syzbot report. > > > > > > > > What does the "better solution" look like? > > > > > > One that actually fixes the root problem here (i.e. does not break the > > > recursion loop, or cause a performance decrease for normal users, or > > > prevent this from being bound to the console). > > > > Does this solution break the recursion loop or affect performance? > > This solution broke the recursion by returning an error, right? This is the part I was least sure about. If this was considered valid and we were to go forward with a solution like this, what would a quality improvement look like? Should we have stayed in this function and waited for the previous occupant to leave before continuing through ->write()? > The performance one was by using mutexes as in previous attempts. Right. This solution was designed to avoid that. -- Lee Jones [李琼斯]