[1/3] Revert "do_SAK: Don't recursively take the tasklist_lock"

Submitted by Kirill Tkhai on Jan. 18, 2018, 9:48 a.m.

Details

Message ID 151626890620.1120.8371403495824228307.stgit@localhost.localdomain
State New
Series "Series without cover letter"
Headers show

Commit Message

Kirill Tkhai Jan. 18, 2018, 9:48 a.m.
This reverts commit 20ac94378de5.

send_sig() does not take tasklist_lock for a long time,
so this commit and the problem it solves are not relevant
anymore.

Also, the problem of force_sig() is it clears SIGNAL_UNKILLABLE
flag, thus even global init may be killed by __do_SAK(),
which is definitely not the expected behavior.

Came from discussion in "tty: Iterate only thread group leaders in __do_SAK()"
https://lkml.org/lkml/2018/1/11/492

https://jira.sw.ru/browse/PSBM-80340

Suggested-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/tty/tty_io.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 719e6edb136c..b46b357a3b76 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3043,7 +3043,7 @@  void __do_SAK(struct tty_struct *tty)
 			printk(KERN_NOTICE "SAK: killed process %d"
 			    " (%s): fd#%d opened to the tty\n",
 				    task_pid_nr(p), p->comm, i - 1);
-			force_sig(SIGKILL, p);
+			send_sig(SIGKILL, p, 1);
 		}
 		task_unlock(p);
 	} while_each_thread(g, p);

Comments

Pavel Tikhomirov Jan. 18, 2018, 2:55 p.m.
Now I see that SIGKILL will kill all threads.
Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>

On 01/18/2018 12:48 PM, Kirill Tkhai wrote:
> This reverts commit 20ac94378de5.
> 
> send_sig() does not take tasklist_lock for a long time,
> so this commit and the problem it solves are not relevant
> anymore.
> 
> Also, the problem of force_sig() is it clears SIGNAL_UNKILLABLE
> flag, thus even global init may be killed by __do_SAK(),
> which is definitely not the expected behavior.
> 
> Came from discussion in "tty: Iterate only thread group leaders in __do_SAK()"
> https://lkml.org/lkml/2018/1/11/492
> 
> https://jira.sw.ru/browse/PSBM-80340
> 
> Suggested-by: Oleg Nesterov <oleg@redhat.com>
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> ---
>   drivers/tty/tty_io.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
> index 719e6edb136c..b46b357a3b76 100644
> --- a/drivers/tty/tty_io.c
> +++ b/drivers/tty/tty_io.c
> @@ -3043,7 +3043,7 @@ void __do_SAK(struct tty_struct *tty)
>   			printk(KERN_NOTICE "SAK: killed process %d"
>   			    " (%s): fd#%d opened to the tty\n",
>   				    task_pid_nr(p), p->comm, i - 1);
> -			force_sig(SIGKILL, p);
> +			send_sig(SIGKILL, p, 1);
>   		}
>   		task_unlock(p);
>   	} while_each_thread(g, p);
>
Kirill Tkhai Jan. 18, 2018, 2:55 p.m.
On 18.01.2018 17:55, Pavel Tikhomirov wrote:
> Now I see that SIGKILL will kill all threads.
> Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>

Thanks, Pasha.

Kirill

> On 01/18/2018 12:48 PM, Kirill Tkhai wrote:
>> This reverts commit 20ac94378de5.
>>
>> send_sig() does not take tasklist_lock for a long time,
>> so this commit and the problem it solves are not relevant
>> anymore.
>>
>> Also, the problem of force_sig() is it clears SIGNAL_UNKILLABLE
>> flag, thus even global init may be killed by __do_SAK(),
>> which is definitely not the expected behavior.
>>
>> Came from discussion in "tty: Iterate only thread group leaders in __do_SAK()"
>> https://lkml.org/lkml/2018/1/11/492
>>
>> https://jira.sw.ru/browse/PSBM-80340
>>
>> Suggested-by: Oleg Nesterov <oleg@redhat.com>
>> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
>> ---
>>   drivers/tty/tty_io.c |    2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
>> index 719e6edb136c..b46b357a3b76 100644
>> --- a/drivers/tty/tty_io.c
>> +++ b/drivers/tty/tty_io.c
>> @@ -3043,7 +3043,7 @@ void __do_SAK(struct tty_struct *tty)
>>               printk(KERN_NOTICE "SAK: killed process %d"
>>                   " (%s): fd#%d opened to the tty\n",
>>                       task_pid_nr(p), p->comm, i - 1);
>> -            force_sig(SIGKILL, p);
>> +            send_sig(SIGKILL, p, 1);
>>           }
>>           task_unlock(p);
>>       } while_each_thread(g, p);
>>
>