git: bd208ed0ab94 - stable/14 - uipc_shm: Fix double check for shmfd->shm_path
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 01 Aug 2024 17:35:58 UTC
The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=bd208ed0ab94d92443feff6eea2240f498deed65 commit bd208ed0ab94d92443feff6eea2240f498deed65 Author: Ricardo Branco <rbranco@suse.de> AuthorDate: 2024-05-20 13:09:08 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2024-08-01 17:34:50 +0000 uipc_shm: Fix double check for shmfd->shm_path Reviewed by: emaste, zlei Pull Request: https://github.com/freebsd/freebsd-src/pull/1250 (cherry picked from commit 7975f57b7e14b146ca730421ef9e2094c242e9c0) --- sys/kern/uipc_shm.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index 0bfbc636e405..20dbe59e2a96 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -1909,21 +1909,19 @@ shm_fill_kinfo_locked(struct shmfd *shmfd, struct kinfo_file *kif, bool list) kif->kf_un.kf_file.kf_file_mode = S_IFREG | shmfd->shm_mode; kif->kf_un.kf_file.kf_file_size = shmfd->shm_size; if (shmfd->shm_path != NULL) { - if (shmfd->shm_path != NULL) { - path = shmfd->shm_path; - pr_path = curthread->td_ucred->cr_prison->pr_path; - if (strcmp(pr_path, "/") != 0) { - /* Return the jail-rooted pathname. */ - pr_pathlen = strlen(pr_path); - visible = strncmp(path, pr_path, pr_pathlen) - == 0 && path[pr_pathlen] == '/'; - if (list && !visible) - return (EPERM); - if (visible) - path += pr_pathlen; - } - strlcpy(kif->kf_path, path, sizeof(kif->kf_path)); + path = shmfd->shm_path; + pr_path = curthread->td_ucred->cr_prison->pr_path; + if (strcmp(pr_path, "/") != 0) { + /* Return the jail-rooted pathname. */ + pr_pathlen = strlen(pr_path); + visible = strncmp(path, pr_path, pr_pathlen) == 0 && + path[pr_pathlen] == '/'; + if (list && !visible) + return (EPERM); + if (visible) + path += pr_pathlen; } + strlcpy(kif->kf_path, path, sizeof(kif->kf_path)); } return (0); }