Message ID | 20231026055844.3127-1-daniel.starke@siemens.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp451729vqb; Wed, 25 Oct 2023 23:01:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDfVApmdAXvHKhRMKRq0sj5P6II80z++wLdOVu4XWJGfRhOjN3zH5aFA0jejbz/iAIDoPq X-Received: by 2002:a05:6808:110:b0:3a7:b4e8:563e with SMTP id b16-20020a056808011000b003a7b4e8563emr16936009oie.38.1698300093353; Wed, 25 Oct 2023 23:01:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698300093; cv=none; d=google.com; s=arc-20160816; b=sn+P7x5++BqxsipRuGK6A4n+ShY8Re5vB5deaOILbSYkQvhelHc8pLKBDlPUlIAil0 eGDob2L5nDeoN0IAmsc7YOrg6LEg3QLIfF1CgmnEasx98RQKK88SgyhR3Pht2GZDJCdk TuwjUZwXLIAtHMhTyycYnUnXkTTe+gTifz+XXEgikStVx47xw71aaWW493xCGjqHTJJm NGY0MpRnklMdpQmqH7+2jNfyYetqeJ9UBdoD8KOzELt30HCTyg5XvC+7eZOfOjjQ4KTh jiru7calwrW6ZTazv00IxEdN6kByLTARDoszUCVfhRwIpHSvshyN0aSNbhJaTDi9oQ74 9GFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=i3xb5thx0MStC8QddfRm44mVBZo7gXtRg05zVb8PFKg=; fh=5YXR7RtUzZ11YkjdXTzgd3M62+HIxQ5O+Fdh381pAu0=; b=sXi90+sPaGwGIYxEXZzPP/mOkGyQQw65YzNk025b9vZU5uvoe40zvP1MXsw9z/6Zrf NcTnmEsCnUKa4kpm0k8IQ+ZzGf7I+AdyoQRod8vYWAUkysd/CnbyRwyulaCmoj3T5Axx ufjrqfWwCa66B98kUHS3/Dvg7qsm2+Y8XxZFv9Lo4SB0q41kXz9M4caubscjJRwgTLhg erVN69iGoneEWjre/5NYJgTgnj42/2HQChTM4LPBzYZBxJYlVvaYe7EF/iU/zgUIOzns 5jPYJkASR++v7E5W7Z1/bfvVe/SaOOAFoSnBlZ9+2DTjuiqcL7OIHqFvIlEfxWBIjurF eWFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=Yk9TWcAb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id p135-20020a25428d000000b00d9a63d1d310si13624019yba.109.2023.10.25.23.01.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 23:01:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=Yk9TWcAb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id BF3178116E5F; Wed, 25 Oct 2023 23:01:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343862AbjJZGBN (ORCPT <rfc822;aposhian.dev@gmail.com> + 26 others); Thu, 26 Oct 2023 02:01:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230478AbjJZGBM (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 26 Oct 2023 02:01:12 -0400 X-Greylist: delayed 62 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 25 Oct 2023 23:01:09 PDT Received: from mta-65-225.siemens.flowmailer.net (mta-65-225.siemens.flowmailer.net [185.136.65.225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6776213A for <linux-kernel@vger.kernel.org>; Wed, 25 Oct 2023 23:01:09 -0700 (PDT) Received: by mta-65-225.siemens.flowmailer.net with ESMTPSA id 202310260600042c81036199cfc14f67 for <linux-kernel@vger.kernel.org>; Thu, 26 Oct 2023 08:00:04 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=daniel.starke@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc; bh=i3xb5thx0MStC8QddfRm44mVBZo7gXtRg05zVb8PFKg=; b=Yk9TWcAbRChesErzaiTjGYrKUXMFp+QoYKQtTK3Vu7Thfiou1vhn8n3v2UZJODaJVssXlD DY8CRagUEvSAZAe7FF3GzAG2zFmN42qjnRtch0dVeP7YTrLVbytL36gbu6IRkWuN+58XlrTM KCIC2V4hXgD3CRpelYBJQ8Iiwlck8=; From: "D. Starke" <daniel.starke@siemens.com> To: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: linux-kernel@vger.kernel.org, Daniel Starke <daniel.starke@siemens.com> Subject: [PATCH 1/2] tty: n_gsm: fix race condition in status line change on dead connections Date: Thu, 26 Oct 2023 07:58:43 +0200 Message-Id: <20231026055844.3127-1-daniel.starke@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-314044:519-21489:flowmailer X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 25 Oct 2023 23:01:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780796718612609853 X-GMAIL-MSGID: 1780796718612609853 |
Series |
[1/2] tty: n_gsm: fix race condition in status line change on dead connections
|
|
Commit Message
D. Starke
Oct. 26, 2023, 5:58 a.m. UTC
From: Daniel Starke <daniel.starke@siemens.com> gsm_cleanup_mux() cleans up the gsm by closing all DLCIs, stopping all timers, removing the virtual tty devices and clearing the data queues. This procedure, however, may cause subsequent changes of the virtual modem status lines of a DLCI. More data is being added the outgoing data queue and the deleted kick timer is restarted to handle this. At this point many resources have already been removed by the cleanup procedure. Thus, a kernel panic occurs. Fix this by proving in gsm_modem_update() that the cleanup procedure has not been started and the mux is still alive. Note that writing to a virtual tty is already protected by checks against the DLCI specific connection state. Fixes: c568f7086c6e ("tty: n_gsm: fix missing timer to handle stalled links") Signed-off-by: Daniel Starke <daniel.starke@siemens.com> --- drivers/tty/n_gsm.c | 2 ++ 1 file changed, 2 insertions(+)
Comments
On Thu, Oct 26, 2023 at 07:58:43AM +0200, D. Starke wrote: > From: Daniel Starke <daniel.starke@siemens.com> > > gsm_cleanup_mux() cleans up the gsm by closing all DLCIs, stopping all > timers, removing the virtual tty devices and clearing the data queues. > This procedure, however, may cause subsequent changes of the virtual modem > status lines of a DLCI. More data is being added the outgoing data queue > and the deleted kick timer is restarted to handle this. At this point many > resources have already been removed by the cleanup procedure. Thus, a > kernel panic occurs. > > Fix this by proving in gsm_modem_update() that the cleanup procedure has > not been started and the mux is still alive. > > Note that writing to a virtual tty is already protected by checks against > the DLCI specific connection state. > > Fixes: c568f7086c6e ("tty: n_gsm: fix missing timer to handle stalled links") > Signed-off-by: Daniel Starke <daniel.starke@siemens.com> > --- > drivers/tty/n_gsm.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c > index 1f3aba607cd5..0ee7531c9201 100644 > --- a/drivers/tty/n_gsm.c > +++ b/drivers/tty/n_gsm.c > @@ -4108,6 +4108,8 @@ static int gsm_modem_upd_via_msc(struct gsm_dlci *dlci, u8 brk) > > static int gsm_modem_update(struct gsm_dlci *dlci, u8 brk) > { > + if (dlci->gsm->dead) > + return -EL2HLT; > if (dlci->adaption == 2) { > /* Send convergence layer type 2 empty data frame. */ > gsm_modem_upd_via_data(dlci, brk); > -- > 2.34.1 > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - You have marked a patch with a "Fixes:" tag for a commit that is in an older released kernel, yet you do not have a cc: stable line in the signed-off-by area at all, which means that the patch will not be applied to any older kernel releases. To properly fix this, please follow the documented rules in the Documentation/process/stable-kernel-rules.rst file for how to resolve this. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot
On Thu, Oct 26, 2023 at 10:27:37AM +0200, Greg KH wrote: > On Thu, Oct 26, 2023 at 07:58:43AM +0200, D. Starke wrote: > > From: Daniel Starke <daniel.starke@siemens.com> > > > > gsm_cleanup_mux() cleans up the gsm by closing all DLCIs, stopping all > > timers, removing the virtual tty devices and clearing the data queues. > > This procedure, however, may cause subsequent changes of the virtual modem > > status lines of a DLCI. More data is being added the outgoing data queue > > and the deleted kick timer is restarted to handle this. At this point many > > resources have already been removed by the cleanup procedure. Thus, a > > kernel panic occurs. > > > > Fix this by proving in gsm_modem_update() that the cleanup procedure has > > not been started and the mux is still alive. > > > > Note that writing to a virtual tty is already protected by checks against > > the DLCI specific connection state. > > > > Fixes: c568f7086c6e ("tty: n_gsm: fix missing timer to handle stalled links") > > Signed-off-by: Daniel Starke <daniel.starke@siemens.com> > > --- > > drivers/tty/n_gsm.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c > > index 1f3aba607cd5..0ee7531c9201 100644 > > --- a/drivers/tty/n_gsm.c > > +++ b/drivers/tty/n_gsm.c > > @@ -4108,6 +4108,8 @@ static int gsm_modem_upd_via_msc(struct gsm_dlci *dlci, u8 brk) > > > > static int gsm_modem_update(struct gsm_dlci *dlci, u8 brk) > > { > > + if (dlci->gsm->dead) > > + return -EL2HLT; > > if (dlci->adaption == 2) { > > /* Send convergence layer type 2 empty data frame. */ > > gsm_modem_upd_via_data(dlci, brk); > > -- > > 2.34.1 > > > > Hi, > > This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him > a patch that has triggered this response. He used to manually respond > to these common problems, but in order to save his sanity (he kept > writing the same thing over and over, yet to different people), I was > created. Hopefully you will not take offence and will fix the problem > in your patch and resubmit it so that it can be accepted into the Linux > kernel tree. > > You are receiving this message because of the following common error(s) > as indicated below: > > - You have marked a patch with a "Fixes:" tag for a commit that is in an > older released kernel, yet you do not have a cc: stable line in the > signed-off-by area at all, which means that the patch will not be > applied to any older kernel releases. To properly fix this, please > follow the documented rules in the > Documentation/process/stable-kernel-rules.rst file for how to resolve > this. > > If you wish to discuss this problem further, or you have questions about > how to resolve this issue, please feel free to respond to this email and > Greg will reply once he has dug out from the pending patches received > from other developers. > Note, I'll take this now, and add the tag by hand, just try to remember it for the future. thanks, greg k-h
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 1f3aba607cd5..0ee7531c9201 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -4108,6 +4108,8 @@ static int gsm_modem_upd_via_msc(struct gsm_dlci *dlci, u8 brk) static int gsm_modem_update(struct gsm_dlci *dlci, u8 brk) { + if (dlci->gsm->dead) + return -EL2HLT; if (dlci->adaption == 2) { /* Send convergence layer type 2 empty data frame. */ gsm_modem_upd_via_data(dlci, brk);