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: Sun, 17 Mar 2024 15:45:23 +0100
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Pasha Tatashin <pasha.tatashin@...een.com>, linux-kernel@...r.kernel.org,
 linux-mm@...ck.org, akpm@...ux-foundation.org, x86@...nel.org, bp@...en8.de,
 brauner@...nel.org, bristot@...hat.com, bsegall@...gle.com,
 dave.hansen@...ux.intel.com, dianders@...omium.org,
 dietmar.eggemann@....com, eric.devolder@...cle.com, hca@...ux.ibm.com,
 hch@...radead.org, hpa@...or.com, jacob.jun.pan@...ux.intel.com,
 jgg@...pe.ca, jpoimboe@...nel.org, jroedel@...e.de, juri.lelli@...hat.com,
 kent.overstreet@...ux.dev, kinseyho@...gle.com,
 kirill.shutemov@...ux.intel.com, lstoakes@...il.com, luto@...nel.org,
 mgorman@...e.de, mic@...ikod.net, michael.christie@...cle.com,
 mingo@...hat.com, mjguzik@...il.com, mst@...hat.com, npiggin@...il.com,
 peterz@...radead.org, pmladek@...e.com, rick.p.edgecombe@...el.com,
 rostedt@...dmis.org, surenb@...gle.com, tglx@...utronix.de,
 urezki@...il.com, vincent.guittot@...aro.org
Subject: Re: [RFC 04/14] fork: Remove assumption that vm_area->nr_pages equals
 to THREAD_SIZE

Le 11/03/2024 à 17:46, Pasha Tatashin a écrit :
> In many places number of pages in the stack is detremined via
> (THREAD_SIZE / PAGE_SIZE). There is also a BUG_ON() that ensures that
> (THREAD_SIZE / PAGE_SIZE) is indeed equals to vm_area->nr_pages.
> 
> However, with dynamic stacks, the number of pages in vm_area will grow
> with stack, therefore, use vm_area->nr_pages to determine the actual
> number of pages allocated in stack.
> 
> Signed-off-by: Pasha Tatashin <pasha.tatashin@...een.com>
> ---
>   kernel/fork.c | 18 +++++++++---------
>   1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 60e812825a7a..a35f4008afa0 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -243,13 +243,11 @@ static int free_vm_stack_cache(unsigned int cpu)
>   
>   static int memcg_charge_kernel_stack(struct vm_struct *vm)

Maybe s/vm/vm_area/ as done in 03/14?

CJ

>   {
> -	int i;
> -	int ret;
> +	int i, ret, nr_pages;
>   	int nr_charged = 0;
>   
> -	BUG_ON(vm->nr_pages != THREAD_SIZE / PAGE_SIZE);
> -
> -	for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++) {
> +	nr_pages = vm->nr_pages;
> +	for (i = 0; i < nr_pages; i++) {
>   		ret = memcg_kmem_charge_page(vm->pages[i], GFP_KERNEL, 0);
>   		if (ret)
>   			goto err;
> @@ -531,9 +529,10 @@ static void account_kernel_stack(struct task_struct *tsk, int account)
>   {
>   	if (IS_ENABLED(CONFIG_VMAP_STACK)) {
>   		struct vm_struct *vm = task_stack_vm_area(tsk);
> -		int i;
> +		int i, nr_pages;
>   
> -		for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++)
> +		nr_pages = vm->nr_pages;
> +		for (i = 0; i < nr_pages; i++)
>   			mod_lruvec_page_state(vm->pages[i], NR_KERNEL_STACK_KB,
>   					      account * (PAGE_SIZE / 1024));
>   	} else {
> @@ -551,10 +550,11 @@ void exit_task_stack_account(struct task_struct *tsk)
>   
>   	if (IS_ENABLED(CONFIG_VMAP_STACK)) {
>   		struct vm_struct *vm;
> -		int i;
> +		int i, nr_pages;
>   
>   		vm = task_stack_vm_area(tsk);
> -		for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++)
> +		nr_pages = vm->nr_pages;
> +		for (i = 0; i < nr_pages; i++)
>   			memcg_kmem_uncharge_page(vm->pages[i], 0);
>   	}
>   }


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ