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, 07 Apr 2011 15:07:06 +0800
From:	Lai Jiangshan <laijs@...fujitsu.com>
To:	paulmck@...ux.vnet.ibm.com
CC:	"H. Peter Anvin" <hpa@...ux.intel.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Michal Marek <mmarek@...e.cz>,
	Jan Beulich <JBeulich@...ell.com>, Ingo Molnar <mingo@...e.hu>,
	Alexander van Heukelum <heukelum@...tmail.fm>,
	Dipankar Sarma <dipankar@...ibm.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Sam Ravnborg <sam@...nborg.org>,
	David Howells <dhowells@...hat.com>,
	Oleg Nesterov <oleg@...hat.com>,
	Roland McGrath <roland@...hat.com>,
	linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>,
	Steven Rostedt <rostedt@...dmis.org>
Subject: [PATCH 2/4] rcu: make rcudpate.h can use struct task_struct.


Step1: Ensure sched.h that it does not include rcudpate.h.

rcupdate.h is so generic that it is included in many headers.
sched.h is so complex that it includes many headers.
So we have to find out all header files which directly include
rcupdate.h and are directly/indirectly included by sched.h.

I found out these files by a script(No False Positive, No False Negetive):
2 include/linux/aio.h ---> include/linux/rcupdate.h
2 include/linux/key.h ---> include/linux/rcupdate.h
2 include/linux/pid.h ---> include/linux/rcupdate.h
2 include/linux/rculist.h ---> include/linux/rcupdate.h
2 include/linux/sched.h ---> include/linux/rcupdate.h
2 include/linux/sem.h ---> include/linux/rcupdate.h
2 include/linux/sysctl.h ---> include/linux/rcupdate.h

So the step 1 changes these files just includes rcupdate_defs.h

Step2: Ensure rcupdate.h included in the files which use rcu_read_lock*()

When the step 1 is done, the kernel build will fail, because some
files just include the above files and use rcu_read_lock*() without
rcupdate.h included.

# vi ~/is_include.py     ########### command1

import re
import sys

include_re = re.compile(r'#\s*include\s*<([_\-\w]*/)([/\._\-\w]*)>')
searched = {}

def is_include(f, depth):
  if f == ('include/linux/', 'rcupdate.h'):
    sys.exit(0)
  if depth <= 0:
    return
  if searched.has_key(f):
    if searched[f] > depth:
      return
  searched[f] = depth
  try:
    ff = file(f[0]+f[1])
  except:
    return ()
  for ch in include_re.findall(ff.read()):
    if ch[0] != 'asm/':
      is_include(('include/' + ch[0], ch[1]), depth - 1)

"""usage: is_include.py file_name depth """
is_include(('', sys.argv[1]), int(sys.argv[2]))
sys.exit(1)

# vi ~/is_include.sh ############## command2
#!/bin/bash

depth="$1"

find -name "*.c" | xargs grep -l rcu_read_lock | while read file
do
	python ~/is_include.py "$file" "$depth" || echo "$file"
done

# ~/is_include.sh 3   ################# command3(after step1 is done)
./drivers/base/power/wakeup.c
./drivers/misc/sgi-gru/grutlbpurge.c
./drivers/char/tpm/tpm.c
./drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
./drivers/net/wireless/ath/ath9k/xmit.c
./drivers/net/wireless/ath/ath9k/htc_drv_main.c
./drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
./drivers/net/wireless/ath/carl9170/mac.c
./drivers/net/wireless/ath/ar9170/mac.c
./drivers/staging/tidspbridge/pmgr/dspapi.c
./drivers/s390/cio/qdio_thinint.c
./lib/is_single_threaded.c
./fs/autofs4/waitq.c
./fs/ecryptfs/messaging.c
./fs/xfs/xfs_mount.c
./fs/xfs/linux-2.6/xfs_sync.c
./fs/xfs/xfs_iget.c
./fs/xfs/xfs_inode.c
./arch/ia64/sn/kernel/irq.c
./security/tomoyo/common.c
./security/apparmor/audit.c
./kernel/sched_fair.c
./kernel/tsacct.c
./kernel/sched_debug.c
./kernel/pid_namespace.c
./kernel/futex_compat.c
./kernel/sched_rt.c
./net/rds/ib_rdma.c
./net/rds/connection.c
./net/mac80211/debugfs_sta.c
./net/mac80211/mesh.c
./net/mac80211/mesh_hwmp.c
./net/mac80211/debugfs_key.c
./net/mac80211/mesh_plink.c
./net/batman-adv/send.c
./net/batman-adv/routing.c
./net/batman-adv/main.c
./net/batman-adv/originator.c

(The simple scripts allow False Positive, disallow False Negetive)
After manual check, only
	drivers/staging/tidspbridge/pmgr/dspapi.c
	kernel/futex_compat.c
	kernel/tsacct.c
	lib/is_single_threaded.c
are required to add  "#include <linux/rcupdate.h>"

Signed-off-by: Lai Jiangshan <laijs@...fujitsu.com>
---
 drivers/staging/tidspbridge/pmgr/dspapi.c |    1 +
 include/linux/aio.h                       |    2 +-
 include/linux/key.h                       |    2 +-
 include/linux/pid.h                       |    2 +-
 include/linux/rculist.h                   |    2 +-
 include/linux/sched.h                     |    2 +-
 include/linux/sem.h                       |    2 +-
 include/linux/sysctl.h                    |    2 +-
 kernel/futex_compat.c                     |    1 +
 kernel/tsacct.c                           |    1 +
 lib/is_single_threaded.c                  |    1 +
 11 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/tidspbridge/pmgr/dspapi.c b/drivers/staging/tidspbridge/pmgr/dspapi.c
index 86ca785..558654e 100644
--- a/drivers/staging/tidspbridge/pmgr/dspapi.c
+++ b/drivers/staging/tidspbridge/pmgr/dspapi.c
@@ -17,6 +17,7 @@
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 #include <linux/types.h>
+#include <linux/rcupdate.h>
 
 /*  ----------------------------------- Host OS */
 #include <dspbridge/host_os.h>
diff --git a/include/linux/aio.h b/include/linux/aio.h
index 7a8db41..1033572 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -5,7 +5,7 @@
 #include <linux/workqueue.h>
 #include <linux/aio_abi.h>
 #include <linux/uio.h>
-#include <linux/rcupdate.h>
+#include <linux/rcupdate_defs.h>
 
 #include <asm/atomic.h>
 
diff --git a/include/linux/key.h b/include/linux/key.h
index 3db0adc..8f18036 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -18,7 +18,7 @@
 #include <linux/types.h>
 #include <linux/list.h>
 #include <linux/rbtree.h>
-#include <linux/rcupdate.h>
+#include <linux/rcupdate_defs.h>
 #include <linux/sysctl.h>
 #include <linux/rwsem.h>
 #include <asm/atomic.h>
diff --git a/include/linux/pid.h b/include/linux/pid.h
index 49f1c2f..12d652c 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -1,7 +1,7 @@
 #ifndef _LINUX_PID_H
 #define _LINUX_PID_H
 
-#include <linux/rcupdate.h>
+#include <linux/rcupdate_defs.h>
 
 enum pid_type
 {
diff --git a/include/linux/rculist.h b/include/linux/rculist.h
index 2dea94f..265e22d 100644
--- a/include/linux/rculist.h
+++ b/include/linux/rculist.h
@@ -7,7 +7,7 @@
  * RCU-protected list version
  */
 #include <linux/list.h>
-#include <linux/rcupdate.h>
+#include <linux/rcupdate_defs.h>
 
 /*
  * Why is there no list_empty_rcu()?  Because list_empty() serves this
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 777d8a5..69db9e7 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -78,7 +78,7 @@ struct sched_param {
 #include <linux/topology.h>
 #include <linux/proportions.h>
 #include <linux/seccomp.h>
-#include <linux/rcupdate.h>
+#include <linux/rcupdate_defs.h>
 #include <linux/rculist.h>
 #include <linux/rtmutex.h>
 
diff --git a/include/linux/sem.h b/include/linux/sem.h
index f2961af..98d96e8 100644
--- a/include/linux/sem.h
+++ b/include/linux/sem.h
@@ -78,7 +78,7 @@ struct  seminfo {
 
 #ifdef __KERNEL__
 #include <asm/atomic.h>
-#include <linux/rcupdate.h>
+#include <linux/rcupdate_defs.h>
 #include <linux/cache.h>
 
 struct task_struct;
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 11684d9..553f127 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -930,7 +930,7 @@ enum
 
 #ifdef __KERNEL__
 #include <linux/list.h>
-#include <linux/rcupdate.h>
+#include <linux/rcupdate_defs.h>
 
 /* For the /proc/sys support */
 struct ctl_table;
diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
index a7934ac..4485705 100644
--- a/kernel/futex_compat.c
+++ b/kernel/futex_compat.c
@@ -10,6 +10,7 @@
 #include <linux/compat.h>
 #include <linux/nsproxy.h>
 #include <linux/futex.h>
+#include <linux/rcupdate.h>
 
 #include <asm/uaccess.h>
 
diff --git a/kernel/tsacct.c b/kernel/tsacct.c
index 24dc60d..2617467 100644
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -21,6 +21,7 @@
 #include <linux/tsacct_kern.h>
 #include <linux/acct.h>
 #include <linux/jiffies.h>
+#include <linux/rcupdate.h>
 #include <linux/mm.h>
 
 /*
diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
index bd2bea9..efcb711 100644
--- a/lib/is_single_threaded.c
+++ b/lib/is_single_threaded.c
@@ -11,6 +11,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/rcupdate.h>
 
 /*
  * Returns true if the task does not share ->mm with another thread/process.
-- 
1.7.4

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