1dc728923Sopenharmony_ciFrom d08ef863feae14e4710bf2026404e6c6e06db2be Mon Sep 17 00:00:00 2001
2dc728923Sopenharmony_ciFrom: zhanchengbin <zhanchengbin1@huawei.com>
3dc728923Sopenharmony_ciDate: Mon, 10 Oct 2022 16:56:58 +0800
4dc728923Sopenharmony_ciSubject: [PATCH] misc/fsck.c: Processes may kill other processes.
5dc728923Sopenharmony_ci
6dc728923Sopenharmony_ciI find a error in misc/fsck.c, if run the fsck -N command, processes
7dc728923Sopenharmony_cidon't execute, just show what would be done. However, the pid whose
8dc728923Sopenharmony_civalue is -1 is added to the instance_list list in the execute
9dc728923Sopenharmony_cifunction,if the kill_all function is called later, kill(-1, signum)
10dc728923Sopenharmony_ciis executed, Signals are sent to all processes except the number one
11dc728923Sopenharmony_ciprocess and itself. Other processes will be killed if they use the
12dc728923Sopenharmony_cidefault signal processing function.
13dc728923Sopenharmony_ci
14dc728923Sopenharmony_ciSigned-off-by: zhanchengbin <zhanchengbin1@huawei.com>
15dc728923Sopenharmony_ciSigned-off-by: Lukas Czerner <lczerner@redhat.com>
16dc728923Sopenharmony_ciReviewed-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
17dc728923Sopenharmony_ciReviewed-by: Darrick J. Wong <djwong@kernel.org>
18dc728923Sopenharmony_ciReviewed-by: Lukas Czerner <lczerner@redhat.com>
19dc728923Sopenharmony_ciSigned-off-by: Theodore Ts'o <tytso@mit.edu>
20dc728923Sopenharmony_ci---
21dc728923Sopenharmony_ci misc/fsck.c | 2 ++
22dc728923Sopenharmony_ci 1 file changed, 2 insertions(+)
23dc728923Sopenharmony_ci
24dc728923Sopenharmony_cidiff --git a/misc/fsck.c b/misc/fsck.c
25dc728923Sopenharmony_ciindex 1f6ec7d9..1769a106 100644
26dc728923Sopenharmony_ci--- a/misc/fsck.c
27dc728923Sopenharmony_ci+++ b/misc/fsck.c
28dc728923Sopenharmony_ci@@ -547,6 +547,8 @@ static int kill_all(int signum)
29dc728923Sopenharmony_ci 	for (inst = instance_list; inst; inst = inst->next) {
30dc728923Sopenharmony_ci 		if (inst->flags & FLAG_DONE)
31dc728923Sopenharmony_ci 			continue;
32dc728923Sopenharmony_ci+		if (inst->pid <= 0)
33dc728923Sopenharmony_ci+			continue;
34dc728923Sopenharmony_ci 		kill(inst->pid, signum);
35dc728923Sopenharmony_ci 		n++;
36dc728923Sopenharmony_ci 	}
37dc728923Sopenharmony_ci-- 
38dc728923Sopenharmony_ci2.38.1
39dc728923Sopenharmony_ci
40