lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 30 Oct 2006 10:51:58 -0800
From:	Jay Lan <jlan@...r.sgi.com>
To:	Oleg Nesterov <oleg@...sign.ru>
CC:	Andrew Morton <akpm@...l.org>,
	Shailabh Nagar <nagar@...son.ibm.com>,
	Balbir Singh <balbir@...ibm.com>, Jay Lan <jlan@....com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] xacct_add_tsk: fix pure theoretical ->mm use-after-free

Oleg Nesterov wrote:
> Paranoid fix. The task can free its ->mm after the 'if (p->mm)' check.

Why this change is necessary? This routine is indirectly invoked by
taskstats_exit_send() routine called inside do_exit():

do_exit()
{
        ...
        taskstats_exit_send(tsk, tidstats, group_dead, mycpu);
        taskstats_exit_free(tidstats);
        delayacct_tsk_exit(tsk);

        exit_mm(tsk);
        ...
}

The mm is freed in exit_mm(), right?

- jay


> 
> Signed-off-by: Oleg Nesterov <oleg@...sign.ru>
> 
> --- STATS/kernel/tsacct.c~3_mm	2006-10-27 01:03:26.000000000 +0400
> +++ STATS/kernel/tsacct.c	2006-10-29 21:46:12.000000000 +0300
> @@ -80,13 +80,17 @@ void bacct_add_tsk(struct taskstats *sta
>   */
>  void xacct_add_tsk(struct taskstats *stats, struct task_struct *p)
>  {
> +	struct mm_struct *mm;
> +
>  	/* convert pages-jiffies to Mbyte-usec */
>  	stats->coremem = jiffies_to_usecs(p->acct_rss_mem1) * PAGE_SIZE / MB;
>  	stats->virtmem = jiffies_to_usecs(p->acct_vm_mem1) * PAGE_SIZE / MB;
> -	if (p->mm) {
> +	mm = get_task_mm(p);
> +	if (mm) {
>  		/* adjust to KB unit */
> -		stats->hiwater_rss   = p->mm->hiwater_rss * PAGE_SIZE / KB;
> -		stats->hiwater_vm    = p->mm->hiwater_vm * PAGE_SIZE / KB;
> +		stats->hiwater_rss   = mm->hiwater_rss * PAGE_SIZE / KB;
> +		stats->hiwater_vm    = mm->hiwater_vm * PAGE_SIZE / KB;
> +		mmput(mm);
>  	}
>  	stats->read_char	= p->rchar;
>  	stats->write_char	= p->wchar;
> 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ