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:   Thu, 15 Sep 2022 16:57:53 +0800
From:   Zhao Gongyi <zhaogongyi@...wei.com>
To:     <linux-doc@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <linux-mm@...ck.org>, <linux-kselftest@...r.kernel.org>
CC:     <akinobu.mita@...il.com>, <corbet@....net>, <david@...hat.com>,
        <osalvador@...e.de>, <shuah@...nel.org>,
        Zhao Gongyi <zhaogongyi@...wei.com>
Subject: [PATCH -next v2 1/5] docs: notifier-error-inject: fix non-working usage of negative values

Fault injection uses debugfs in a way that the provided values via
sysfs are interpreted as u64. Providing negative numbers results in
an error:

  # cd sys/kernel/debug/notifier-error-inject/memory
  #  echo -12 > actions/MEM_GOING_ONLINE/error
  -bash: echo: write error: Invalid argument

Update the docs and examples to use "printf %#x <val>" in these cases.

Signed-off-by: Zhao Gongyi <zhaogongyi@...wei.com>
---
 .../fault-injection/notifier-error-inject.rst          | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/Documentation/fault-injection/notifier-error-inject.rst b/Documentation/fault-injection/notifier-error-inject.rst
index 1668b6e48d3a..0e2790122166 100644
--- a/Documentation/fault-injection/notifier-error-inject.rst
+++ b/Documentation/fault-injection/notifier-error-inject.rst
@@ -11,6 +11,10 @@ modules that can be used to test the following notifiers.
  * powerpc pSeries reconfig notifier
  * Netdevice notifier

+Note that the interface only accepts unsigned values. So, if you want
+to use a negative errno, you'd better use 'printf' instead of 'echo', e.g.:
+$ printf %#x -12 > actions/PM_SUSPEND_PREPARE/error
+
 PM notifier error injection module
 ----------------------------------
 This feature is controlled through debugfs interface
@@ -26,7 +30,7 @@ Possible PM notifier events to be failed are:
 Example: Inject PM suspend error (-12 = -ENOMEM)::

 	# cd /sys/kernel/debug/notifier-error-inject/pm/
-	# echo -12 > actions/PM_SUSPEND_PREPARE/error
+	# printf %#x -12 > actions/PM_SUSPEND_PREPARE/error
 	# echo mem > /sys/power/state
 	bash: echo: write error: Cannot allocate memory

@@ -44,7 +48,7 @@ Possible memory notifier events to be failed are:
 Example: Inject memory hotplug offline error (-12 == -ENOMEM)::

 	# cd /sys/kernel/debug/notifier-error-inject/memory
-	# echo -12 > actions/MEM_GOING_OFFLINE/error
+	# printf %#x -12 > actions/MEM_GOING_OFFLINE/error
 	# echo offline > /sys/devices/system/memory/memoryXXX/state
 	bash: echo: write error: Cannot allocate memory

@@ -82,7 +86,7 @@ Netdevice notifier events which can be failed are:
 Example: Inject netdevice mtu change error (-22 == -EINVAL)::

 	# cd /sys/kernel/debug/notifier-error-inject/netdev
-	# echo -22 > actions/NETDEV_CHANGEMTU/error
+	# printf %#x -22 > actions/NETDEV_CHANGEMTU/error
 	# ip link set eth0 mtu 1024
 	RTNETLINK answers: Invalid argument

--
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ