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: <11907762153804-git-send-email-ezk@cs.sunysb.edu>
Date:	Tue, 25 Sep 2007 23:10:04 -0400
From:	Erez Zadok <ezk@...sunysb.edu>
To:	akpm@...ux-foundation.org
Cc:	linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
	viro@....linux.org.uk, hch@...radead.org,
	Erez Zadok <ezk@...sunysb.edu>,
	"Josef 'Jeff' Sipek" <jsipek@...sunysb.edu>
Subject: [PATCH 25/25] Unionfs: use poison.h for safe poison pointers

This also fixes a compile warning on 64-bit systems.

Signed-off-by: Josef 'Jeff' Sipek <jsipek@...sunysb.edu>
Signed-off-by: Erez Zadok <ezk@...sunysb.edu>
---
 fs/unionfs/debug.c |   16 ++++++----------
 fs/unionfs/union.h |    1 +
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/fs/unionfs/debug.c b/fs/unionfs/debug.c
index 09b52ce..b103eb9 100644
--- a/fs/unionfs/debug.c
+++ b/fs/unionfs/debug.c
@@ -25,14 +25,6 @@
 		}							\
 	} while (0)
 
-#if BITS_PER_LONG == 32
-#define POISONED_PTR		((void*) 0x5a5a5a5a)
-#elif BITS_PER_LONG == 64
-#define POISONED_PTR		((void*) 0x5a5a5a5a5a5a5a5a)
-#else
-#error Unknown BITS_PER_LONG value
-#endif /* BITS_PER_LONG != known */
-
 /*
  * __unionfs_check_{inode,dentry,file} perform exhaustive sanity checking on
  * the fan-out of various Unionfs objects.  We check that no lower objects
@@ -50,6 +42,7 @@ void __unionfs_check_inode(const struct inode *inode,
 	struct inode *lower_inode;
 	struct super_block *sb;
 	int printed_caller = 0;
+	void *poison_ptr;
 
 	/* for inodes now */
 	BUG_ON(!inode);
@@ -88,12 +81,13 @@ void __unionfs_check_inode(const struct inode *inode,
 		}
 		lower_inode = unionfs_lower_inode_idx(inode, bindex);
 		if (lower_inode) {
+			memset(&poison_ptr, POISON_INUSE, sizeof(void *));
 			if (unlikely(bindex < istart || bindex > iend)) {
 				PRINT_CALLER(fname, fxn, line);
 				printk(" Ci5: inode/linode=%p:%p bindex=%d "
 				       "istart/end=%d:%d\n", inode,
 				       lower_inode, bindex, istart, iend);
-			} else if (unlikely(lower_inode == POISONED_PTR)) {
+			} else if (unlikely(lower_inode == poison_ptr)) {
 				/* freed inode! */
 				PRINT_CALLER(fname, fxn, line);
 				printk(" Ci6: inode/linode=%p:%p bindex=%d "
@@ -131,6 +125,7 @@ void __unionfs_check_dentry(const struct dentry *dentry,
 	struct super_block *sb;
 	struct vfsmount *lower_mnt;
 	int printed_caller = 0;
+	void *poison_ptr;
 
 	BUG_ON(!dentry);
 	sb = dentry->d_sb;
@@ -257,12 +252,13 @@ void __unionfs_check_dentry(const struct dentry *dentry,
 	for (bindex = sbstart(sb); bindex < sbmax(sb); bindex++) {
 		lower_inode = unionfs_lower_inode_idx(inode, bindex);
 		if (lower_inode) {
+			memset(&poison_ptr, POISON_INUSE, sizeof(void *));
 			if (unlikely(bindex < istart || bindex > iend)) {
 				PRINT_CALLER(fname, fxn, line);
 				printk(" CI5: dentry/linode=%p:%p bindex=%d "
 				       "istart/end=%d:%d\n", dentry,
 				       lower_inode, bindex, istart, iend);
-			} else if (unlikely(lower_inode == POISONED_PTR)) {
+			} else if (unlikely(lower_inode == poison_ptr)) {
 				/* freed inode! */
 				PRINT_CALLER(fname, fxn, line);
 				printk(" CI6: dentry/linode=%p:%p bindex=%d "
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 8df44a9..510267f 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -43,6 +43,7 @@
 #include <linux/fs_stack.h>
 #include <linux/magic.h>
 #include <linux/log2.h>
+#include <linux/poison.h>
 
 #include <asm/mman.h>
 #include <asm/system.h>
-- 
1.5.2.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