From patchwork Sun May 14 19:52:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 13240553 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0DBCBA34 for ; Sun, 14 May 2023 19:52:36 +0000 (UTC) Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 635FA199 for ; Sun, 14 May 2023 12:52:33 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-75773a7bd66so892468485a.1 for ; Sun, 14 May 2023 12:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684093952; x=1686685952; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=N2YNf79EHZ/wWVYoLYruhucyvo6J0n3PYGo32c70cl8=; b=I76ZJyyjVOjLuaPIid/NIl3DuaVtujV5dgh9xjm1ui12zreo28ge11Zex/iCjqYYLK A6EYAQEK2EX/b4ruY/Xb3Fvxp4cL/6nHm72Xl0pnlAimsY2OpeuHuzaXRnsFGQAuyXcb 4BAEV4f2YcxbAzW57TpQeK0PgKZ8gUxWEN7NstA0HEfb9/aDL0MnhxmBx8Kcc0dx1qhu 5wcBK0y2uAGfCLEbuts8d1ud8/sXTlr7MtOLGE1kAWp9R+veatEEH2sk3D6b3howGMLo /CgV9nbZ5DoCwDtMln9tRVwaE2NkTeFDlQ067wfQN0RYsKa29OSl1pGfFFuuTvFV8LNQ LbOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684093952; x=1686685952; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N2YNf79EHZ/wWVYoLYruhucyvo6J0n3PYGo32c70cl8=; b=KNRXYaW2vUIf+Ji9Wu3Z2ZK9Zow4m5IuihJjmr7be8PUYjZOMBLKPTBsy9rwHEzPxw uqNJT8fqp4c/3NP2ZvE6b5U5t1NftgPyduh0sl9JOtZH0PVlTOQ5zizzTu77TK9eIRLG YEo62OErsqHhCOa6WcYbxwfPkVQRHeudYPcWsQfFuETxH5sowvYPMV512Rt4aE6aFnuQ KpufkXpz85uNDUsJ8WFuBp1nLlp3rB6nzEZ3DE8fZI0QDN039ftgq3SQfg4q86GlHAEV 17bwsz/jreJHrDZl8DfIYYJ8vbswK0Yd2yJKIhXoX3ObD8nPeU1XOFTrKvfnmX7NOi7K KX7A== X-Gm-Message-State: AC+VfDwMTK9OdGuAq/oImS0Mcbo8De/DOtyTR70FPNzELphUCSQNaZJZ wIINbR2DOMiCwiv6Ffb/zRuP62wtO7N+ew== X-Google-Smtp-Source: ACHHUZ4j4WTwa7ZaOAUJ0hHBs0VrbljPC857FzHqp1V/spauKkMqN2byGgcoH8QYOgVH5o0UZuIXbQ== X-Received: by 2002:a05:622a:4d2:b0:3f4:dec2:76cc with SMTP id q18-20020a05622a04d200b003f4dec276ccmr27493816qtx.49.1684093952289; Sun, 14 May 2023 12:52:32 -0700 (PDT) Received: from wsfd-netdev15.ntdv.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id fa11-20020a05622a4ccb00b003f517e1fed2sm1069444qtb.15.2023.05.14.12.52.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 May 2023 12:52:31 -0700 (PDT) From: Xin Long To: network dev , tipc-discussion@lists.sourceforge.net Cc: davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Paolo Abeni , Jon Maloy , Tung Nguyen Subject: [PATCHv3 net 1/3] tipc: add tipc_bearer_min_mtu to calculate min mtu Date: Sun, 14 May 2023 15:52:27 -0400 Message-Id: <580bc5fa36dd1454a5c111e5490907521d63d060.1684093873.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 X-Patchwork-Delegate: kuba@kernel.org As different media may requires different min mtu, and even the same media with different net family requires different min mtu, add tipc_bearer_min_mtu() to calculate min mtu accordingly. This API will be used to check the new mtu when doing the link mtu negotiation in the next patch. Signed-off-by: Xin Long Acked-by: Jon Maloy --- v2: - use bearer_get() to avoid the open code. v3: - move the change history under ---, as Tung suggested. --- net/tipc/bearer.c | 13 +++++++++++++ net/tipc/bearer.h | 3 +++ net/tipc/udp_media.c | 5 +++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 35cac7733fd3..0e9a29e1536b 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c @@ -541,6 +541,19 @@ int tipc_bearer_mtu(struct net *net, u32 bearer_id) return mtu; } +int tipc_bearer_min_mtu(struct net *net, u32 bearer_id) +{ + int mtu = TIPC_MIN_BEARER_MTU; + struct tipc_bearer *b; + + rcu_read_lock(); + b = bearer_get(net, bearer_id); + if (b) + mtu += b->encap_hlen; + rcu_read_unlock(); + return mtu; +} + /* tipc_bearer_xmit_skb - sends buffer to destination over bearer */ void tipc_bearer_xmit_skb(struct net *net, u32 bearer_id, diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index 490ad6e5f7a3..bd0cc5c287ef 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h @@ -146,6 +146,7 @@ struct tipc_media { * @identity: array index of this bearer within TIPC bearer array * @disc: ptr to link setup request * @net_plane: network plane ('A' through 'H') currently associated with bearer + * @encap_hlen: encap headers length * @up: bearer up flag (bit 0) * @refcnt: tipc_bearer reference counter * @@ -170,6 +171,7 @@ struct tipc_bearer { u32 identity; struct tipc_discoverer *disc; char net_plane; + u16 encap_hlen; unsigned long up; refcount_t refcnt; }; @@ -232,6 +234,7 @@ int tipc_bearer_setup(void); void tipc_bearer_cleanup(void); void tipc_bearer_stop(struct net *net); int tipc_bearer_mtu(struct net *net, u32 bearer_id); +int tipc_bearer_min_mtu(struct net *net, u32 bearer_id); bool tipc_bearer_bcast_support(struct net *net, u32 bearer_id); void tipc_bearer_xmit_skb(struct net *net, u32 bearer_id, struct sk_buff *skb, diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c index c2bb818704c8..0a85244fd618 100644 --- a/net/tipc/udp_media.c +++ b/net/tipc/udp_media.c @@ -738,8 +738,8 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b, udp_conf.local_ip.s_addr = local.ipv4.s_addr; udp_conf.use_udp_checksums = false; ub->ifindex = dev->ifindex; - if (tipc_mtu_bad(dev, sizeof(struct iphdr) + - sizeof(struct udphdr))) { + b->encap_hlen = sizeof(struct iphdr) + sizeof(struct udphdr); + if (tipc_mtu_bad(dev, b->encap_hlen)) { err = -EINVAL; goto err; } @@ -760,6 +760,7 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b, else udp_conf.local_ip6 = local.ipv6; ub->ifindex = dev->ifindex; + b->encap_hlen = sizeof(struct ipv6hdr) + sizeof(struct udphdr); b->mtu = 1280; #endif } else { From patchwork Sun May 14 19:52:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 13240554 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00DB6BA43 for ; Sun, 14 May 2023 19:52:36 +0000 (UTC) Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75EB1CE for ; Sun, 14 May 2023 12:52:34 -0700 (PDT) Received: by mail-qt1-x836.google.com with SMTP id d75a77b69052e-3f392680773so42404191cf.0 for ; Sun, 14 May 2023 12:52:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684093953; x=1686685953; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vdIVSmwHdSdIoPV9cJkDHS/vbOe/GpuUMWjNVM1MTLQ=; b=dB8tqdEheOK20x4a8S0r2kI3GVVyD/xsd/yJ/hGSoJJWzi7glQtqARBgi6xc90XwKr qd5XvNdgjxdmZV5GYW5evLkcn7lFfWuAM2bz3eDPp3Xbztl9wjwTTAErglzbaQqNWS8L 587vR5d1PHTuIUInfdYgE+MyGU7de7DKKrFPf1cmR8YyCuRBgS7U3+JvGoFh/ghvAxNV x5IZT+o/UKSCSY31KKiHbeXXyJmXhUesAmZY4S+bCVHao0ALrBrhCwLcYzbdO5wb63gI RPRpKTf+JacpH29w2H7Vq0zkqzhe2rJGScWfseKWRSWY2Edan5mKGiFrhqkNpQ4BRhk3 p/Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684093953; x=1686685953; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vdIVSmwHdSdIoPV9cJkDHS/vbOe/GpuUMWjNVM1MTLQ=; b=IcoWXd9+e+Oadel+Q2gwt1mxQ0U/xH85wYDaH/UANFPLx5DhS/CRUt7QqhXeeDJKBs 0OvvxG2WlHPLba37ax5zFrkHD1PkCn9ns4jTa8pmvSlC7hlAzPOcunEED3kZmXadYrxL g2JlHri+GtINsYuN8g+z9mzpV6k6gGtplS7GlcJP0IGviI7EjB2Z2Ffy5E1lEwbg+H9l pGi89cGo+Bm+IQmaLaw5P/bnLV3ED1EiZgxsGX0KKlnGj8EPijYmSPG1GyhFbOSp3J+N pgjT0B85eKScD/OZoYMDGHh/81voO0Maa97pXgR4PXIjPkgjLioyDVAW7xw0JZHKDABD 3BMw== X-Gm-Message-State: AC+VfDxxQlVX2NlOY6WIRuEtvH9gxHy/onPLym3Qx76bSXdMqNE49/X/ cQD/1SonYieqpmlKVcQTfqPG0XLtH2tHfA== X-Google-Smtp-Source: ACHHUZ6hfZaLmHw42Cxrg23lP/GifBvqpkt8XkSoz6wBF6keOZqgotlpnnoYwnjYfhgm2bFPHoK4hA== X-Received: by 2002:a05:622a:64d:b0:3ef:370b:e7e with SMTP id a13-20020a05622a064d00b003ef370b0e7emr51586486qtb.40.1684093953345; Sun, 14 May 2023 12:52:33 -0700 (PDT) Received: from wsfd-netdev15.ntdv.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id fa11-20020a05622a4ccb00b003f517e1fed2sm1069444qtb.15.2023.05.14.12.52.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 May 2023 12:52:32 -0700 (PDT) From: Xin Long To: network dev , tipc-discussion@lists.sourceforge.net Cc: davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Paolo Abeni , Jon Maloy , Tung Nguyen Subject: [PATCHv3 net 2/3] tipc: do not update mtu if msg_max is too small in mtu negotiation Date: Sun, 14 May 2023 15:52:28 -0400 Message-Id: X-Mailer: git-send-email 2.39.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 X-Patchwork-Delegate: kuba@kernel.org When doing link mtu negotiation, a malicious peer may send Activate msg with a very small mtu, e.g. 4 in Shuang's testing, without checking for the minimum mtu, l->mtu will be set to 4 in tipc_link_proto_rcv(), then n->links[bearer_id].mtu is set to 4294967228, which is a overflow of '4 - INT_H_SIZE - EMSG_OVERHEAD' in tipc_link_mss(). With tipc_link.mtu = 4, tipc_link_xmit() kept printing the warning: tipc: Too large msg, purging xmit list 1 5 0 40 4! tipc: Too large msg, purging xmit list 1 15 0 60 4! And with tipc_link_entry.mtu 4294967228, a huge skb was allocated in named_distribute(), and when purging it in tipc_link_xmit(), a crash was even caused: general protection fault, probably for non-canonical address 0x2100001011000dd: 0000 [#1] PREEMPT SMP PTI CPU: 0 PID: 0 Comm: swapper/0 Kdump: loaded Not tainted 6.3.0.neta #19 RIP: 0010:kfree_skb_list_reason+0x7e/0x1f0 Call Trace: skb_release_data+0xf9/0x1d0 kfree_skb_reason+0x40/0x100 tipc_link_xmit+0x57a/0x740 [tipc] tipc_node_xmit+0x16c/0x5c0 [tipc] tipc_named_node_up+0x27f/0x2c0 [tipc] tipc_node_write_unlock+0x149/0x170 [tipc] tipc_rcv+0x608/0x740 [tipc] tipc_udp_recv+0xdc/0x1f0 [tipc] udp_queue_rcv_one_skb+0x33e/0x620 udp_unicast_rcv_skb.isra.72+0x75/0x90 __udp4_lib_rcv+0x56d/0xc20 ip_protocol_deliver_rcu+0x100/0x2d0 This patch fixes it by checking the new mtu against tipc_bearer_min_mtu(), and not updating mtu if it is too small. Fixes: ed193ece2649 ("tipc: simplify link mtu negotiation") Reported-by: Shuang Li Signed-off-by: Xin Long Acked-by: Jon Maloy --- v2: - do the msg_max check against the min MTU early, as Tung suggested. v3: - move the change history under ---, as Tung suggested. --- net/tipc/link.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/tipc/link.c b/net/tipc/link.c index b3ce24823f50..2eff1c7949cb 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -2200,7 +2200,7 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb, struct tipc_msg *hdr = buf_msg(skb); struct tipc_gap_ack_blks *ga = NULL; bool reply = msg_probe(hdr), retransmitted = false; - u32 dlen = msg_data_sz(hdr), glen = 0; + u32 dlen = msg_data_sz(hdr), glen = 0, msg_max; u16 peers_snd_nxt = msg_next_sent(hdr); u16 peers_tol = msg_link_tolerance(hdr); u16 peers_prio = msg_linkprio(hdr); @@ -2239,6 +2239,9 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb, switch (mtyp) { case RESET_MSG: case ACTIVATE_MSG: + msg_max = msg_max_pkt(hdr); + if (msg_max < tipc_bearer_min_mtu(l->net, l->bearer_id)) + break; /* Complete own link name with peer's interface name */ if_name = strrchr(l->name, ':') + 1; if (sizeof(l->name) - (if_name - l->name) <= TIPC_MAX_IF_NAME) @@ -2283,8 +2286,8 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb, l->peer_session = msg_session(hdr); l->in_session = true; l->peer_bearer_id = msg_bearer_id(hdr); - if (l->mtu > msg_max_pkt(hdr)) - l->mtu = msg_max_pkt(hdr); + if (l->mtu > msg_max) + l->mtu = msg_max; break; case STATE_MSG: From patchwork Sun May 14 19:52:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 13240555 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48B58BE65 for ; Sun, 14 May 2023 19:52:38 +0000 (UTC) Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 652EC10E9 for ; Sun, 14 May 2023 12:52:35 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id d75a77b69052e-3f507edcaaaso19849341cf.2 for ; Sun, 14 May 2023 12:52:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684093954; x=1686685954; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jyvf4TEwS2vn6fQxq7OrYN1TDJ6PU+gnGXB81K2v2K0=; b=r99P5Df+3D3jsNP+KIrOr+xBLW2RECHOkLT4DUjVxA7bq2PuOnq7HAJTGv2Ax9+LL+ K5kDeHm8Cjj4YzcxJ7N1ZYZvCMgl3gEOG5fiMyQyHcGEsFtZTwIhMiR1GhzeXvBXzROw c9H9CtPHRXrIDhwLmTIw1UEIonku/fzVkfTq0Ci7d0TyaByjAv3ZxHc2RrYb6uIXK4W7 PaUdAjaBgriO5UoZpmr3DaR0msEwG9FyuwsD2c+9hqFreVd3tHZ6cn0jKi/3bjGWDZuO lNY1wkqIqTf4QV7vnptoJzQC5+CfdOfnh1Jn7sTfEGAZqc1fCAK9wLo13iX2hzuy6G1v CooQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684093954; x=1686685954; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jyvf4TEwS2vn6fQxq7OrYN1TDJ6PU+gnGXB81K2v2K0=; b=E/hHBQeX1CHSmgqkfIW8RSJU8GrWQTtiPiIV1yEcM8q1LIG8SkSroXjTt7LPX07rym aH7Ew6P55WbPK8c68NzcVqIQnAOMKuuyykbndgvgobILx5r1yKFJ7L95mma1NPGecgD3 WUtuJ+Z5b7mQGnzYpXSg15HCYWBOagWCnIeaWJW4hrh57mdCizpeBP0G2j8DQy221ds0 EFG0rEGXtQX2wAka504kRaX6axn4RHlSZSteyIEBd3t9SKkUa51hbD/VTtoelrLKSlFl GkcOEWjlwsu9pzTOptBkkgg/+r7sxFptF80QccuiN2jojEjURFU5vuCOZvmH9zLXx6gf VQ7A== X-Gm-Message-State: AC+VfDwoLYcV8UuaSUgwPioTalsSBE0yp5b+gjMqq1U351cHUY4+LGxk /FMl1T6XlgPGp+Q7slzCKyhVt8PZcQTd0A== X-Google-Smtp-Source: ACHHUZ5HO2jd3PRwDBjHw9uFywTkOFHu4MNDhdqs954iR5WE41qYYX1Cyn222mMEEF70mpJj2ReMYQ== X-Received: by 2002:a05:622a:1a21:b0:3ef:36d0:c06e with SMTP id f33-20020a05622a1a2100b003ef36d0c06emr58804137qtb.33.1684093954367; Sun, 14 May 2023 12:52:34 -0700 (PDT) Received: from wsfd-netdev15.ntdv.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id fa11-20020a05622a4ccb00b003f517e1fed2sm1069444qtb.15.2023.05.14.12.52.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 May 2023 12:52:34 -0700 (PDT) From: Xin Long To: network dev , tipc-discussion@lists.sourceforge.net Cc: davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Paolo Abeni , Jon Maloy , Tung Nguyen Subject: [PATCHv3 net 3/3] tipc: check the bearer min mtu properly when setting it by netlink Date: Sun, 14 May 2023 15:52:29 -0400 Message-Id: <401254e10285db58966f64793d4762c23a25f9d3.1684093873.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 X-Patchwork-Delegate: kuba@kernel.org Checking the bearer min mtu with tipc_udp_mtu_bad() only works for IPv4 UDP bearer, and IPv6 UDP bearer has a different value for the min mtu. This patch checks with encap_hlen + TIPC_MIN_BEARER_MTU for min mtu, which works for both IPv4 and IPv6 UDP bearer. Note that tipc_udp_mtu_bad() is still used to check media min mtu in __tipc_nl_media_set(), as m->mtu currently is only used by the IPv4 UDP bearer as its default mtu value. Fixes: 682cd3cf946b ("tipc: confgiure and apply UDP bearer MTU on running links") Signed-off-by: Xin Long Acked-by: Jon Maloy --- net/tipc/bearer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 0e9a29e1536b..53881406e200 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c @@ -1151,8 +1151,8 @@ int __tipc_nl_bearer_set(struct sk_buff *skb, struct genl_info *info) return -EINVAL; } #ifdef CONFIG_TIPC_MEDIA_UDP - if (tipc_udp_mtu_bad(nla_get_u32 - (props[TIPC_NLA_PROP_MTU]))) { + if (nla_get_u32(props[TIPC_NLA_PROP_MTU]) < + b->encap_hlen + TIPC_MIN_BEARER_MTU) { NL_SET_ERR_MSG(info->extack, "MTU value is out-of-range"); return -EINVAL;