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: <1334441685-4438-3-git-send-email-levinsasha928@gmail.com>
Date:	Sat, 14 Apr 2012 18:14:44 -0400
From:	Sasha Levin <levinsasha928@...il.com>
To:	torvalds@...ux-foundation.org, akpm@...ux-foundation.org,
	peterz@...radead.org, mingo@...e.hu, hpa@...or.com,
	tglx@...utronix.de, srivatsa.bhat@...ux.vnet.ibm.com
Cc:	linux-kernel@...r.kernel.org, Sasha Levin <levinsasha928@...il.com>
Subject: [RFC 2/3] sched: add type checks to for_each_cpu_mask()

Add type checks to assert that 'mask' is 'struct cpumask *'. This check
would have detected the bug fixed in e3831ed ("sched: Fix incorrect usage
of for_each_cpu_mask() in select_fallback_rq()"):

kernel/sched/core.c: In function 'select_fallback_rq':
kernel/sched/core.c:1273:2: warning: comparison of distinct pointer types lacks a cast
kernel/sched/core.c:1284:3: warning: comparison of distinct pointer types lacks a cast

Signed-off-by: Sasha Levin <levinsasha928@...il.com>
---
 include/linux/cpumask.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index a2c819d..58fd022 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -799,7 +799,8 @@ static inline const struct cpumask *get_cpu_mask(unsigned int cpu)
 #define first_cpu(src)		({ (void)(src); 0; })
 #define next_cpu(n, src)	({ (void)(src); 1; })
 #define any_online_cpu(mask)	0
-#define for_each_cpu_mask(cpu, mask)	\
+#define for_each_cpu_mask(cpu, mask)		\
+	typecheck(struct cpumask *, (mask));	\
 	for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
 #else /* NR_CPUS > 1 */
 int __first_cpu(const cpumask_t *srcp);
@@ -809,6 +810,7 @@ int __next_cpu(int n, const cpumask_t *srcp);
 #define next_cpu(n, src)	__next_cpu((n), &(src))
 #define any_online_cpu(mask) cpumask_any_and(&mask, cpu_online_mask)
 #define for_each_cpu_mask(cpu, mask)			\
+	typecheck(struct cpumask *, (mask));		\
 	for ((cpu) = -1;				\
 		(cpu) = next_cpu((cpu), (mask)),	\
 		(cpu) < NR_CPUS; )
-- 
1.7.8.5

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