From nobody Mon Apr 25 07:23:43 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2ADA41A90DF6; Mon, 25 Apr 2022 07:23:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KmxMN1StQz3FYJ; Mon, 25 Apr 2022 07:23:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650871424; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2NBltglQt1ipLzx2OWpiaNiqdUDA3vsGgC/OYUYe4YY=; b=B+EHJdMngvwFPKVqRNaqyYMLa1nOOP/CZDwVdYF5vznQM0cLJTuolwT5HLgHPDJfUMmIar E6kod/Nnhz6ulO2D1obzgGDEPc0z+/cGv2QiBdxeaOCgA9hUgAjlvJx85Yyu5LsmVwsKxG GOGK42iTWG8oUww/7Vd380A7ZN/Vjov7qNbgpTDX2uLhJlINheVhrBNEQbnXcVQ2o6DMPF ozBdwoo+5mcsx9axnt57BBXZ8BeftuPTYOZnTg6LgUP35CFLJnKatJGRfeba3mZ7QQLsTz EQk3ADkJgfKlFHT6TtlAsKABwLIfT+Dle/6S8CxUK88imXl3PlrhZk9jAImtXw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E518716B13; Mon, 25 Apr 2022 07:23:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23P7NhNg065732; Mon, 25 Apr 2022 07:23:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23P7Nh3S065731; Mon, 25 Apr 2022 07:23:43 GMT (envelope-from git) Date: Mon, 25 Apr 2022 07:23:43 GMT Message-Id: <202204250723.23P7Nh3S065731@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: fe894a370556 - main - linux(4): Check that the thread tid in the thread group pid in linux_tdfind(). List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fe894a370556e5b173a8893cdcde6323ff79cc57 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650871424; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2NBltglQt1ipLzx2OWpiaNiqdUDA3vsGgC/OYUYe4YY=; b=wkBRiZSP5jMjLiT9wYHWF+VkjfcQbeJ8J/vJcBtUhRhMZVn/DozUhK3fIPTSzxu+khctSa 83Fb1I9f1PtEUmKXKl+f3rRD0VfS3x6vt2W4HUpeuPXzrXDbZYvdXDW27HVEm52Kjpetrs 2iucSqpvF2Wn4JtXURJrB1x3sEqLkcFctyHG/XLIoMYlOaGptAkZsrX5sQAfOEfpa2ehEB WxMr0oySn6IDW5fUQlU0M8PHi9XbRb/6G3337jlXm84mOVaPjjZdYBPTWj0pcfP1QXO40T gjlrd/E9qQ6GAn31JUwXNXIQvokfUQjKz3ba7IK2biaobHK4MuyjbKie4dcXCg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1650871424; a=rsa-sha256; cv=none; b=ybTMKp5CaZOrf07RDoypPG6bqO6icIRNZyvjz+JfRn16BxMOxJ7FUdFferEJ2kEreN+qb5 5E3Kwb2ImvY1DMItQg8AX6+4q+/Smh40wC3Xx7iY+EJ+2AXJDhnT3mzxc9eFW5lQTZvkmk UW+4Wm06zbCJ4oTlPTWzrj/SKMwSvim+nyiWc/nxLg18yGJKu+DFDBNYAxMIxIBziYbshG OyRkAW4/0z2wfIaA8qUgBd8gF4Ve1wJt5a1lEf9NM2RT1pmOtQ/pm3jVgIXsG0znSmx4+5 5jchjdq69W+VwDXvZZPQgLdES9YtrY8AelCQT1KKRtSrkme9Fnx0Pz34elimVA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=fe894a370556e5b173a8893cdcde6323ff79cc57 commit fe894a370556e5b173a8893cdcde6323ff79cc57 Author: Dmitry Chagin AuthorDate: 2022-04-25 07:21:51 +0000 Commit: Dmitry Chagin 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