git: fe894a370556 - main - 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: Mon, 25 Apr 2022 07:23:43 UTC
The branch main has been updated by dchagin:
URL: https://cgit.FreeBSD.org/src/commit/?id=fe894a370556e5b173a8893cdcde6323ff79cc57
commit fe894a370556e5b173a8893cdcde6323ff79cc57
Author: Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2022-04-25 07:21:51 +0000
Commit: Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2022-04-25 07:21:51 +0000
linux(4): Check that the thread tid in the thread group pid in linux_tdfind().
MFC after: 2 weeks
---
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 0579ac1a03ce..252c6e0737c0 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -2710,34 +2710,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