From c864c8cf08a9dc197612d5ffffd239aa72de7c97 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Fri, 24 Sep 2021 03:14:56 +0300 Subject: [PATCH] aio_aqueue(): avoid ucred leak on failure path Approved by: so Security: FreeBSD-SA-22:10.aio PR: 258698 (cherry picked from commit 45c2c7c484de7747014492b17ff89e323ee66496) (cherry picked from commit 9499d3c1e40dfeb1f63f61af7cdf25ee27f9a2ec) --- sys/kern/vfs_aio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c index 9b45a06c5f9..80b7c3ac94e 100644 --- a/sys/kern/vfs_aio.c +++ b/sys/kern/vfs_aio.c @@ -1698,7 +1698,7 @@ aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj, else error = fo_aio_queue(fp, job); if (error) - goto err3; + goto err4; AIO_LOCK(ki); job->jobflags &= ~KAIOCB_QUEUEING; @@ -1719,6 +1719,8 @@ aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj, AIO_UNLOCK(ki); return (0); +err4: + crfree(job->cred); err3: if (fp) fdrop(fp, td); -- 2.45.0