Re: [bugfix] SMP, shm-2.3.52-A0

From: Andrew Morton (morton@nortelnetworks.com)
Date: Thu Mar 16 2000 - 21:38:29 EST


Ingo Molnar wrote:
>
> shm.c calls filp_open without the kernel lock held - this is illegal
> because the dentry code is not yet SMP-threaded. The attached patch
> (against pre3-2.3.52) fixes this.

Prevent this from ever happening again....

diff -uNr linux-2.3.99-pre1/include/linux/kassert.h linux-akpm/include/linux/kassert.h
--- linux-2.3.99-pre1/include/linux/kassert.h Thu Jan 1 10:00:00 1970
+++ linux-akpm/include/linux/kassert.h Fri Mar 17 10:36:34 2000
@@ -0,0 +1,21 @@
+#ifndef _KASSERT_H_
+#define _KASSERT_H_
+
+#define KASSERTS_ENABLED 1
+
+#if KASSERTS_ENABLED
+#define KASSERT_FAIL() \
+ do { \
+ printk("assertion failure at %s:%d\n", __FILE__, __LINE__); \
+ } while (0)
+
+#define KASSERT(expr) \
+ do { \
+ if (!(expr)) \
+ KASSERT_FAIL(); \
+ } while (0)
+#else
+#define KASSERT(expr) ((void)0)
+#endif
+
+#endif /* _KASSERT_H_ */
--- linux-2.3.99-pre1/fs/open.c Fri Mar 17 11:50:30 2000
+++ linux-akpm/fs/open.c Fri Mar 17 10:48:06 2000
@@ -10,6 +10,7 @@
 #include <linux/file.h>
 #include <linux/smp_lock.h>
 #include <linux/quotaops.h>
+#include <linux/kassert.h>
 
 #include <asm/uaccess.h>
 
@@ -650,6 +651,8 @@
         struct dentry * dentry;
         struct file * f;
         int flag,error;
+
+ KASSERT(spin_is_locked(&kernel_flag));
 
         error = -ENFILE;
         f = get_empty_filp();

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:20 EST