git: e4de5369401e - stable/13 - linux(4): Check that the thread tid in the thread group pid in linux_tdfind().
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 17 Jun 2022 19:39:15 UTC
The branch stable/13 has been updated by dchagin:
URL: https://cgit.FreeBSD.org/src/commit/?id=e4de5369401e6146a8f051762c1956a7c8d235da
commit e4de5369401e6146a8f051762c1956a7c8d235da
Author: Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2022-04-25 07:21:51 +0000
Commit: Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2022-06-17 19:33:54 +0000
linux(4): Check that the thread tid in the thread group pid in linux_tdfind().
MFC after: 2 weeks
(cherry picked from commit fe894a370556e5b173a8893cdcde6323ff79cc57)
---
sys/compat/linux/linux_misc.c | 48 +++++++++++++++++++++----------------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index b1f465ef5a9e..096bbcbf0008 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -2717,34 +2717,34 @@ linux_tdfind(struct thread *td, lwpid_t tid, pid_t pid)
tdt = NULL;
if (tid == 0 || tid == td->td_tid) {
- tdt = td;
- PROC_LOCK(tdt->td_proc);
+ if (pid != -1 && td->td_proc->p_pid != pid)
+ return (NULL);
+ PROC_LOCK(td->td_proc);
+ return (td);
} else if (tid > PID_MAX)
- tdt = tdfind(tid, pid);
- else {
- /*
- * Initial thread where the tid equal to the pid.
- */
- p = pfind(tid);
- if (p != NULL) {
- if (SV_PROC_ABI(p) != SV_ABI_LINUX) {
- /*
- * p is not a Linuxulator process.
- */
- PROC_UNLOCK(p);
- return (NULL);
- }
- FOREACH_THREAD_IN_PROC(p, tdt) {
- em = em_find(tdt);
- if (tid == em->em_tid)
- return (tdt);
- }
+ return (tdfind(tid, pid));
+
+ /*
+ * Initial thread where the tid equal to the pid.
+ */
+ p = pfind(tid);
+ if (p != NULL) {
+ if (SV_PROC_ABI(p) != SV_ABI_LINUX ||
+ (pid != -1 && tid != pid)) {
+ /*
+ * p is not a Linuxulator process.
+ */
PROC_UNLOCK(p);
+ return (NULL);
}
- return (NULL);
+ FOREACH_THREAD_IN_PROC(p, tdt) {
+ em = em_find(tdt);
+ if (tid == em->em_tid)
+ return (tdt);
+ }
+ PROC_UNLOCK(p);
}
-
- return (tdt);
+ return (NULL);
}
void