From owner-dev-commits-src-all@freebsd.org Fri May 7 20:49:52 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BD6AF63C32D; Fri, 7 May 2021 20:49:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FcMyS4wGdz3M7L; Fri, 7 May 2021 20:49:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9C07C12541; Fri, 7 May 2021 20:49:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 147KnqP5052497; Fri, 7 May 2021 20:49:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 147KnqXw052496; Fri, 7 May 2021 20:49:52 GMT (envelope-from git) Date: Fri, 7 May 2021 20:49:52 GMT Message-Id: <202105072049.147KnqXw052496@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: aad59c79f5f2 - main - Fix panic when trying to delete non-existent gateway in multipath route. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: aad59c79f5f2b1881c6613b1b0b6ac7be8eb474b Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 May 2021 20:49:52 -0000 The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=aad59c79f5f2b1881c6613b1b0b6ac7be8eb474b commit aad59c79f5f2b1881c6613b1b0b6ac7be8eb474b Author: Alexander V. Chernikov AuthorDate: 2021-05-07 20:36:50 +0000 Commit: Alexander V. Chernikov CommitDate: 2021-05-07 20:41:31 +0000 Fix panic when trying to delete non-existent gateway in multipath route. IF non-existend gateway was specified, the code responsible for calculating an updated nexthop group, returned the same already-used nexthop group. After the route table update, the operation result contained the same old & new nexthop groups. Thus, the code responsible for decomposing the notification to the list of simple nexthop-level notifications, was not able to find any differences. As a result, it hasn't updated any of the "simple" notification fields, resulting in empty rtentry pointer. This empty pointer was the direct reason of a panic. Fix the problem by returning ESRCH when the new nexthop group is the same as the old one after applying gateway filter. Reported by: Michael PR: 255665 MFC after: 3 days --- sys/net/route/mpath_ctl.c | 11 ++++++++--- sys/net/route/nhgrp_ctl.c | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sys/net/route/mpath_ctl.c b/sys/net/route/mpath_ctl.c index 5632750f466d..8351437e34c6 100644 --- a/sys/net/route/mpath_ctl.c +++ b/sys/net/route/mpath_ctl.c @@ -181,10 +181,15 @@ del_route_mpath(struct rib_head *rh, struct rt_addrinfo *info, if ((info->rti_info[RTAX_GATEWAY] == NULL) && (info->rti_filter == NULL)) return (ESRCH); - error = nhgrp_get_filtered_group(rh, nhg, gw_filter_func, (void *)&ri, - &rnd); - if (error == 0) + error = nhgrp_get_filtered_group(rh, nhg, gw_filter_func, (void *)&ri, &rnd); + if (error == 0) { + if (rnd.rnd_nhgrp == nhg) { + /* No gateway match, unreference new group and return. */ + nhop_free_any(rnd.rnd_nhop); + return (ESRCH); + } error = change_route_nhop(rh, rt, info, &rnd, rc); + } return (error); } diff --git a/sys/net/route/nhgrp_ctl.c b/sys/net/route/nhgrp_ctl.c index 49866499ac86..9f1f3a5b4bc4 100644 --- a/sys/net/route/nhgrp_ctl.c +++ b/sys/net/route/nhgrp_ctl.c @@ -578,9 +578,9 @@ nhgrp_get_group(struct rib_head *rh, struct weightened_nhop *wn, int num_nhops, } /* - * Creates new nexthop group based on @src group with the nexthops defined in bitmask - * @nhop_mask removed. - * Returns referenced nexthop group or NULL on failure. + * Creates new nexthop group based on @src group without the nexthops + * chosen by @flt_func. + * Returns 0 on success, storring the reference nhop group/object in @rnd. */ int nhgrp_get_filtered_group(struct rib_head *rh, const struct nhgrp_object *src,