git: 7975f57b7e14 - main - uipc_shm: Fix double check for shmfd->shm_path
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 21 May 2024 13:41:07 UTC
The branch main has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=7975f57b7e14b146ca730421ef9e2094c242e9c0
commit 7975f57b7e14b146ca730421ef9e2094c242e9c0
Author: Ricardo Branco <rbranco@suse.de>
AuthorDate: 2024-05-20 13:09:08 +0000
Commit: Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-05-21 13:39:53 +0000
uipc_shm: Fix double check for shmfd->shm_path
Reviewed by: emaste, zlei
Pull Request: https://github.com/freebsd/freebsd-src/pull/1250
---
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 1136f34a6f85..c83455d1e70b 100644
--- a/sys/kern/uipc_shm.c
+++ b/sys/kern/uipc_shm.c
@@ -1910,21 +1910,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);
}