Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3867739pxp; Tue, 15 Mar 2022 07:51:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7tFzCZkWXVMsFv1Z3B75r53TOitLOLlcByerpKZNUt9Kx2NnL1Zt4MKGOiGp5/fYdN4VP X-Received: by 2002:aa7:d1cc:0:b0:416:60c6:9225 with SMTP id g12-20020aa7d1cc000000b0041660c69225mr25577249edp.71.1647355913197; Tue, 15 Mar 2022 07:51:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647355913; cv=none; d=google.com; s=arc-20160816; b=Em9he71PEvLPpxBZC0i2jgy5fuKPq5pBJFR9vgPcG7TcFwQ6IDtuHhQ6ojGu6Q8L8b 7mGgD4oGUHaw8rKBdz3TyxrelksTjc5veb06IqWBuepTVJIS/Z7b6STi2cTJrqvJvmTh WskSXbszGZgkT6az/RbdBaNy2+iEKrCq4qs6lVEguCr11FVIg6jaVWSIFvmeUE64xPR/ 8FXJxthZ1sOsLaK0FV31r0O2rj6GpHjVyakWDagtTYJSUZKWwtxFInyjZEG9s9/53lET jVjoFcU9C8QqWrfB97gxKAEmPm+r7zswKmRUPxdYlLlGaoJNKEzUuHiPItSVwZdLlQZf gdvg== 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=/OM4uuBB85ru9k2XyDdu6MtUGzaaDurW3J928EJtrW8=; b=o5yjde+AIQkDRNkgIBOBM0Ut40kHnFlgA9A6lxUg7s0U8lXQMpsJMo96RliAy5YT4o 9YDNgD87e8GWF5FBImiyJsZ2FzSbIbMDC8LFgqOtYDadlW8l6SBpWks+DmNNJdb9AJnP L2HoaXX7KflhMNxTyYtrHnYIotNnnlINHbjy5qpgut1T0/xrdfOVInKIJwgKLoWEi/Nh PG2t8NftqsFsudNHZuZ+f3KrnZ5bvHXSzU4ZQRbcHdCgZftdAjc1rLgafhs2sUboGgt6 W888Mct8q3CJZwb97Fs9nSxd3b5ZehDHu6lFsa1uFy+++TnonzZ/kttEUJ1caokDeoBp 2Z4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2H3d7uU+; 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 hr24-20020a1709073f9800b006d68123f949si11148672ejc.376.2022.03.15.07.51.27; Tue, 15 Mar 2022 07:51:53 -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=2H3d7uU+; 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 S242109AbiCNMSq (ORCPT + 99 others); Mon, 14 Mar 2022 08:18:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242392AbiCNMJz (ORCPT ); Mon, 14 Mar 2022 08:09:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C58D56404; Mon, 14 Mar 2022 05:07:50 -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 ams.source.kernel.org (Postfix) with ESMTPS id 744B5B80DED; Mon, 14 Mar 2022 12:07:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9096C340EC; Mon, 14 Mar 2022 12:07:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647259668; bh=dQE9AN0W3xhOOojm4d6cc0ZVs/VcgoMmZFSyfL9v3+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2H3d7uU+57Zd59ZIej/qiKmal169BeekIH6tY1uFdYkQmbuOszYGvDNcgTacdPzFQ Ax6HMtCuQp5s0XFKJpUpBrnbn/MBsjT20w6aGvRwD+5kAmVOXx+IMRWQUG8lkqbfFK ly2uVu5Uit+gXjAO4u4XjISlHEhHm5GggT0irB8o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jon Maloy , Tung Nguyen , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 035/110] tipc: fix incorrect order of state message data sanity check Date: Mon, 14 Mar 2022 12:53:37 +0100 Message-Id: <20220314112744.017934814@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314112743.029192918@linuxfoundation.org> References: <20220314112743.029192918@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=-8.6 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: Tung Nguyen [ Upstream commit c79fcc27be90b308b3fa90811aefafdd4078668c ] When receiving a state message, function tipc_link_validate_msg() is called to validate its header portion. Then, its data portion is validated before it can be accessed correctly. However, current data sanity check is done after the message header is accessed to update some link variables. This commit fixes this issue by moving the data sanity check to the beginning of state message handling and right after the header sanity check. Fixes: 9aa422ad3266 ("tipc: improve size validations for received domain records") Acked-by: Jon Maloy Signed-off-by: Tung Nguyen Link: https://lore.kernel.org/r/20220308021200.9245-1-tung.q.nguyen@dektech.com.au Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/tipc/link.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/tipc/link.c b/net/tipc/link.c index 4e7936d9b442..115a4a7950f5 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -2285,6 +2285,11 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb, break; case STATE_MSG: + /* Validate Gap ACK blocks, drop if invalid */ + glen = tipc_get_gap_ack_blks(&ga, l, hdr, true); + if (glen > dlen) + break; + l->rcv_nxt_state = msg_seqno(hdr) + 1; /* Update own tolerance if peer indicates a non-zero value */ @@ -2310,10 +2315,6 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb, break; } - /* Receive Gap ACK blocks from peer if any */ - glen = tipc_get_gap_ack_blks(&ga, l, hdr, true); - if(glen > dlen) - break; tipc_mon_rcv(l->net, data + glen, dlen - glen, l->addr, &l->mon_state, l->bearer_id); -- 2.34.1