Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1614938iob; Thu, 5 May 2022 05:13:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5IfxwRkulrd8ihMDwICRXtnBcR4DgCu/CIpJCntEhtbb+iKCMzN0jMsBPL5DydD+Av3Gl X-Received: by 2002:a17:90b:4d84:b0:1dc:6554:1bf2 with SMTP id oj4-20020a17090b4d8400b001dc65541bf2mr5792353pjb.86.1651752791918; Thu, 05 May 2022 05:13:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651752791; cv=none; d=google.com; s=arc-20160816; b=A2UZ/iTxHiS/hGqfP5AQ4+v8Fj3ifkSenJ4Ra1q5tAff6diBSD9r7lBda5C0c3278A JqhNiyFYkmByYqH49MlRBGBaTIrpYzk3q8DztMgREvKSwOADa+dz/AVMrrAX9CKrOJH8 I1eUZdmMfCBcby7/R8mNX8EuPzz9ou5uFg4qbV0yZlTKu6kc1lUDQ163Rb+k3aCNSlcp hWPuVR1GA6N7DEkgKA/KNXwbVvudlpZ36bchwEQEiULeYMKYPuGsp2J2wsnrYgND96JV B1b8gPmijseyZ/0jHt2zuQz9GdZ1IRy9ukFCHHAyjw+tR7Kf3bVVeCAI8nbaizLVxmny 1gfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+HzAmK5rLSegnQfTlpONXxR9INI+WiGl/n+EoIrH8cI=; b=ODV4Y/PhSy6ZzY3IZHJY9ZE4JMqmNhVHmapYn36D0DMdXP+eB8HhD+DP3zwToNcohK zJix0n5N2LGnsnNyxbv21pxeJ4GKjne7eXcim1jfV6x2Oa7jPcYgZthl6VvJ9UqPQECt HT9DGxKvhw33HAbqiBk7lQGaeGvdsvhTxr2EomyOkcI1UvwSJ6Hm+2pf0kjEbYSKzzJO tvkt0zPSYd1w5bpjEJE8M4qEXmtrgjEPAiL11u3noq7MMZNPZ0uR8KvJvQcftg760uv7 3h29lEsbD1OkxOJhBJBhUGwsBM9E9/I7H+uwxLC7OuaPwxxyNeq/NF8T4xxsISlS5GY9 SXgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RElK8c5v; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o6-20020a655bc6000000b003c19e192b51si1525490pgr.20.2022.05.05.05.12.45; Thu, 05 May 2022 05:13:11 -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=@linuxfoundation.org header.s=korg header.b=RElK8c5v; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356648AbiEDRmB (ORCPT + 99 others); Wed, 4 May 2022 13:42:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356613AbiEDRJf (ORCPT ); Wed, 4 May 2022 13:09:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D821E26FC; Wed, 4 May 2022 09:55:14 -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 B8FF461899; Wed, 4 May 2022 16:55:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FB20C385A4; Wed, 4 May 2022 16:55:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683314; bh=mBt5odG1NpN2Xxc1qTN/8ZCV/ARaiXb8egGhXjljbvQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RElK8c5vOi73NJy9DDZr5Gi7+IkfUtn1GVrQweyklIZZMfPzm3ujNhzUB64Z3LV7N kYA6tws0XDoc2eX3P31e2GVaU/WklBYGiPlDBk/72akLODDQtr7Ldg5x/X+JmsMvf6 xgcGYFFp3CrA6ogjoxDvi4oEwF1O6jGZvfXOU6t8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Starke Subject: [PATCH 5.15 166/177] tty: n_gsm: fix wrong command retry handling Date: Wed, 4 May 2022 18:45:59 +0200 Message-Id: <20220504153108.382459489@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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 From: Daniel Starke commit d0bcdffcad5a22f202e3bf37190c0dd8c080ea92 upstream. n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010. See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1516 The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to the newer 27.010 here. Chapter 5.7.3 states that the valid range for the maximum number of retransmissions (N2) is from 0 to 255 (both including). gsm_config() fails to limit this range correctly. Furthermore, gsm_control_retransmit() handles this number incorrectly by performing N2 - 1 retransmission attempts. Setting N2 to zero results in more than 255 retransmission attempts. Fix the range check in gsm_config() and the value handling in gsm_control_send() and gsm_control_retransmit() to comply with 3GPP 27.010. Fixes: e1eaea46bb40 ("tty: n_gsm line discipline") Cc: stable@vger.kernel.org Signed-off-by: Daniel Starke Link: https://lore.kernel.org/r/20220414094225.4527-11-daniel.starke@siemens.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/n_gsm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1329,7 +1329,6 @@ static void gsm_control_retransmit(struc spin_lock_irqsave(&gsm->control_lock, flags); ctrl = gsm->pending_cmd; if (ctrl) { - gsm->cretries--; if (gsm->cretries == 0) { gsm->pending_cmd = NULL; ctrl->error = -ETIMEDOUT; @@ -1338,6 +1337,7 @@ static void gsm_control_retransmit(struc wake_up(&gsm->event); return; } + gsm->cretries--; gsm_control_transmit(gsm, ctrl); mod_timer(&gsm->t2_timer, jiffies + gsm->t2 * HZ / 100); } @@ -1378,7 +1378,7 @@ retry: /* If DLCI0 is in ADM mode skip retries, it won't respond */ if (gsm->dlci[0]->mode == DLCI_MODE_ADM) - gsm->cretries = 1; + gsm->cretries = 0; else gsm->cretries = gsm->n2; @@ -2278,7 +2278,7 @@ static int gsm_config(struct gsm_mux *gs /* Check the MRU/MTU range looks sane */ if (c->mru > MAX_MRU || c->mtu > MAX_MTU || c->mru < 8 || c->mtu < 8) return -EINVAL; - if (c->n2 < 3) + if (c->n2 > 255) return -EINVAL; if (c->encapsulation > 1) /* Basic, advanced, no I */ return -EINVAL;