From nobody Thu Mar 31 17:50:41 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 A28601A56C0C; Thu, 31 Mar 2022 17:50:42 +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 4KTrSK3nlxz4s4T; Thu, 31 Mar 2022 17:50:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648749041; 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=G7OY6QhIfjcc+7BNsPk0oyfbU4FaihoJznqLJcpXdOM=; b=H+5G2QCKxihw017A3MmLfpXp3Jnay+7RGEvkXafT3yqCtfKqJZSDmxQU7FEPg0emjihJTP C4EzMliX4mvtfdgotnUWXY/kAEdVSGq+z85xStKWXrfEEksK5SPiSaB8xhn6l5c9SolCEY hmWXe0WVrX+rAbZxwyUQW+o6T4BLDYYKookNfbMyoqpNpTgydqn0SucU9XrH45hunoKc4W kUlPNxnOAUB/MEJtolfJZYgJwU2eGHzQQDWUMBHVE7ou7DoC9jghd4ASJYS6nTX9amAEwa UNYrc1xZnVeKY95/fCHMRgcnSTH9NUsO8kkxQGoqFXuECSAfIBjTDOcfdpICEg== 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 57AEA2BEEC; Thu, 31 Mar 2022 17:50:41 +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 22VHofOg038728; Thu, 31 Mar 2022 17:50:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22VHofTi038727; Thu, 31 Mar 2022 17:50:41 GMT (envelope-from git) Date: Thu, 31 Mar 2022 17:50:41 GMT Message-Id: <202203311750.22VHofTi038727@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: 4e3aefb923ac - main - linux(4): Fixup waitid handling P_PGID idtype. 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: 4e3aefb923ac1bd8e2a707b00239f171eab1231b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648749041; 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=G7OY6QhIfjcc+7BNsPk0oyfbU4FaihoJznqLJcpXdOM=; b=CYDA/ThhwVxNEz7q9VPCvJgD+J8f88k4PwkpTiWJ2d0pdOSbpL0HO/tZR4ojTuLAjElNvZ pYcFjXKHK6zmGetQ9gMmTJAv9pvjzYaMpP+7dzo66V24RKryHNrrUlYDJ0VpIpl+MEXt35 vOEUdRWsK2sNLnUEngzUUoG6+4I1vhs4HoW+zK0mwysvwu7ZW8VgeMZJAiqSS7iEpdbGtN Dg/fchOm6A3NTLxZ8Qax2mrtkiBsxBT360wM2pmfJk56+8eWjSTEbw7+f0uSuGv20j5Nst iuuX48slaGGpRJZpUXxTZFAS1KBKqouy2Gls+/5p8H06uSeQ8thIm3bXFhX2QA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648749041; a=rsa-sha256; cv=none; b=gXQ5OMUAuhWTdcfAz3PYlJMGc+mL6gBfy2TsA/qScuRhglOuSRksmXiqPAyEt1FmuinQox s1kQ8Et9uLD3ow2GIBNjDBnW+gmsv215HtS+av7PBTdmuMStEDvMRgXi1yeB465AO7cVG5 BIMrobIFh74aprqgHWdY1EQTfdI4GZVJse89i6h47D/z90bzWo9oseyE3woCl9OU3gG1V/ BjdEzPJ4u8c4BjugO4WiJlT2iI57z/OGlGHgvwpe4aJL8XB4k00RQK4NIGnUjd4nKv+3Gk f2wcDIDq3yEKLnDA+O3LfQJbqVkA8/YbXqZuiE0/1Nj2QvsrFIFSVqf0H07DwQ== 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=4e3aefb923ac1bd8e2a707b00239f171eab1231b commit 4e3aefb923ac1bd8e2a707b00239f171eab1231b Author: Dmitry Chagin AuthorDate: 2022-03-31 17:44:00 +0000 Commit: Dmitry Chagin CommitDate: 2022-03-31 17:44:00 +0000 linux(4): Fixup waitid handling P_PGID idtype. Since Linux 5.4, if id is zero, then wait for any child that is in the same process grop as the caller's process group. Differential revision: https://reviews.freebsd.org/D31567 MFC after: 2 weeks --- sys/compat/linux/linux_mib.h | 2 ++ sys/compat/linux/linux_misc.c | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sys/compat/linux/linux_mib.h b/sys/compat/linux/linux_mib.h index 61a3a38a23ae..e2064903b28b 100644 --- a/sys/compat/linux/linux_mib.h +++ b/sys/compat/linux/linux_mib.h @@ -60,8 +60,10 @@ int linux_kernver(struct thread *td); #define LINUX_KERNVER_2004000 LINUX_KERNVER(2,4,0) #define LINUX_KERNVER_2006000 LINUX_KERNVER(2,6,0) #define LINUX_KERNVER_2006039 LINUX_KERNVER(2,6,39) +#define LINUX_KERNVER_5004000 LINUX_KERNVER(5,4,0) #define linux_use26(t) (linux_kernver(t) >= LINUX_KERNVER_2006000) +#define linux_use54(t) (linux_kernver(t) >= LINUX_KERNVER_5004000) extern int linux_debug; extern int linux_default_openfiles; diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 260eef258ddb..a4e5f913d03b 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -1097,6 +1097,8 @@ linux_waitid(struct thread *td, struct linux_waitid_args *args) { idtype_t idtype; int error, options; + struct proc *p; + pid_t id; if (args->options & ~(LINUX_WNOHANG | LINUX_WNOWAIT | LINUX_WEXITED | LINUX_WSTOPPED | LINUX_WCONTINUED | __WCLONE | __WNOTHREAD | __WALL)) @@ -1108,6 +1110,7 @@ linux_waitid(struct thread *td, struct linux_waitid_args *args) options |= WEXITED | WTRAPPED | WUNTRACED | WCONTINUED | WLINUXCLONE; + id = args->id; switch (args->idtype) { case LINUX_P_ALL: idtype = P_ALL; @@ -1118,7 +1121,12 @@ linux_waitid(struct thread *td, struct linux_waitid_args *args) idtype = P_PID; break; case LINUX_P_PGID: - if (args->id <= 0) + if (linux_use54(td) && args->id == 0) { + p = td->td_proc; + PROC_LOCK(p); + id = p->p_pgid; + PROC_UNLOCK(p); + } else if (args->id <= 0) return (EINVAL); idtype = P_PGID; break; @@ -1129,7 +1137,7 @@ linux_waitid(struct thread *td, struct linux_waitid_args *args) return (EINVAL); } - error = linux_common_wait(td, idtype, args->id, NULL, options, + error = linux_common_wait(td, idtype, id, NULL, options, args->rusage, args->info); td->td_retval[0] = 0;