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]
Message-ID: <20130219104255.3d01363a@redhat.com>
Date:	Tue, 19 Feb 2013 10:42:55 -0300
From:	Mauro Carvalho Chehab <mchehab@...hat.com>
To:	Borislav Petkov <bp@...en8.de>
Cc:	balbi@...com, Greg KH <gregkh@...uxfoundation.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Ingo Molnar <mingo@...hat.com>, JBottomley@...allels.com,
	linux-scsi@...r.kernel.org, davem@...emloft.net,
	netdev@...r.kernel.org, Doug Thompson <dougthompson@...ssion.com>,
	linux-edac@...r.kernel.org, rjw@...k.pl, linux-pm@...r.kernel.org
Subject: Re: SYSFS "errors"

Em Tue, 19 Feb 2013 14:06:26 +0100
Borislav Petkov <bp@...en8.de> escreveu:

> > No, on both cases, open() will return an error (-ENOENT against -EPERM).
> 
> What if it is a shell script doing:
> 
> cat /sys/devices/system/edac/mc/mc0/sdram_scrub_rate
> 
> or similar?

Well, cat will return "1" if an error is found, no matter what error happened. 

With an existing file (-ENOSYS):

	$ cat /sys/devices/system/edac/mc/mc0/sdram_scrub_rate; echo $?

	cat: /sys/devices/system/edac/mc/mc0/sdram_scrub_rate: No such device
	1

When the file doesn't exist (-ENOENT):
	$ cat /sys/devices/system/edac/mc/mc0/sdram_scrub_rate_not_exist; echo $?
	cat: /sys/devices/system/edac/mc/mc0/sdram_scrub_rate_not_exist: No such file or directory
	1

When permission doesn't match (-EPERM):
	$ cat /sys/devices/system/cpu/probe; echo $?
	cat: /sys/devices/system/cpu/probe: Permission denied
	1

When everything is ok, it will return 0
	$ cat /sys/devices/system/edac/mc/mc0/ce_count; echo $? >/dev/null
	0

A script ready to handle -ENOSYS would be doing, instead:

	RATE=$(cat /sys/devices/system/edac/mc/mc0/ce_count 2>/dev/null)
	if [ "$?" == "0" ]; then echo "Scrub rate: $RATE"; fi

So, a bash script won't notice any difference.

The only difference will be noticed if the script is written on some other 
language and the script is dumb enough to assume success if the errno is
different than -ENOSYS.

-- 

Cheers,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ