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]
Message-ID: <e3fc40c9-6e4e-d8de-63ce-ce34d78fa883@suse.cz>
Date:   Thu, 10 Nov 2022 10:40:52 +0100
From:   Vlastimil Babka <vbabka@...e.cz>
To:     Rong Tao <rtoax@...mail.com>, akpm@...ux-foundation.org
Cc:     Rong Tao <rongtao@...tc.cn>,
        Stéphane Graber <stgraber@...ntu.com>,
        Yuanzheng Song <songyuanzheng@...wei.com>,
        linux-kernel@...r.kernel.org, Christoph Lameter <cl@...ux.com>,
        David Rientjes <rientjes@...gle.com>,
        "linux-mm@...ck.org" <linux-mm@...ck.org>,
        Joonsoo Kim <iamjoonsoo.kim@....com>,
        Pekka Enberg <penberg@...nel.org>,
        Hyeonggon Yoo <42.hyeyoo@...il.com>,
        Roman Gushchin <roman.gushchin@...ux.dev>
Subject: Re: [PATCH] tools/vm/slabinfo: indicates the cause of the EACCES
 error

On 11/8/22 13:47, Rong Tao wrote:
> From: Rong Tao <rongtao@...tc.cn>
> 
> If you don't run slabinfo with a superuser, return 0 when read_slab_dir()
> reads get_obj_and_str("slabs", &t), because fopen() fails (sometimes
> EACCES), causing slabcache() to return directly, without any error during
> this time, we should tell the user about the EACCES problem instead of
> running successfully($?=0) without any error printing.
> 
>  For example:
>  $ ./slabinfo
>  Permission denied, Try using superuser  <== What this submission did
>  $ sudo ./slabinfo
>  Name            Objects Objsize   Space Slabs/Part/Cpu  O/S O %Fr %Ef Flg
>  Acpi-Namespace     5950      48  286.7K         65/0/5   85 0   0  99
>  Acpi-Operand      13664      72  999.4K       231/0/13   56 0   0  98
>  ...
> 
> Signed-off-by: Rong Tao <rongtao@...tc.cn>

Thanks, added to slab.git slab/for-6.2/tools

> ---
>  tools/vm/slabinfo.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/vm/slabinfo.c b/tools/vm/slabinfo.c
> index 0fffaeedee76..cfaeaea71042 100644
> --- a/tools/vm/slabinfo.c
> +++ b/tools/vm/slabinfo.c
> @@ -157,9 +157,11 @@ static unsigned long read_obj(const char *name)
>  {
>  	FILE *f = fopen(name, "r");
>  
> -	if (!f)
> +	if (!f) {
>  		buffer[0] = 0;
> -	else {
> +		if (errno == EACCES)
> +			fatal("%s, Try using superuser\n", strerror(errno));
> +	} else {
>  		if (!fgets(buffer, sizeof(buffer), f))
>  			buffer[0] = 0;
>  		fclose(f);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ