From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161293AbXCNOlI (ORCPT ); Wed, 14 Mar 2007 10:41:08 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1161304AbXCNOlI (ORCPT ); Wed, 14 Mar 2007 10:41:08 -0400 Received: from ebiederm.dsl.xmission.com ([166.70.28.69]:53159 "EHLO ebiederm.dsl.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161293AbXCNOlG (ORCPT ); Wed, 14 Mar 2007 10:41:06 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: "Catalin Marinas" Cc: "Linux Kernel Mailing List" Subject: Re: Possible "struct pid" leak from tty_io.c References: Date: Wed, 14 Mar 2007 08:40:43 -0600 In-Reply-To: (Catalin Marinas's message of "Wed, 14 Mar 2007 09:59:21 +0000") Message-ID: User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org How does this look? I don't have the setup to test this easily, but this bit makes seems to make sense. I will keep code reviewing and see if I can convince myself that this is correct or incorrect in the mean time... diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index e453268..fc125ac 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -1376,6 +1376,8 @@ static void do_tty_hangup(struct work_struct *work) read_unlock(&tasklist_lock); tty->flags = 0; + put_pid(tty->session); + put_pid(tty->pgrp); tty->session = NULL; tty->pgrp = NULL; tty->ctrl_status = 0; @@ -3841,6 +3843,8 @@ static struct pid *__proc_set_tty(struct task_struct *tsk, struct tty_struct *tt { struct pid *old_pgrp; if (tty) { + put_pid(tty->session); + put_pid(tty->pgrp); tty->session = get_pid(task_session(tsk)); tty->pgrp = get_pid(task_pgrp(tsk)); }