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

!1672 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/F3MDGNSS4NARSSKD53VIBRG3ZXPCVNL4/ 
 
https://gitee.com/openeuler/kernel/issues/I7LEZX 
 
Link:https://gitee.com/openeuler/kernel/pulls/1672 

Reviewed-by: Jialin Zhang <zhangjialin11@huawei.com> 
Signed-off-by: Jialin Zhang <zhangjialin11@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.
先完成此消息的编辑!
想要评论请 注册