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] [day] [month] [year] [list]
Date:	Wed, 30 Sep 2015 10:28:03 +0900
From:	Minchan Kim <minchan@...nel.org>
To:	Sergey Senozhatsky <sergey.senozhatsky@...il.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org,
	Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>
Subject: Re: [PATCH] zram: keep the exact overcommited value in mem_used_max

On Thu, Sep 24, 2015 at 06:51:52PM +0900, Sergey Senozhatsky wrote:
> From: Sergey SENOZHATSKY <sergey.senozhatsky@...il.com>
> 
> `mem_used_max' is designed to store the max amount of memory zram
> consumed to store the data. However, it does not represent the actual
> 'overcommited' (max) value. The existing code goes to -ENOMEM
> overcommited case before it updates `->stats.max_used_pages', which
> hides the reason we went to -ENOMEM in the first place -- we actually
> used more memory than `->limit_pages':
> 
>         alloced_pages = zs_get_total_pages(meta->mem_pool);
>         if (zram->limit_pages && alloced_pages > zram->limit_pages) {
>                 zs_free(meta->mem_pool, handle);
>                 ret = -ENOMEM;
>                 goto out;
>         }
> 
>         update_used_max(zram, alloced_pages);
> 
> Which is misleading. User will see -ENOMEM, check `->limit_pages',
> check `->stats.max_used_pages', which will keep the value BEFORE zram
> passed `->limit_pages', and see:
> 	`->stats.max_used_pages' < `->limit_pages'
> 
> Move update_used_max() before we do `->limit_pages' check, so that
> user will see:
> 	`->stats.max_used_pages' > `->limit_pages'
> should the overcommit and -ENOMEM happen.
> 
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@...il.com>

It was intent.

IOW, I want that max_mem_used is never higher than mem_limit but
I realized you are right because user doesn't have way to detect
where -ENOMEM is coming from.
For example, it could come from mem_limit or real memory alloc fail.

Thanks, Sergey.

Acked-by: Minchan Kim <minchan@...nel.org>
--
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