]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
xfs: use %px for data pointers when debugging
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 9 Jan 2018 20:02:55 +0000 (12:02 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Fri, 12 Jan 2018 22:09:08 +0000 (14:09 -0800)
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>
fs/xfs/libxfs/xfs_dir2_node.c
fs/xfs/xfs_aops.c
fs/xfs/xfs_dquot_item.c
fs/xfs/xfs_fsops.c
fs/xfs/xfs_inode.c
fs/xfs/xfs_linux.h
fs/xfs/xfs_log.c
fs/xfs/xfs_log_recover.c
fs/xfs/xfs_qm.c

index e900dbcb0de94602960bde173de366bfb8ca458c..bb893ae02696a7b4a8bef37e2f16bc3c94df5047 100644 (file)
@@ -1919,7 +1919,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,
index 4fc526a27a94fe4594508b707f0a9ca976c1dd98..2e094c76bd4505f97e38fffd94d96bba450425a6 100644 (file)
@@ -791,7 +791,7 @@ xfs_aops_discard_page(
                goto out_invalidate;
 
        xfs_alert(ip->i_mount,
-               "page discard on page %p, inode 0x%llx, offset %llu.",
+               "page discard on page "PTR_FMT", inode 0x%llx, offset %llu.",
                        page, ip->i_ino, offset);
 
        xfs_ilock(ip, XFS_ILOCK_EXCL);
index 664dea105e76fee564a1feeb16a05387fe6b9000..e564f11d83f3cd97ff3ea455c19aee94b93f3996 100644 (file)
@@ -212,7 +212,7 @@ xfs_qm_dquot_logitem_push(
 
        error = xfs_qm_dqflush(dqp, &bp);
        if (error) {
-               xfs_warn(dqp->q_mount, "%s: push error %d on dqp %p",
+               xfs_warn(dqp->q_mount, "%s: push error %d on dqp "PTR_FMT,
                        __func__, error, dqp);
        } else {
                if (!xfs_buf_delwri_queue(bp, buffer_list))
index cc86b2b34243d8f68af52b96aa8cf56aab842441..8b4545623e25691f564397a471e11864c8326a1a 100644 (file)
@@ -878,7 +878,7 @@ xfs_do_force_shutdown(
 
        if (!(flags & SHUTDOWN_FORCE_UMOUNT)) {
                xfs_notice(mp,
-       "%s(0x%x) called from line %d of file %s.  Return address = %p",
+       "%s(0x%x) called from line %d of file %s.  Return address = "PTR_FMT,
                        __func__, flags, lnnum, fname, __return_address);
        }
        /*
index 29c47da383e0525fd85a1963fcc2329805ace0a4..c9e40d4fc9396b3c0ff47387a2e94fcc86eb2181 100644 (file)
@@ -3529,7 +3529,7 @@ xfs_iflush_int(
        if (XFS_TEST_ERROR(dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC),
                               mp, XFS_ERRTAG_IFLUSH_1)) {
                xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
-                       "%s: Bad inode %Lu magic number 0x%x, ptr %p",
+                       "%s: Bad inode %Lu magic number 0x%x, ptr "PTR_FMT,
                        __func__, ip->i_ino, be16_to_cpu(dip->di_magic), dip);
                goto corrupt_out;
        }
@@ -3539,7 +3539,7 @@ xfs_iflush_int(
                    (ip->i_d.di_format != XFS_DINODE_FMT_BTREE),
                    mp, XFS_ERRTAG_IFLUSH_3)) {
                        xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
-                               "%s: Bad regular inode %Lu, ptr %p",
+                               "%s: Bad regular inode %Lu, ptr "PTR_FMT,
                                __func__, ip->i_ino, ip);
                        goto corrupt_out;
                }
@@ -3550,7 +3550,7 @@ xfs_iflush_int(
                    (ip->i_d.di_format != XFS_DINODE_FMT_LOCAL),
                    mp, XFS_ERRTAG_IFLUSH_4)) {
                        xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
-                               "%s: Bad directory inode %Lu, ptr %p",
+                               "%s: Bad directory inode %Lu, ptr "PTR_FMT,
                                __func__, ip->i_ino, ip);
                        goto corrupt_out;
                }
@@ -3559,7 +3559,7 @@ xfs_iflush_int(
                                ip->i_d.di_nblocks, mp, XFS_ERRTAG_IFLUSH_5)) {
                xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
                        "%s: detected corrupt incore inode %Lu, "
-                       "total extents = %d, nblocks = %Ld, ptr %p",
+                       "total extents = %d, nblocks = %Ld, ptr "PTR_FMT,
                        __func__, ip->i_ino,
                        ip->i_d.di_nextents + ip->i_d.di_anextents,
                        ip->i_d.di_nblocks, ip);
@@ -3568,7 +3568,7 @@ xfs_iflush_int(
        if (XFS_TEST_ERROR(ip->i_d.di_forkoff > mp->m_sb.sb_inodesize,
                                mp, XFS_ERRTAG_IFLUSH_6)) {
                xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
-                       "%s: bad inode %Lu, forkoff 0x%x, ptr %p",
+                       "%s: bad inode %Lu, forkoff 0x%x, ptr "PTR_FMT,
                        __func__, ip->i_ino, ip->i_d.di_forkoff, ip);
                goto corrupt_out;
        }
index 74d3576c8043690527033eadd7d40136c29b2623..bee51a14a906ea71661e06b5d82fd46dd219c536 100644 (file)
@@ -291,4 +291,16 @@ static inline uint64_t howmany_64(uint64_t x, uint32_t y)
 #define XFS_IS_REALTIME_MOUNT(mp) (0)
 #endif
 
+/*
+ * 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.
+ */
+#ifdef DEBUG
+# define PTR_FMT "%px"
+#else
+# define PTR_FMT "%p"
+#endif
+
 #endif /* __XFS_LINUX__ */
index 922e5a9764ca1791e2462b8fb99ccd8069706bd4..c1f266c34af727d2ad45306544512d52809338ed 100644 (file)
@@ -2244,7 +2244,7 @@ xlog_write_setup_ophdr(
                break;
        default:
                xfs_warn(log->l_mp,
-                       "Bad XFS transaction clientid 0x%x in ticket %p",
+                       "Bad XFS transaction clientid 0x%x in ticket "PTR_FMT,
                        ophdr->oh_clientid, ticket);
                return NULL;
        }
@@ -3926,7 +3926,7 @@ xlog_verify_iclog(
                }
                if (clientid != XFS_TRANSACTION && clientid != XFS_LOG)
                        xfs_warn(log->l_mp,
-                               "%s: invalid clientid %d op %p offset 0x%lx",
+                               "%s: invalid clientid %d op "PTR_FMT" offset 0x%lx",
                                __func__, clientid, ophead,
                                (unsigned long)field_offset);
 
index 205bace41832416b549dbc9e31c6e9c894e2363f..d864380b6575b683d1f8d4b7361e72de42c70b69 100644 (file)
@@ -2218,7 +2218,7 @@ xlog_recover_do_inode_buffer(
                                next_unlinked_offset - reg_buf_offset;
                if (unlikely(*logged_nextp == 0)) {
                        xfs_alert(mp,
-               "Bad inode buffer log record (ptr = %p, bp = %p). "
+               "Bad inode buffer log record (ptr = "PTR_FMT", bp = "PTR_FMT"). "
                "Trying to replay bad (0) inode di_next_unlinked field.",
                                item, bp);
                        XFS_ERROR_REPORT("xlog_recover_do_inode_buf",
@@ -3049,7 +3049,7 @@ xlog_recover_inode_pass2(
         */
        if (unlikely(dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC))) {
                xfs_alert(mp,
-       "%s: Bad inode magic number, dip = %p, dino bp = %p, ino = %Ld",
+       "%s: Bad inode magic number, dip = "PTR_FMT", dino bp = "PTR_FMT", ino = %Ld",
                        __func__, dip, bp, in_f->ilf_ino);
                XFS_ERROR_REPORT("xlog_recover_inode_pass2(1)",
                                 XFS_ERRLEVEL_LOW, mp);
@@ -3059,7 +3059,7 @@ xlog_recover_inode_pass2(
        ldip = item->ri_buf[1].i_addr;
        if (unlikely(ldip->di_magic != XFS_DINODE_MAGIC)) {
                xfs_alert(mp,
-                       "%s: Bad inode log record, rec ptr %p, ino %Ld",
+                       "%s: Bad inode log record, rec ptr "PTR_FMT", ino %Ld",
                        __func__, item, in_f->ilf_ino);
                XFS_ERROR_REPORT("xlog_recover_inode_pass2(2)",
                                 XFS_ERRLEVEL_LOW, mp);
@@ -3117,8 +3117,8 @@ xlog_recover_inode_pass2(
                        XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(3)",
                                         XFS_ERRLEVEL_LOW, mp, ldip);
                        xfs_alert(mp,
-               "%s: Bad regular inode log record, rec ptr %p, "
-               "ino ptr = %p, ino bp = %p, ino %Ld",
+               "%s: Bad regular inode log record, rec ptr "PTR_FMT", "
+               "ino ptr = "PTR_FMT", ino bp = "PTR_FMT", ino %Ld",
                                __func__, item, dip, bp, in_f->ilf_ino);
                        error = -EFSCORRUPTED;
                        goto out_release;
@@ -3130,8 +3130,8 @@ xlog_recover_inode_pass2(
                        XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(4)",
                                             XFS_ERRLEVEL_LOW, mp, ldip);
                        xfs_alert(mp,
-               "%s: Bad dir inode log record, rec ptr %p, "
-               "ino ptr = %p, ino bp = %p, ino %Ld",
+               "%s: Bad dir inode log record, rec ptr "PTR_FMT", "
+               "ino ptr = "PTR_FMT", ino bp = "PTR_FMT", ino %Ld",
                                __func__, item, dip, bp, in_f->ilf_ino);
                        error = -EFSCORRUPTED;
                        goto out_release;
@@ -3141,8 +3141,8 @@ xlog_recover_inode_pass2(
                XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(5)",
                                     XFS_ERRLEVEL_LOW, mp, ldip);
                xfs_alert(mp,
-       "%s: Bad inode log record, rec ptr %p, dino ptr %p, "
-       "dino bp %p, ino %Ld, total extents = %d, nblocks = %Ld",
+       "%s: Bad inode log record, rec ptr "PTR_FMT", dino ptr "PTR_FMT", "
+       "dino bp "PTR_FMT", ino %Ld, total extents = %d, nblocks = %Ld",
                        __func__, item, dip, bp, in_f->ilf_ino,
                        ldip->di_nextents + ldip->di_anextents,
                        ldip->di_nblocks);
@@ -3153,8 +3153,8 @@ xlog_recover_inode_pass2(
                XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(6)",
                                     XFS_ERRLEVEL_LOW, mp, ldip);
                xfs_alert(mp,
-       "%s: Bad inode log record, rec ptr %p, dino ptr %p, "
-       "dino bp %p, ino %Ld, forkoff 0x%x", __func__,
+       "%s: Bad inode log record, rec ptr "PTR_FMT", dino ptr "PTR_FMT", "
+       "dino bp "PTR_FMT", ino %Ld, forkoff 0x%x", __func__,
                        item, dip, bp, in_f->ilf_ino, ldip->di_forkoff);
                error = -EFSCORRUPTED;
                goto out_release;
@@ -3164,7 +3164,7 @@ xlog_recover_inode_pass2(
                XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(7)",
                                     XFS_ERRLEVEL_LOW, mp, ldip);
                xfs_alert(mp,
-                       "%s: Bad inode log record length %d, rec ptr %p",
+                       "%s: Bad inode log record length %d, rec ptr "PTR_FMT,
                        __func__, item->ri_buf[1].i_len, item);
                error = -EFSCORRUPTED;
                goto out_release;
index 6b9f44df7918b6c1701f40e1a8d5bb4d7d42299c..5b848f4b637ffbd72128ec5ef41592b2bcb3567e 100644 (file)
@@ -162,7 +162,7 @@ xfs_qm_dqpurge(
                 */
                error = xfs_qm_dqflush(dqp, &bp);
                if (error) {
-                       xfs_warn(mp, "%s: dquot %p flush failed",
+                       xfs_warn(mp, "%s: dquot "PTR_FMT" flush failed",
                                __func__, dqp);
                } else {
                        error = xfs_bwrite(bp);
@@ -480,7 +480,7 @@ xfs_qm_dquot_isolate(
 
                error = xfs_qm_dqflush(dqp, &bp);
                if (error) {
-                       xfs_warn(dqp->q_mount, "%s: dquot %p flush failed",
+                       xfs_warn(dqp->q_mount, "%s: dquot "PTR_FMT" flush failed",
                                 __func__, dqp);
                        goto out_unlock_dirty;
                }