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-next>] [day] [month] [year] [list]
Message-ID: <20090615223333.GA8734@x200.localdomain>
Date:	Tue, 16 Jun 2009 02:33:33 +0400
From:	Alexey Dobriyan <adobriyan@...il.com>
To:	akpm@...ux-foundation.org
Cc:	linux-kernel@...r.kernel.org, stefani@...bold.net,
	a.p.zijlstra@...llo.nl, ebiederm@...ssion.com, mingo@...e.hu
Subject: Re: + procfs-provide-stack-information-for-threads-v08.patch added
	to -mm tree

On Mon, Jun 15, 2009 at 03:02:05PM -0700, akpm@...ux-foundation.org wrote:
>      procfs-provide-stack-information-for-threads-v08.patch
> --- a/fs/proc/array.c~procfs-provide-stack-information-for-threads-v08

> +++ a/fs/proc/array.c
> @@ -321,6 +321,54 @@ static inline void task_context_switch_c
>  			p->nivcsw);
>  }
>  
> +static inline unsigned long get_stack_usage_in_bytes(struct vm_area_struct *vma,
> +					struct task_struct *p)
> +{
> +	unsigned long	i;
> +	struct page	*page;
> +	unsigned long	stkpage;
> +
> +	stkpage = KSTK_ESP(p) & PAGE_MASK;
> +
> +#ifdef CONFIG_STACK_GROWSUP
> +	for (i = vma->vm_end; i-PAGE_SIZE > stkpage; i -= PAGE_SIZE) {
> +
> +		page = follow_page(vma, i-PAGE_SIZE, 0);

How can this work?

If stack page got swapped out, you'll get smaller than actual result.

> +
> +		if (!IS_ERR(page) && page)
> +			break;
> +	}
> +	return i - (p->stack_start & PAGE_MASK);
> +#else
> +	for (i = vma->vm_start; i+PAGE_SIZE <= stkpage; i += PAGE_SIZE) {
> +
> +		page = follow_page(vma, i, 0);
> +
> +		if (!IS_ERR(page) && page)
> +			break;
> +	}
> +	return (p->stack_start & PAGE_MASK) - i + PAGE_SIZE;
> +#endif
> +}
> +
> +static inline void task_show_stack_usage(struct seq_file *m,
> +						struct task_struct *task)
> +{
> +	struct vm_area_struct	*vma;
> +	struct mm_struct	*mm = get_task_mm(task);
> +
> +	if (mm) {
> +		down_read(&mm->mmap_sem);
> +		vma = find_vma(mm, task->stack_start);
> +		if (vma)
> +			seq_printf(m, "Stack usage:\t%lu kB\n",
> +				get_stack_usage_in_bytes(vma, task) >> 10);
> +
> +		up_read(&mm->mmap_sem);
> +		mmput(mm);
> +	}
> +}
--
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