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>] [day] [month] [year] [list]
Message-ID: <5154F1D3.6050600@huawei.com>
Date:	Fri, 29 Mar 2013 09:43:47 +0800
From:	Xie XiuQi <xiexiuqi@...wei.com>
To:	Tony Luck <tony.luck@...el.com>
CC:	Fenghua Yu <fenghua.yu@...el.com>,
	Jiang Liu <jiang.liu@...wei.com>,
	Yijing Wang <wangyijing@...wei.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH v2] ia64: Fix example error_injection_tool

I got a "sched_setaffinity:: Invalid argument" error when using
err_injection_tool to inject error on a system with over 32 cpus.

Error information when injecting an error on a system with over 32 cpus:
$ ./err_injection_tool -i
/sys/devices/system/cpu/cpu0/err_inject//err_type_info
Begine at Tue Mar 26 11:20:08 2013
Configurations:
On cpu32: loop=10, interval=5(s) err_type_info=4101,err_struct_info=95
Error sched_setaffinity:: Invalid argument
All done

This because there is overflow when calculating the cpumask: the
type of (1<<k) is int, while mask[j] is unsigned long. When k > 31,
(1<<k) is truncated to ZERO, resulting in a unexpected cpumask.

v2:
 - use "1UL" to avoid the verbose cast suggested by Tony.

Suggested-by: Tony Luck <tony.luck@...el.com>
Signed-off-by: Xie XiuQi <xiexiuqi@...wei.com>
---
 Documentation/ia64/err_inject.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Documentation/ia64/err_inject.txt b/Documentation/ia64/err_inject.txt
index 223e4f0..9f651c1 100644
--- a/Documentation/ia64/err_inject.txt
+++ b/Documentation/ia64/err_inject.txt
@@ -882,7 +882,7 @@ int err_inj()
 			cpu=parameters[i].cpu;
 			k = cpu%64;
 			j = cpu/64;
-			mask[j]=1<<k;
+			mask[j] = 1UL << k;

 			if (sched_setaffinity(0, MASK_SIZE*8, mask)==-1) {
 				perror("Error sched_setaffinity:");
-- 
1.6.0.2

--
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