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