From: Darrick J. Wong Date: Tue, 27 Feb 2018 04:43:18 +0000 (-0600) Subject: xfs: use %px for data pointers when debugging X-Git-Tag: v4.16.0-rc1~84 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d7e71605e73f5c05ac029046d56781b675311592;p=thirdparty%2Fxfsprogs-dev.git xfs: use %px for data pointers when debugging 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 Reviewed-by: Dave Chinner Signed-off-by: Eric Sandeen --- diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index 130f6ed2b..637493d73 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -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 diff --git a/libxfs/xfs_dir2_node.c b/libxfs/xfs_dir2_node.c index ab9c4afbf..399926457 100644 --- a/libxfs/xfs_dir2_node.c +++ b/libxfs/xfs_dir2_node.c @@ -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,