Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Sep 2023 08:57:12 GMT
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: f08b43610ea1 - releng/14.0 - pfsync: fix state leak
Message-ID:  <202309140857.38E8vCAJ076924@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch releng/14.0 has been updated by kp:

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

commit f08b43610ea1e7804fc5ddb1bd5f3c2b1fce18c3
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2023-09-08 09:21:12 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2023-09-14 08:56:49 +0000

    pfsync: fix state leak
    
    If we receive a state with a route-to interface name set and we can't
    find the interface we do not insert the state. However, in that case we
    must still clean up the state (and state keys).
    Do so, so we do not leak states.
    
    Approved by:    re (delphij)
    Reviewed by:    Kajetan Staszkiewicz <vegeta@tuxpowered.net>
    MFC after:      3 days
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D41779
    
    (cherry picked from commit f415a5c1bd56933367e42312731e4ec553e256ed)
    (cherry picked from commit 1bd8fa1dd0ba562c6b60fe1a316cfcca637d14d6)
---
 sys/netpfil/pf/if_pfsync.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c
index db448c9bbc48..e29c00fcb879 100644
--- a/sys/netpfil/pf/if_pfsync.c
+++ b/sys/netpfil/pf/if_pfsync.c
@@ -685,8 +685,10 @@ pfsync_state_import(union pfsync_state_union *sp, int flags, int msg_version)
 					printf("%s: unknown route interface: %s\n",
 					    __func__, sp->pfs_1400.rt_ifname);
 				if (flags & PFSYNC_SI_IOCTL)
-					return (EINVAL);
-				return (0);	/* skip this state */
+					error = EINVAL;
+				else
+					error = 0;
+				goto cleanup_keys;
 			}
 			break;
 		default:
@@ -734,6 +736,7 @@ pfsync_state_import(union pfsync_state_union *sp, int flags, int msg_version)
 
 cleanup:
 	error = ENOMEM;
+cleanup_keys:
 	if (skw == sks)
 		sks = NULL;
 	uma_zfree(V_pf_state_key_z, skw);



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