[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <470ea2ee-54fd-3dd5-2500-36fb82665c11@huawei.com>
Date: Fri, 30 Sep 2022 09:42:52 +0800
From: zhanchengbin <zhanchengbin1@...wei.com>
To: Lukas Czerner <lczerner@...hat.com>
CC: Theodore Ts'o <tytso@....edu>, <linux-ext4@...r.kernel.org>,
<liuzhiqiang26@...wei.com>, linfeilong <linfeilong@...wei.com>
Subject: Re: [bug report] misc/fsck.c: Processes may kill other processes.
On 2022/9/29 19:28, Lukas Czerner wrote:
> Hi,
>
> indeed we'd like to avoid killing the instance that was not ran because
> of noexecute. Can you try the following patch?
>
> Thanks!
> -Lukas
Yes, you're right, I think we can fix it in this way.
diff --git a/misc/fsck.c b/misc/fsck.c
index 1f6ec7d9..91edbf17 100644
--- a/misc/fsck.c
+++ b/misc/fsck.c
@@ -547,6 +547,8 @@ static int kill_all(int signum)
for (inst = instance_list; inst; inst = inst->next) {
if (inst->flags & FLAG_DONE)
continue;
+ if (inst->pid == -1)
+ continue;
kill(inst->pid, signum);
n++;
}
>
>
> diff --git a/misc/fsck.c b/misc/fsck.c
> index 1f6ec7d9..8fae7730 100644
> --- a/misc/fsck.c
> +++ b/misc/fsck.c
> @@ -497,9 +497,10 @@ static int execute(const char *type, const char *device, const char *mntpt,
> }
>
> /* Fork and execute the correct program. */
> - if (noexecute)
> + if (noexecute) {
> pid = -1;
> - else if ((pid = fork()) < 0) {
> + inst->flags |= FLAG_DONE;
> + } else if ((pid = fork()) < 0) {
> perror("fork");
> free(inst);
> return errno;
> @@ -544,6 +545,9 @@ static int kill_all(int signum)
> struct fsck_instance *inst;
> int n = 0;
>
> + if (noexecute)
> + return 0;
> +
> for (inst = instance_list; inst; inst = inst->next) {
> if (inst->flags & FLAG_DONE)
> continue;
regards,
Zhan Chengbin
Powered by blists - more mailing lists