Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4723951iob; Sun, 8 May 2022 23:19:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxONeFSEGAteRglwJAQmKb4+kRWYuYCaBY13WxYsaX7m1DkkjNnKE2cEn1oIdEd5hIMdtkM X-Received: by 2002:a17:90a:e510:b0:1d8:39b3:280b with SMTP id t16-20020a17090ae51000b001d839b3280bmr25232239pjy.142.1652077192171; Sun, 08 May 2022 23:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652077192; cv=none; d=google.com; s=arc-20160816; b=SYf1fYT9wAPmuSs/B0Odi+gTu8I7u9rmqKf3ijsh/71B49d83pzRfjCaU0qrp9HXI0 nDDWcb/Djy+yYgBHj8Eb4/oVyW1Ky19YBQUL/78tGRatM97wZ0jvbM2r9d+vGYUJpS9n 1Z65UXtpR8XlT/kOPbLhJYRspyQiBUxRkXhEHNX+tpLOUwAYU0ZBy7fs9hzbsdzCd57K GjUGY68wdUkNi1ETb51FVyQTtpJ7Mr4p3kJ8zTfOcmi5zo1w1EDcMvYT78j5iV8P/62j oNya6Aj9hUJWyZcgwCFs19jAiPR7lJY7/mgkOWvbFNmARjsvh8X7kctmct+Ox0RW75yO mEag== 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=BvwKVEpGQ4s6a8WiMVA7mcgvSg4PrD6R0nU0UiuchGc=; b=DGmjxJPIOKg+S5HqbpCCJJd1lr7fZgPDvZ/NrnxU0oqYnnOUR7NEbcPgQ5/QTe8P/g R2GArm1STPBQ8ZfOXyl0r77CEE4BWL0tt7IsRerTnNqzVg5wlCQ4RpefYFMiD9zKlHUE SPQUIhwSaP372QIQCfjG6AzptLn7oeeTzR0y5/TAQOjlQLRW0tnWm6yHCdt6jK0qBs21 sayMh59TtCQ8OHzJOUDtAFaf1KbBUcH+5TGwO14aCwTQ8WoXyJ+1pfc2mqARrNPS9eo9 Avc9lag42toVDmdnd8Fwdo9P1u1bTnGJaDi62iMqKik4H1IIKKEEpxuwqjSEF0epGnTf AEbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=P31LxUDx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id r13-20020a170902c7cd00b00153b2d16647si8495061pla.591.2022.05.08.23.19.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 23:19:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=P31LxUDx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 99F7013C1CF; Sun, 8 May 2022 23:16:50 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359785AbiEDRxw (ORCPT + 99 others); Wed, 4 May 2022 13:53:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357818AbiEDRPW (ORCPT ); Wed, 4 May 2022 13:15:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 965CD5549F; Wed, 4 May 2022 09:59:02 -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 568CB618AC; Wed, 4 May 2022 16:59:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4A17C385B1; Wed, 4 May 2022 16:59:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683541; bh=j4di2SiZYsOQ8iqn5pxU5YuTVDJsOrrUoFgbjmZGRSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P31LxUDxtyZPSYCwiQemMrYrOCsV5lN7d3J+pXmmFkSbHR0JcIgNsi0P+rQik1mFH s9PGjSwXjZjlSqb1kAGgP1vVSvJflh0E7y/QxyY9ZtY0nQAx9+HL76HebU7ymtHnPa wPBEBhfQBD7it1s1AXD0d6ylH9wCNC02fMwgQeYU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Starke Subject: [PATCH 5.17 212/225] tty: n_gsm: fix wrong command retry handling Date: Wed, 4 May 2022 18:47:30 +0200 Message-Id: <20220504153128.914688313@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153110.096069935@linuxfoundation.org> References: <20220504153110.096069935@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=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 @@ -1354,7 +1354,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; @@ -1363,6 +1362,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); } @@ -1403,7 +1403,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; @@ -2343,7 +2343,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;