未验证 提交 5b5909d1 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!1663 tty: fix pid memleak in disassociate_ctty()

Merge Pull Request from: @ci-robot 
 
PR sync from: Yi Yang <yiyang13@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/FA2B7TOM3KI377VPITPMUXX6FWMNJ2NK/ 
 
https://gitee.com/openeuler/kernel/issues/I7PBYJ 
 
Link:https://gitee.com/openeuler/kernel/pulls/1663 

Reviewed-by: Liu YongQiang <liuyongqiang13@huawei.com> 
Signed-off-by: Liu YongQiang <liuyongqiang13@huawei.com> 
......@@ -308,6 +308,18 @@ void disassociate_ctty(int on_exit)
spin_unlock_irqrestore(&tty->ctrl_lock, flags);
tty_unlock(tty);
tty_kref_put(tty);
/*
* Race with tty_signal_session_leader(), current->signal
* ->tty_old_pgrp may be reassigned, put_pid() again to ensure
* the pid does not leak memory.
*/
if (on_exit) {
spin_lock_irq(&current->sighand->siglock);
put_pid(current->signal->tty_old_pgrp);
current->signal->tty_old_pgrp = NULL;
spin_unlock_irq(&current->sighand->siglock);
}
}
/* Now clear signal->tty under the lock */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册