]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: use %px for data pointers when debugging
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)
committerEric Sandeen <sandeen@redhat.com>
Tue, 27 Feb 2018 04:43:18 +0000 (22:43 -0600)
Source kernel commit: c96900435fa9fdfd9702a60cd765bd85e380303e

Starting with commit 57e734423ad ("vsprintf: refactor %pK code out of
pointer"), the behavior of the raw '%p' printk format specifier was
changed to print a 32-bit hash of the pointer value to avoid leaking
kernel pointers into dmesg.  For most situations that's good.

This is /undesirable/ behavior when we're trying to debug XFS, however,
so define a PTR_FMT that prints the actual pointer when we're in debug
mode.

Note that %p for tracepoints still prints the raw pointer, so in the
long run we could consider rewriting some of these messages as
tracepoints.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/libxfs_priv.h
libxfs/xfs_dir2_node.c

index 130f6ed2bbbec9baa5407703ca5987a2ac157395..637493d733bc2e81103d56528a95f7cff59619dd 100644 (file)
@@ -102,6 +102,16 @@ extern char    *progname;
 
 #define STATIC                         static
 
+/*
+ * Starting in Linux 4.15, the %p (raw pointer value) printk modifier
+ * prints a hashed version of the pointer to avoid leaking kernel
+ * pointers into dmesg.  If we're trying to debug the kernel we want the
+ * raw values, so override this behavior as best we can.
+ *
+ * In userspace we don't have this problem.
+ */
+#define PTR_FMT "%p"
+
 /* XXX: need to push these out to make LIBXFS_ATTR defines */
 #define ATTR_ROOT                      0x0002
 #define ATTR_SECURE                    0x0008
index ab9c4afbf110abe668623521fc46a554a13df271..399926457acd43e1e3097df4cfb7d83b822ddf00 100644 (file)
@@ -1916,7 +1916,7 @@ xfs_dir2_node_addname_int(
                                        (unsigned long long)ifbno, lastfbno);
                                if (fblk) {
                                        xfs_alert(mp,
-                               " fblk %p blkno %llu index %d magic 0x%x",
+                               " fblk "PTR_FMT" blkno %llu index %d magic 0x%x",
                                                fblk,
                                                (unsigned long long)fblk->blkno,
                                                fblk->index,