]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: explicitly pass buffer size to xfs_corruption_error
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 28 Jun 2018 20:11:58 +0000 (15:11 -0500)
committerEric Sandeen <sandeen@redhat.com>
Thu, 28 Jun 2018 20:11:58 +0000 (15:11 -0500)
Source kernel commit: 2551a53053de52993be8752731f084fad3cfc4d8

Explicitly pass the buffer length to xfs_corruption_error() instead of
assuming XFS_CORRUPTION_DUMP_LEN so that we avoid dumping off the end
of the buffer.

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_btree.c
libxfs/xfs_da_btree.c
libxfs/xfs_dir2_data.c
libxfs/xfs_dir2_leaf.c
libxfs/xfs_dir2_node.c

index 4c15a21ad8ea240d432c9fa664bde0037c16b292..31c13cec1bf4606a523dbb79e99aba5b1fd438b6 100644 (file)
@@ -138,12 +138,12 @@ enum ce { CE_DEBUG, CE_CONT, CE_NOTE, CE_WARN, CE_ALERT, CE_PANIC };
 
 /* stop unused var warnings by assigning mp to itself */
 
-#define xfs_corruption_error(fu,e,l,mp,fi,ln,fa)       do { \
+#define xfs_corruption_error(e,l,mp,b,sz,fi,ln,fa)     do { \
        (mp) = (mp); \
        cmn_err(CE_ALERT, "%s: XFS_CORRUPTION_ERROR", (e));  \
 } while (0)
 
-#define XFS_CORRUPTION_ERROR(e,l,mp,m) do { \
+#define XFS_CORRUPTION_ERROR(e, lvl, mp, buf, bufsize) do { \
        (mp) = (mp); \
        cmn_err(CE_ALERT, "%s: XFS_CORRUPTION_ERROR", (e));  \
 } while (0)
index 5f899f772c9edf12918ae780d0c1e757b1fb65f3..6a15ad5f251a025b1d2ef92c0e3dbc90212b0646 100644 (file)
@@ -1928,7 +1928,8 @@ xfs_btree_lookup(
                                if (level != 0 || cur->bc_nlevels != 1) {
                                        XFS_CORRUPTION_ERROR(__func__,
                                                        XFS_ERRLEVEL_LOW,
-                                                       cur->bc_mp, block);
+                                                       cur->bc_mp, block,
+                                                       sizeof(*block));
                                        return -EFSCORRUPTED;
                                }
 
index 5f71d817f6aef0fc07eea3d3e07236b4235f2e33..467e96dc9e350522b3435fe6cf84991cb3415946 100644 (file)
@@ -301,7 +301,7 @@ xfs_da3_node_read(
                        break;
                default:
                        XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW,
-                                       tp->t_mountp, info);
+                                       tp->t_mountp, info, sizeof(*info));
                        xfs_trans_brelse(tp, *bpp);
                        *bpp = NULL;
                        return -EFSCORRUPTED;
index 4eeb92a28e9b9a588fa0d20bc2133e40d4cb5ccd..3fd8307d859a555c94daa9166fcbc6f069628514 100644 (file)
@@ -248,7 +248,8 @@ xfs_dir3_data_check(
        if (!fa)
                return;
        xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, dp->i_mount,
-                       bp->b_addr, __FILE__, __LINE__, fa);
+                       bp->b_addr, BBTOB(bp->b_length), __FILE__, __LINE__,
+                       fa);
        ASSERT(0);
 }
 #endif
@@ -1154,7 +1155,7 @@ xfs_dir2_data_use_free(
        return 0;
 corrupt:
        xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, args->dp->i_mount,
-                       hdr, __FILE__, __LINE__, fa);
+                       hdr, sizeof(*hdr), __FILE__, __LINE__, fa);
        return -EFSCORRUPTED;
 }
 
index 006d42ecd66aac837f23a4461ec5491c88a41666..6fd153d7561f3c0e0db3aadaad288b7623e85461 100644 (file)
@@ -78,7 +78,8 @@ xfs_dir3_leaf_check(
        if (!fa)
                return;
        xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, dp->i_mount,
-                       bp->b_addr, __FILE__, __LINE__, fa);
+                       bp->b_addr, BBTOB(bp->b_length), __FILE__, __LINE__,
+                       fa);
        ASSERT(0);
 }
 #else
index f5c6f9a77fa9ab10d87b35e3715b2402f384ec29..b0cdbbd5a56d9982c3806d6b290c53600ff5020f 100644 (file)
@@ -81,7 +81,8 @@ xfs_dir3_leaf_check(
        if (!fa)
                return;
        xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, dp->i_mount,
-                       bp->b_addr, __FILE__, __LINE__, fa);
+                       bp->b_addr, BBTOB(bp->b_length), __FILE__, __LINE__,
+                       fa);
        ASSERT(0);
 }
 #else