Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Mar 2021 06:28:48 GMT
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 99158c7fbd56 - main - if_wg: stop holding creds in wg_socket_init()
Message-ID:  <202103150628.12F6SmTr067509@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kevans:

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

commit 99158c7fbd565e0898ee31f47bbdf091e0c853d8
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2021-03-15 06:21:25 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2021-03-15 06:21:25 +0000

    if_wg: stop holding creds in wg_socket_init()
    
    We're now xlocked when we create sockets, so we're now guaranteed that
    the creds won't be released out from underneath us over in
    wg_prison_remove().
---
 sys/dev/if_wg/if_wg.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sys/dev/if_wg/if_wg.c b/sys/dev/if_wg/if_wg.c
index c0b3ecdaa002..4d5c66133a8f 100644
--- a/sys/dev/if_wg/if_wg.c
+++ b/sys/dev/if_wg/if_wg.c
@@ -953,9 +953,8 @@ wg_socket_init(struct wg_softc *sc, in_port_t port)
 	sx_assert(&sc->sc_lock, SX_XLOCKED);
 
 	td = curthread;
-	if (sc->sc_ucred == NULL)
+	if ((cred = sc->sc_ucred) == NULL)
 		return (EBUSY);
-	cred = crhold(sc->sc_ucred);
 
 	/*
 	 * For socket creation, we use the creds of the thread that created the
@@ -993,7 +992,6 @@ wg_socket_init(struct wg_softc *sc, in_port_t port)
 		wg_socket_set(sc, so4, so6);
 	}
 out:
-	crfree(cred);
 	return (rc);
 }
 



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