Merge back earlier cpufreq fixes for v4.4.
[firefly-linux-kernel-4.4.55.git] / fs / xfs / xfs_log_recover.c
index 512a0945d52ac4e023e2181510e70e65f3da04e8..c5ecaacdd21833eed42a4852ce16f9a37d5d1bd6 100644 (file)
@@ -3431,7 +3431,7 @@ xlog_recover_add_to_cont_trans(
         * previous record. Copy the rest of the header.
         */
        if (list_empty(&trans->r_itemq)) {
-               ASSERT(len < sizeof(struct xfs_trans_header));
+               ASSERT(len <= sizeof(struct xfs_trans_header));
                if (len > sizeof(struct xfs_trans_header)) {
                        xfs_warn(log->l_mp, "%s: bad header length", __func__);
                        return -EIO;
@@ -4609,9 +4609,19 @@ xlog_recover(
        int             error;
 
        /* find the tail of the log */
-       if ((error = xlog_find_tail(log, &head_blk, &tail_blk)))
+       error = xlog_find_tail(log, &head_blk, &tail_blk);
+       if (error)
                return error;
 
+       /*
+        * The superblock was read before the log was available and thus the LSN
+        * could not be verified. Check the superblock LSN against the current
+        * LSN now that it's known.
+        */
+       if (xfs_sb_version_hascrc(&log->l_mp->m_sb) &&
+           !xfs_log_check_lsn(log->l_mp, log->l_mp->m_sb.sb_lsn))
+               return -EINVAL;
+
        if (tail_blk != head_blk) {
                /* There used to be a comment here:
                 *