From nobody Tue May 30 17:12:41 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QVzVK3x3mz4Xqt9; Tue, 30 May 2023 17:12:41 +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 4QVzVK3MkTz3jcg; Tue, 30 May 2023 17:12:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685466761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XRObmg/EG251oHyu7hTgyDJZcum9KbaadQmPCxoPSb0=; b=I2tqfsf8WZJLUOgpNcvUe1rK0SlmmmuK423/91V5nmwe55V4RyOs9O7iBMx5qaKozqe0Lo 16rZDpVyOdVO0kwlr1cWrCZtxGo6QsOOS0UYf9mlCXVli8C4FoNe+NK0dgmHg6cap3FK/+ TZ8E6o5RAMjEzKzSL0/dqAg4y0SCTWjwMZSGoqYSEmYP4qEHJgriac7o4z66uPJpzBfv77 ppQQ83rKw23zO203wUpib8QjGjjZpueNe0arjKyrTnk/inMhxlo0z89lEtacmIb8jwPdwD +lOMLRwJpuSWjGn6lIKUjRPr4dPB3y+HUFZAXKPR20fNaW8pHRH4s/N6Arbahw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685466761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XRObmg/EG251oHyu7hTgyDJZcum9KbaadQmPCxoPSb0=; b=eAIkDFOeDKZbJ2dXnXKl9QkJE4qB9wUD1wqjy/8dgAhsrnBrPAvdzsmwW89H8YQkK+w1VF PklsKJnELscTLApe4iJOZabt8X/Rj8rx35Pxar3GJ/4I7Rjacfcc74HNZtsbiWBS1h3fA+ sAWkw8DKRPvwQnZkFqIguuGajktnrusEdKJNc71YtmWp2Mnhv5e/UtsS9C4pyVX0SsE1ra vx90Y9wBa1LVXeMmAX/XlrDI2AnMCT3g1NRpS7aBiVbxJirJaTpa6w98zPeqUKBLATsCok azMtfjqVkh3PbA0S/6GFGeh3mRZWCPvUhj+hwGY5ELLjFrOApNm9QQZmm6BxBw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1685466761; a=rsa-sha256; cv=none; b=fMCheHURoNOtpCOALh6+dOh+K7gkgsALOIyoL2nDA7JO6oFrbKDLYRC4xok+N9PUMhmj/h o0eqBmFhrQbWSZ07TfzhKDw2oih5+FNoBjo4KxTRWWTjdPWjPuBlvghhNjWvnBexHrQD/d XUBBbhJ83fYUPa1/yup0qAPOOHPlyx9D//s0mKBrBpB/0mlIKypIcXiE2lyBh+Kap+5g/K 9utbp2zhQYTIGwplD7Ky4D1H9MQYtSPPu3BNm0SQfJEoWQoLat12z3y0IAzMtRkP0dsW5L ZBZV7WbAix7Zeat8dNTHSxHWOih76SALmLbdm1eeh7f+lH15F8JvfQw/xMDbaw== 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 4QVzVK2QzGz12V1; Tue, 30 May 2023 17:12:41 +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 34UHCfZ6030248; Tue, 30 May 2023 17:12:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34UHCfJD030247; Tue, 30 May 2023 17:12:41 GMT (envelope-from git) Date: Tue, 30 May 2023 17:12:41 GMT Message-Id: <202305301712.34UHCfJD030247@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Eric van Gyzen Subject: git: 8fa89d8b1904 - stable/12 - Fix NULL deref in ip_output during route change List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vangyzen X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 8fa89d8b190472778ed07db9d8937cb1ce7b44fc Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=8fa89d8b190472778ed07db9d8937cb1ce7b44fc commit 8fa89d8b190472778ed07db9d8937cb1ce7b44fc Author: Eric van Gyzen AuthorDate: 2023-05-23 09:46:42 +0000 Commit: Eric van Gyzen CommitDate: 2023-05-30 12:10:03 +0000 Fix NULL deref in ip_output during route change When changing the interface address during a route change, the rtentry's rt_ifa will be NULL briefly. Some parts of ip_output do not handle that NULL. In such case, re-validate the rtentry. That validation does not check the rt_ifa, but it does lock the route, which will synchronize with rtrequest1_fib_change. I would prefer to leave the rt_ifa pointer intact during the route change, but ip6_output is not fully protected by the net_epoch, so that could allow a use-after-free. ip6_output already handles a NULL rt_ifa. This is a direct commit to stable/12 because later branches have nexthop and do not appear to have this bug. PR: 271573 Reported by: Gaurav.Gandhi@dell.com Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D40236 --- sys/netinet/ip_output.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 399afa184999..93b41376f3c2 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -393,6 +393,10 @@ again: goto bad; } ia = ifatoia(rte->rt_ifa); + if (ia == NULL) { + /* race with rtrequest1_fib_change */ + goto again; + } ifp = rte->rt_ifp; counter_u64_add(rte->rt_pksent, 1); rt_update_ro_flags(ro);