Re: [PATCH 3/3] xfs: use %px for data pointers when debugging

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 10, 2018 at 10:04:09AM +1100, Dave Chinner wrote:
> On Tue, Jan 09, 2018 at 12:46:11PM -0800, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> > 
> > 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@xxxxxxxxxx>
> 
> It sucks to have to play games like this, but we have to be able to
> debug the code somehow....
> 
> > diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
> > index fd03780..0949bab 100644
> > --- a/fs/xfs/xfs_linux.h
> > +++ b/fs/xfs/xfs_linux.h
> > @@ -291,4 +291,10 @@ static inline uint64_t howmany_64(uint64_t x, uint32_t y)
> >  #define XFS_IS_REALTIME_MOUNT(mp) (0)
> >  #endif
> >  
> > +#ifdef DEBUG
> > +# define PTR_FMT "%px"
> > +#else
> > +# define PTR_FMT "%p"
> > +#endif
> 
> Can you add a comment here explaining why this is different?

/*
 * 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.
 */

--D

> 
> Otherwise it looks OK.
> 
> Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx>
> -- 
> Dave Chinner
> david@xxxxxxxxxxxxx
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux