xfs: validate sb_logsunit is a multiple of the fs blocksize
PATCH 1/1 xfs: validate sb_logsunit is a multiple of the fs blocksize
Make sure the log stripe unit is sane before proceeding with mounting. AFAICT this means that logsunit has to be 0, 1, or a multiple of the fs block size. Found this by setting the LSB of logsunit in xfs/350 and watching the system crash as soon as we try to write to the log.
--- fs/xfs/xfs_log.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/xfs/xfs_log.c +6 -0
@@ -659,6 +659,12 @@ xfs_log_mount(XFS_FSB_TO_B (mp, mp->m_sb.sb_logblocks), XFS_MAX_LOG_BYTES); error = -EINVAL ; + }else if (mp->m_sb.sb_logsunit >1 && + mp->m_sb.sb_logsunit % mp->m_sb.sb_blocksize) { +xfs_warn (mp, +"log stripe unit %u bytes must be a multiple of block size" , + mp->m_sb.sb_logsunit); + error = -EINVAL ; }if (error) {if (xfs_sb_version_hascrc (&mp->m_sb)) {
Quoted 15 lines · Darrick J. Wong
Make sure the log stripe unit is sane before proceeding with mounting. AFAICT this means that logsunit has to be 0, 1, or a multiple of the fs block size. Found this by setting the LSB of logsunit in xfs/350 and watching the system crash as soon as we try to write to the log.
Signed-off-by Darrick J. Wong <[email protected]>--- fs/xfs/xfs_log.c | 6 ++++++ 1 file changed, 6 insertions(+)fs/xfs/xfs_log.c +0
-0
fs/xfs/xfs_log.c xfs_log_mount( · line 667
Quoted 9 lines
fs/xfs/xfs_log.c +6
-0@@ -659,6 +659,12 @@ xfs_log_mount(XFS_FSB_TO_B (mp, mp->m_sb.sb_logblocks), XFS_MAX_LOG_BYTES); error = -EINVAL ; + }else if (mp->m_sb.sb_logsunit >1 && + mp->m_sb.sb_logsunit % mp->m_sb.sb_blocksize) { +xfs_warn (mp, +"log stripe unit %u bytes must be a multiple of block size" , + mp->m_sb.sb_logsunit); + error = -EINVAL ;
Looks fine, but I notice that the error handling just below only fails the mount on v5 filesystems. Otherwise we warn and carry on. I'm not sure why that is.. but is this a crash vector on v4 filesystems as well?
Brian
Quoted 7 lines
fs/xfs/xfs_log.c +0
-1}if (error) {if (xfs_sb_version_hascrc (&mp->m_sb)) { --To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 21 lines · Brian Foster
Quoted 20 lines · Darrick J. Wong
Make sure the log stripe unit is sane before proceeding with mounting. AFAICT this means that logsunit has to be 0, 1, or a multiple of the fs block size. Found this by setting the LSB of logsunit in xfs/350 and watching the system crash as soon as we try to write to the log.
Signed-off-by Darrick J. Wong <[email protected]>--- fs/xfs/xfs_log.c | 6 ++++++ 1 file changed, 6 insertions(+)fs/xfs/xfs_log.c +2
-0@@ -659,6 +659,12 @@ xfs_log_mount(XFS_FSB_TO_B (mp, mp->m_sb.sb_logblocks), XFS_MAX_LOG_BYTES); error = -EINVAL ; + }else if (mp->m_sb.sb_logsunit >1 && + mp->m_sb.sb_logsunit % mp->m_sb.sb_blocksize) {
Quoted 8 lines
fs/xfs/xfs_log.c xfs_log_mount( · line 667
Quoted 4 lines
fs/xfs/xfs_log.c +4
-0+xfs_warn (mp, +"log stripe unit %u bytes must be a multiple of block size" , + mp->m_sb.sb_logsunit); + error = -EINVAL ;Looks fine, but I notice that the error handling just below only fails the mount on v5 filesystems. Otherwise we warn and carry on. I'm not sure why that is.. but is this a crash vector on v4 filesystems as well?
It is a crash vector on v4 as well, so I'll be stricter about failing the mount. I was trying to be cautious about this since there haven't
been general complaints about v4 filesystems, but ... eh. A crash is a
crash. :)
--D
Quoted 14 lines
Brian
Quoted 7 lines
fs/xfs/xfs_log.c +0
-1}if (error) {if (xfs_sb_version_hascrc (&mp->m_sb)) { --To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html