From 59b7435149eab2dd06dd678742faff6049cb655f Mon Sep 17 00:00:00 2001 From: "Denis V. Lunev" Date: Tue, 29 Apr 2008 01:02:00 -0700 Subject: proc: introduce proc_create_data to setup de->data This set of patches fixes an proc ->open'less usage due to ->proc_fops flip in the most part of the kernel code. The original OOPS is described in the commit 2d3a4e3666325a9709cc8ea2e88151394e8f20fc: Typical PDE creation code looks like: pde = create_proc_entry("foo", 0, NULL); if (pde) pde->proc_fops = &foo_proc_fops; Notice that PDE is first created, only then ->proc_fops is set up to final value. This is a problem because right after creation a) PDE is fully visible in /proc , and b) ->proc_fops are proc_file_operations which do not have ->open callback. So, it's possible to ->read without ->open (see one class of oopses below). The fix is new API called proc_create() which makes sure ->proc_fops are set up before gluing PDE to main tree. Typical new code looks like: pde = proc_create("foo", 0, NULL, &foo_proc_fops); if (!pde) return -ENOMEM; Fix most networking users for a start. In the long run, create_proc_entry() for regular files will go. In addition to this, proc_create_data is introduced to fix reading from proc without PDE->data. The race is basically the same as above. create_proc_entries is replaced in the entire kernel code as new method is also simply better. This patch: The problem is the same as for de->proc_fops. Right now PDE becomes visible without data set. So, the entry could be looked up without data. This, in most cases, will simply OOPS. proc_create_data call is created to address this issue. proc_create now becomes a wrapper around it. Signed-off-by: Denis V. Lunev Cc: "Eric W. Biederman" Cc: "J. Bruce Fields" Cc: Alessandro Zummo Cc: Alexey Dobriyan Cc: Bartlomiej Zolnierkiewicz Cc: Benjamin Herrenschmidt Cc: Bjorn Helgaas Cc: Chris Mason Acked-by: David Howells Cc: Dmitry Torokhov Cc: Geert Uytterhoeven Cc: Grant Grundler Cc: Greg Kroah-Hartman Cc: Haavard Skinnemoen Cc: Heiko Carstens Cc: Ingo Molnar Cc: James Bottomley Cc: Jaroslav Kysela Cc: Jeff Garzik Cc: Jeff Mahoney Cc: Jesper Nilsson Cc: Karsten Keil Cc: Kyle McMartin Cc: Len Brown Cc: Martin Schwidefsky Cc: Mathieu Desnoyers Cc: Matthew Wilcox Cc: Mauro Carvalho Chehab Cc: Mikael Starvik Cc: Nadia Derbey Cc: Neil Brown Cc: Paul Mackerras Cc: Peter Osterlund Cc: Pierre Peiffer Cc: Russell King Cc: Takashi Iwai Cc: Tony Luck Cc: Trond Myklebust Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/proc/root.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs/proc/root.c') diff --git a/fs/proc/root.c b/fs/proc/root.c index c741b45a5503..95117538a4f6 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c @@ -230,5 +230,5 @@ void pid_ns_release_proc(struct pid_namespace *ns) EXPORT_SYMBOL(proc_symlink); EXPORT_SYMBOL(proc_mkdir); EXPORT_SYMBOL(create_proc_entry); -EXPORT_SYMBOL(proc_create); +EXPORT_SYMBOL(proc_create_data); EXPORT_SYMBOL(remove_proc_entry); -- cgit v1.2.1