Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 May 2021 10:31:09 GMT
From:      "Alexander V. Chernikov" <melifaro@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: d40def01a4f4 - stable/13 - Fix a use after free in update_rtm_from_rc().
Message-ID:  <202105301031.14UAV9Vm014705@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by melifaro:

URL: https://cgit.FreeBSD.org/src/commit/?id=d40def01a4f4fed65329f4a74792cad3134eeb29

commit d40def01a4f4fed65329f4a74792cad3134eeb29
Author:     Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2021-05-14 16:03:08 +0000
Commit:     Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2021-05-30 10:30:53 +0000

    Fix a use after free in update_rtm_from_rc().
    
    update_rtm_from_rc() calls update_rtm_from_info() internally.
    The latter one may update provided prtm pointer with a new rtm.
    Reassign rtm from prtm afeter calling update_rtm_from_info() to
     avoid touching the freed rtm.
    
    PR:             255871
    Submitted by:   lylgood@foxmail.com
---
 sys/net/rtsock.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 6930bd167ac1..3cb645f42e4c 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -976,6 +976,7 @@ update_rtm_from_rc(struct rt_addrinfo *info, struct rt_msghdr **prtm,
 	if ((error = update_rtm_from_info(info, prtm, alloc_len)) != 0)
 		return (error);
 
+	rtm = *prtm;
 	rtm->rtm_flags = rc->rc_rt->rte_flags | nhop_get_rtflags(nh);
 	if (rtm->rtm_flags & RTF_GWFLAG_COMPAT)
 		rtm->rtm_flags = RTF_GATEWAY | 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105301031.14UAV9Vm014705>