Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp347289rdb; Thu, 5 Oct 2023 07:41:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLd+ygRsc2DwMrwkbAOurAJ8MW433YExX65nfugxCspBUU00F+D48mMAR1L0SDvl4gf7mK X-Received: by 2002:a17:902:bb84:b0:1c4:5c05:c3d3 with SMTP id m4-20020a170902bb8400b001c45c05c3d3mr5257954pls.14.1696516918676; Thu, 05 Oct 2023 07:41:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696516918; cv=none; d=google.com; s=arc-20160816; b=DCX96rszky3sEqnTQbThyloh++CX8vmHttknFcLIuh701wK+8z8AW5l+gjmwz+svgb 8Auc8n57aezk8umRvL7BXFmBkzyiPTR9Z0p7nDnsZolTnlEWHXIvfsSnGtpqPnkzrWlf g5EKeyqymSgBV2lQN4sqpPMed7b4/ZjknUiNz2gFHnikag1w9w+QtQ2OQ8jAAYqvRNZ5 1QRk3O3hP8D1jeyZXDJo6N70XFHvaEMygL1a7AKFn5Bc9P9NtQ2ke15lgjWQPWaUWs6X UK4mUc0HD7UIxMHnm3LAWWP20HlyIsl3oGTxhVQHHSZabWhZeNvLZkcWsTN85qBZ0S8G Wh5Q== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hZT5+pincDoI3InSYKyX5yztM8UEx5EZmTgBuHYcI0k=; fh=lQmlxQesYx27L+Ts6LV368ZO09XA9ThroYyk67zO4TA=; b=AWy4LwebJMGEDGcbqUQluSDwNB0nSAZMOTWMRjJjx/qrl7x0GDchT350AFM96Opmz+ dDRbcXMZ0fjVU0FT4IFVd+PbtinTWhQdNp+ZZhl4mKNjytmvx4WgKgD4Jbzo/1046dyb jgG7EQnzVijQSjFwDDHTFBnvgytccJubSosiLsJ2tBa+m0qgqa/dlrh01uOp//uupx2z 4Ml5buw4qTYY9bd74AuaNlz6NMxE/M5iLTeRE2m54ic2MqV/0pNC6orWcxCjF5aPnUWk q0a5HUButosAjGA8pWVsrfTObN0iaas2qeKUHD3XnJNdw+Xb6BgEd7wpFaiqCV6ZuMcs zCeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0wxIPavt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id e15-20020a17090301cf00b001c7264c45a6si1688603plh.563.2023.10.05.07.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:41:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0wxIPavt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id ACE9A837431F; Thu, 5 Oct 2023 07:41:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235969AbjJEOjB (ORCPT + 99 others); Thu, 5 Oct 2023 10:39:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235976AbjJEOg0 (ORCPT ); Thu, 5 Oct 2023 10:36:26 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E52E240FA7; Thu, 5 Oct 2023 06:59:06 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C39EEC3279B; Thu, 5 Oct 2023 12:37:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1696509461; bh=yPssmHk+h0I732PLM72/lK/bohTqVJvSoMLO4hpb3D4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=0wxIPavtBAUyeJXufOCmBYrGsalBt0X+Y/fZ+1f7IbmQtmxkzMsmJbQAqTKWiU3P9 awgP8FnfwpkOZvIUnLAjHJS3EYKj6L83fSwtnRA2Bp/g3xRN8TlfGg+k8wjSIzqa9c 3NQ/IXPowUMQ4UWRhCIA1yWbvAPUawd1Ro6Ck9cQ= Date: Thu, 5 Oct 2023 14:37:38 +0200 From: Greg Kroah-Hartman To: Lee Jones 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: <2023100524-obituary-scoundrel-971d@gregkh> References: <20231004125704.GA83257@google.com> <2023100435-xerox-idiocy-5cf0@gregkh> <20231005090311.GD83257@google.com> <2023100528-directory-arrogant-2ca9@gregkh> <20231005104311.GG83257@google.com> <2023100512-charger-cherisher-9a3d@gregkh> <20231005114632.GA681678@google.com> <2023100507-worst-quarrel-2b97@gregkh> <20231005121756.GB681678@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231005121756.GB681678@google.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Thu, 05 Oct 2023 07:41:26 -0700 (PDT) On Thu, Oct 05, 2023 at 01:17:56PM +0100, Lee Jones wrote: > On Thu, 05 Oct 2023, Greg Kroah-Hartman wrote: > > > On Thu, Oct 05, 2023 at 12:46:32PM +0100, Lee Jones wrote: > > > On Thu, 05 Oct 2023, Starke, Daniel wrote: > > > > > > > > > Would something like this tick that box? > > > > > > > > > > > > diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index > > > > > > 1f3aba607cd51..5c1d2fcd5d9e2 100644 > > > > > > --- a/drivers/tty/n_gsm.c > > > > > > +++ b/drivers/tty/n_gsm.c > > > > > > @@ -3716,6 +3716,10 @@ static ssize_t gsmld_write(struct tty_struct *tty, struct file *file, > > > > > > if (!gsm) > > > > > > return -ENODEV; > > > > > > > > > > > > + /* The GSM line discipline does not support binding to console */ > > > > > > + if (strncmp(tty->name, "tty", 3)) > > > > > > + return -EINVAL; > > > > > > > > > > No, that's not going to work, some consoles do not start with "tty" :( > > > > > > Ah, you mean there are others that we need to consider? > > > > > > I was just covering off con_write() from drivers/tty/vt/vt.c. > > > > > > Does anyone have a counter proposal? > > > > consoles are dynamically assigned, the device knows if it is a console > > or not, so there is a way to determine this at runtime. It's not a > > device naming thing at all. > > It's not a device naming thing, but it is a ... :) > > Okay, here's another uninformed stab in the dark: > > diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c > index 1f3aba607cd51..ddf00f6a4141d 100644 > --- a/drivers/tty/n_gsm.c > +++ b/drivers/tty/n_gsm.c > @@ -3629,6 +3629,10 @@ static int gsmld_open(struct tty_struct *tty) > if (tty->ops->write == NULL) > return -EINVAL; > > + /* The GSM line discipline does not support binding to console */ > + if (tty->driver->type == TTY_DRIVER_TYPE_CONSOLE) > + return -EINVAL; > + > /* Attach our ldisc data */ > gsm = gsm_alloc_mux(); > if (gsm == NULL) > > This seems to allow for the real serial devices (TTY_DRIVER_TYPE_SERIAL) > suggested by Daniel. Close, but not quite. Driver "types" can say if they are a console or not, but that doesn't mean you can't run the console over a serial port as well, right? Sorry, I don't have a real solution right now, and wouldn't wish the phrase "just dig through the tty console code!" on anyone, but that's what it is going to take to figure it out somehow, I can't remember the exact way consoles are hooked up at the moment (I conviently skipped that portion of the tty layer in my Embedded Recipies talk last week, saying "it's magic...") thanks, greg k-h