From nobody Mon Nov 25 19:49:32 2024 Received: from out0-215.mail.aliyun.com (out0-215.mail.aliyun.com [140.205.0.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D8E81E412E for ; Thu, 24 Oct 2024 14:28:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.205.0.215 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729780125; cv=none; b=qyaiJHVC+zwWk+2RJ4V3z9/vqWfbRxi3hcWx8x+xERgxWe0rIJC7sTBOCmVUHaB2W/54Jvnbvs/YaAkVByngv9xD3PH5Smd9vxxleIdZhfGMsVDPa1bniA18dmO3mapknCXyBWt+O9aTfJgmb3013Syr7sa2er602l8jFIwqgAM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729780125; c=relaxed/simple; bh=KLD7jDp1bxtN/NU7xRa/QUaFd2d5eTWVnfaMQMq4sx4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kV6cIupfpKUwg2uelGXPFRpFW0XXCFy2Lvi7Go980UpQRgbIrQzzn7M01axE3yVd9J2YmDyXsf2j7+HcAII6vaQGMqsOm4M7/3ce8a9slu0aRj7pk1p4VGt987pmmTcnqa8EnBr3yDz5DXauib7Ca2+kLt133uVQZEARH8k45pI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com; spf=pass smtp.mailfrom=antgroup.com; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b=UjA1BCx0; arc=none smtp.client-ip=140.205.0.215 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antgroup.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b="UjA1BCx0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1729780117; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=Vju3PSxIcD7VxO0E+oMlNC+TNtVp16e3ZGllvv3Wkog=; b=UjA1BCx04keL7rQy4UTiTpaEpNvku8cKP+u4uIOppUEdyN8z2HISBaMI7vFqF5LISjop5Cu8J4T4g5sPUkv5FG6HipYL6IxPY1OGpPLN8DQxO5+FRy4gYpE74qikQcYcO3ibClGG8DzoafJoNIQNSN2rOgkVn2/CZXaoVMrtpEE= Received: from ubuntu..(mailfrom:tiwei.btw@antgroup.com fp:SMTPD_---.ZreBszp_1729780114 cluster:ay29) by smtp.aliyun-inc.com; Thu, 24 Oct 2024 22:28:36 +0800 From: "Tiwei Bie" To: richard@nod.at, anton.ivanov@cambridgegreys.com, johannes@sipsolutions.net Cc: , , "Tiwei Bie" Subject: [PATCH 1/4] um: Add os_set_pdeathsig helper function Date: Thu, 24 Oct 2024 22:28:25 +0800 Message-Id: <20241024142828.2612828-2-tiwei.btw@antgroup.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241024142828.2612828-1-tiwei.btw@antgroup.com> References: <20241024142828.2612828-1-tiwei.btw@antgroup.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This helper can be used to set the parent-death signal of the calling process to SIGKILL to ensure that the process will be killed if the UML kernel dies unexpectedly without proper cleanup. This helper will be used in the follow-up patches. Signed-off-by: Tiwei Bie --- arch/um/include/shared/os.h | 2 ++ arch/um/os-Linux/process.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index 09f8201de5db..d709a24dc6fc 100644 --- a/arch/um/include/shared/os.h +++ b/arch/um/include/shared/os.h @@ -216,6 +216,8 @@ extern int os_drop_memory(void *addr, int length); extern int can_drop_memory(void); extern int os_mincore(void *addr, unsigned long len); =20 +void os_set_pdeathsig(void); + /* execvp.c */ extern int execvp_noalloc(char *buf, const char *file, char *const argv[]); /* helper.c */ diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c index f20602e793d9..9f086f939420 100644 --- a/arch/um/os-Linux/process.c +++ b/arch/um/os-Linux/process.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -203,3 +204,8 @@ void init_new_thread_signals(void) set_handler(SIGIO); signal(SIGWINCH, SIG_IGN); } + +void os_set_pdeathsig(void) +{ + prctl(PR_SET_PDEATHSIG, SIGKILL); +} --=20 2.34.1 From nobody Mon Nov 25 19:49:32 2024 Received: from out187-24.us.a.mail.aliyun.com (out187-24.us.a.mail.aliyun.com [47.90.187.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF8611E8833 for ; Thu, 24 Oct 2024 14:28:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.90.187.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729780133; cv=none; b=XhHg1J0JzcJeEAxY7ywJHC+lqfKtwbwkpOCnOB7J83DawjNNC2jfqmAlVTC4KoXM7HH/jF64AcGQ8QjR8bkCIcwxN/858ICB6pNVlSfYm31Yitofmfgyt9ye1k3bUKDsb1I5RlhAAwFnaxQ5UVVKgwgSWdBWzn1wQgSfe800sK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729780133; c=relaxed/simple; bh=93aQHlKMBq3mxQqH3WygGtWzqoD93//12SPcyrkof9E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sNZ+ADhcWvUNrQrjNVhmXDOiiwIUkH7XEpb5eAWUn6qF6qnRuW/Fo4dcHCIfZtwzTC93DidjO/Wlo5EKPUu8PQ22v/UBdMl4p1Xl04/4ObJSKixXTQWSn9+zN9Pp/VP4TqSZiHEvHfLXJZXnS795EP1XyLauwEBgTqwzEaqcDJo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com; spf=pass smtp.mailfrom=antgroup.com; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b=xFifBZFG; arc=none smtp.client-ip=47.90.187.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antgroup.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b="xFifBZFG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1729780117; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=DW2X6x5nYJj0dxAEofhIKyQStzlJYeyPAOconukYPcI=; b=xFifBZFGfevXW1X/9XqfwjvzJirpgISM/W0cLGJUbiPKp88cLb8H1JbXbPqUORtEq4U6ZtU/XjKM7YLP2fYoJRXizHJXVmSPXfbZV2v64qo8wbwHmLMGeOH1MZOQKUjTwVnPybXJvHVDxoKwR0Ug3jV2p1cIY+wVsuMHJcffXXE= Received: from ubuntu..(mailfrom:tiwei.btw@antgroup.com fp:SMTPD_---.ZreBt-9_1729780116 cluster:ay29) by smtp.aliyun-inc.com; Thu, 24 Oct 2024 22:28:36 +0800 From: "Tiwei Bie" To: richard@nod.at, anton.ivanov@cambridgegreys.com, johannes@sipsolutions.net Cc: , , "Tiwei Bie" Subject: [PATCH 2/4] um: Set parent-death signal for ubd io thread/process Date: Thu, 24 Oct 2024 22:28:26 +0800 Message-Id: <20241024142828.2612828-3-tiwei.btw@antgroup.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241024142828.2612828-1-tiwei.btw@antgroup.com> References: <20241024142828.2612828-1-tiwei.btw@antgroup.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The ubd io thread is not really a traditional thread. Set the parent-death signal for it to ensure that it will be killed if the UML kernel dies unexpectedly without proper cleanup. Signed-off-by: Tiwei Bie --- arch/um/drivers/ubd_kern.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index 7f28ec1929dc..2b8d04e67600 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c @@ -1499,6 +1499,7 @@ int io_thread(void *arg) { int n, count, written, res; =20 + os_set_pdeathsig(); os_fix_helper_signals(); =20 while(1){ --=20 2.34.1 From nobody Mon Nov 25 19:49:32 2024 Received: from out0-193.mail.aliyun.com (out0-193.mail.aliyun.com [140.205.0.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B2D11C1758 for ; Thu, 24 Oct 2024 14:28:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.205.0.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729780125; cv=none; b=nBVl7UJrKFdHY1nrL9l1tY9DU05ClUm6BP23Bgn41tLXq+Dc10GbpM+b7dIzbOccf56iwnjBekbKz8GrUtGwzW28JMPSGs+L0tqWqkoQgnp4dWViRGBat/a8lje47Pz3DCadBy1M4LvzWILQbY3co0UWUZUpplTonFw4rLzqSyQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729780125; c=relaxed/simple; bh=oXy6rXpqqHRMqsCBsUClVbHN+aOv3TSBjb7kr7SgFEM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NifbVn7alL34R+x/wgmjGuOP118RLZBZKBx6Fk0XlBuZziHjVLpTefMFNTqZwQ/d7kDzMYWRiCf1RVTponEaMoZUpfxtLHHSMDTYdZsBac1Ja+DaaUq5vyo28L0DEivO4aBtFN+WQOx6AwmCRAshvZ0Ib+0uZqALZXIoVuATp5o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com; spf=pass smtp.mailfrom=antgroup.com; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b=o4Vnko3A; arc=none smtp.client-ip=140.205.0.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antgroup.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b="o4Vnko3A" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1729780118; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=o7nomrNF4UUPmRyX4jzl23OQWMT1pV1gEWGtKNbTeqs=; b=o4Vnko3AJULnvRhVZjHaiYWcOaoEAROuMn51S1xO5XJIiAjpkff8GeXXKnkhctQHO09yAyCK0ORw0Ho8zvAeI6UOVg1O/m9lJhE8DXg3b7fD3GNB6HSPEcpqFp6BHOUOEFfyt5Cyu0UNfIGRNr/6TMN5tfSlZZqv/CGbH9nBLpI= Received: from ubuntu..(mailfrom:tiwei.btw@antgroup.com fp:SMTPD_---.ZreBt-G_1729780117 cluster:ay29) by smtp.aliyun-inc.com; Thu, 24 Oct 2024 22:28:37 +0800 From: "Tiwei Bie" To: richard@nod.at, anton.ivanov@cambridgegreys.com, johannes@sipsolutions.net Cc: , , "Tiwei Bie" Subject: [PATCH 3/4] um: Set parent-death signal for write_sigio thread/process Date: Thu, 24 Oct 2024 22:28:27 +0800 Message-Id: <20241024142828.2612828-4-tiwei.btw@antgroup.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241024142828.2612828-1-tiwei.btw@antgroup.com> References: <20241024142828.2612828-1-tiwei.btw@antgroup.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The write_sigio thread is not really a traditional thread. Set the parent-death signal for it to ensure that it will be killed if the UML kernel dies unexpectedly without proper cleanup. Signed-off-by: Tiwei Bie --- arch/um/os-Linux/sigio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/um/os-Linux/sigio.c b/arch/um/os-Linux/sigio.c index 9e71794839e8..9aac8def4d63 100644 --- a/arch/um/os-Linux/sigio.c +++ b/arch/um/os-Linux/sigio.c @@ -55,6 +55,7 @@ static int write_sigio_thread(void *unused) int i, n, respond_fd; char c; =20 + os_set_pdeathsig(); os_fix_helper_signals(); fds =3D ¤t_poll; while (1) { --=20 2.34.1 From nobody Mon Nov 25 19:49:32 2024 Received: from out0-196.mail.aliyun.com (out0-196.mail.aliyun.com [140.205.0.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFD601D1745 for ; Thu, 24 Oct 2024 14:33:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.205.0.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729780442; cv=none; b=XvYgP09T3xrFrNK7zJF6tr6VCYm0W/fV8StcJ7scy0VzRL9VQercvOGKaXPyGRuOYNvhKta12JY9Bw8A7RjucCd1wgVf/IgHw/bZiPxEsK1J89oel/CPXygSh/Ef1ylCVN44jzxBn0BiZT6HMm0J/kAhp0e+WdoQPzU3hN2N3qI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729780442; c=relaxed/simple; bh=2KuxAKEg5UlIEaFA7fkjnIg4NOYGWc+teDk36qv6NiQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=K2vjtcpj6i8ngiBSZih5tzdmR5H/UWMWRqmXf9DFDSdb7idBLZ8B0vHc76U3nS77QsBuPV7lVh2uhV3/2oeC1uwV/Bl4/MgGQWI9VGejPUvcvLud+uPA2mx0sgK8lstJ+eB/4yKMPOkM/oXjHmTBWpTQwtHw/Mr4bu17xm1jC0Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com; spf=pass smtp.mailfrom=antgroup.com; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b=kyNKJM7o; arc=none smtp.client-ip=140.205.0.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antgroup.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b="kyNKJM7o" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1729780435; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=9F+/gG2/NpWN+fSAPQ0vZiXCLF44MabL2VbrE4Rm4ys=; b=kyNKJM7oGJevt94n5kxYDH22ZlY1cZHU4ug/4OWCUSeGRJ1CmU7LVUqGNTOCkBsuikJ1POKZdwEPFdWrzlQDSvyYhkW/IMWEU/wSZ/WTvxNjWDTxlfWlVGfYefiX63tJ4M0P6CEYQK7qkuAAWLQjqIsxQDk5qTMR2RHyAcY3mWc= Received: from ubuntu..(mailfrom:tiwei.btw@antgroup.com fp:SMTPD_---.ZreBt-P_1729780117 cluster:ay29) by smtp.aliyun-inc.com; Thu, 24 Oct 2024 22:28:37 +0800 From: "Tiwei Bie" To: richard@nod.at, anton.ivanov@cambridgegreys.com, johannes@sipsolutions.net Cc: , , "Tiwei Bie" Subject: [PATCH 4/4] um: Use os_set_pdeathsig helper in winch thread/process Date: Thu, 24 Oct 2024 22:28:28 +0800 Message-Id: <20241024142828.2612828-5-tiwei.btw@antgroup.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241024142828.2612828-1-tiwei.btw@antgroup.com> References: <20241024142828.2612828-1-tiwei.btw@antgroup.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since we have a helper now, let's switch to using it. It will make the code slightly more consistent. Signed-off-by: Tiwei Bie --- arch/um/drivers/chan_user.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c index 1434114b2f34..35f9beeb19b3 100644 --- a/arch/um/drivers/chan_user.c +++ b/arch/um/drivers/chan_user.c @@ -10,7 +10,6 @@ #include #include #include -#include #include "chan_user.h" #include #include @@ -162,7 +161,7 @@ static __noreturn int winch_thread(void *arg) int count; char c =3D 1; =20 - prctl(PR_SET_PDEATHSIG, SIGKILL); + os_set_pdeathsig(); =20 pty_fd =3D data->pty_fd; pipe_fd =3D data->pipe_fd; --=20 2.34.1