All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Tinguely <tinguely@sgi.com>
To: XFS Filesystem <xfs@oss.sgi.com>
Subject: [PATCH] xfsprogs: fix xfs_logprint EFI entry split on log buffer
Date: Wed, 09 Apr 2014 16:00:14 -0500	[thread overview]
Message-ID: <20140409210048.859660076@sgi.com> (raw)
In-Reply-To: 20140409210013.095709266@sgi.com

[-- Attachment #1: xfsprogs-xfs_logprint-fix-efi-entries-contiued-on-next-buf.patch --]
[-- Type: text/plain, Size: 4804 bytes --]

xfs_logprint does not correctly handle EFI entries that
are split across two log buffers. xfs_efi_copy_format()
falsely interrupts the truncated size of the split entry
as being a corrupt entry.

If the first log entry has enough information, namely the
number of extents in the entry and the identifier, then
display this information and a warning that this entry is
truncated. Otherwise, if there is not enough information in
the first log buffer, then print a message that the EFI decode
was not possible. These messages are similar to split inode
entries.

Example of a continued entry:
Oper (336): tid: f214bdb  len: 44  clientid: TRANS  flags: CONTINUE
EFI:  #regs: 1    num_extents: 2  id: 0xffff880804f63900
EFI free extent data skipped (CONTINUE set, no space)

Reported-by: Michael L. Semon <mlsemon35@gmail.com>
Signed-off-by: Mark Tinguely <tinguely@sgi.com>
---
 logprint/log_misc.c      |   31 ++++++++++++++++++++++++++-----
 logprint/log_print_all.c |    2 +-
 logprint/logprint.h      |    2 +-
 3 files changed, 28 insertions(+), 7 deletions(-)

Index: b/logprint/log_misc.c
===================================================================
--- a/logprint/log_misc.c
+++ b/logprint/log_misc.c
@@ -477,13 +477,17 @@ xlog_print_trans_efd(xfs_caddr_t *ptr, u
 
 
 int
-xlog_print_trans_efi(xfs_caddr_t *ptr, uint src_len)
+xlog_print_trans_efi(
+	xfs_caddr_t *ptr,
+	uint src_len,
+	int continued)
 {
     xfs_efi_log_format_t *src_f, *f;
     uint		 dst_len;
     xfs_extent_t	 *ex;
     int			 i;
     int			 error = 0;
+    int			 core_size = offsetof(xfs_efi_log_format_t, efi_extents);
 
     /*
      * memmove to ensure 8-byte alignment for the long longs in
@@ -498,17 +502,29 @@ xlog_print_trans_efi(xfs_caddr_t *ptr, u
 
     /* convert to native format */
     dst_len = sizeof(xfs_efi_log_format_t) + (src_f->efi_nextents - 1) * sizeof(xfs_extent_t);
+
+    if (continued && src_len < core_size) {
+	printf(_("EFI: Not enough data to decode further\n"));
+	return 1;
+    }
+
     if ((f = (xfs_efi_log_format_t *)malloc(dst_len)) == NULL) {
 	fprintf(stderr, _("%s: xlog_print_trans_efi: malloc failed\n"), progname);
 	exit(1);
     }
-    if (xfs_efi_copy_format((char*)src_f, src_len, f)) {
+    if (xfs_efi_copy_format((char*)src_f, src_len, f, continued)) {
 	error = 1;
 	goto error;
     }
 
     printf(_("EFI:  #regs: %d    num_extents: %d  id: 0x%llx\n"),
 	   f->efi_size, f->efi_nextents, (unsigned long long)f->efi_id);
+
+    if (continued) {
+	printf(_("EFI free extent data skipped (CONTINUE set, no space)\n"));
+	goto error;
+    }
+
     ex = f->efi_extents;
     for (i=0; i < f->efi_nextents; i++) {
 	    printf("(s: 0x%llx, l: %d) ",
@@ -1034,7 +1050,8 @@ xlog_print_record(
 		    }
 		    case XFS_LI_EFI: {
 			skip = xlog_print_trans_efi(&ptr,
-					be32_to_cpu(op_head->oh_len));
+					be32_to_cpu(op_head->oh_len),
+					continued);
 			break;
 		    }
 		    case XFS_LI_EFD: {
@@ -1572,7 +1589,11 @@ xfs_inode_item_format_convert(char *src_
 }
 
 int
-xfs_efi_copy_format(char *buf, uint len, xfs_efi_log_format_t *dst_efi_fmt)
+xfs_efi_copy_format(
+	char			  *buf,
+	uint			  len,
+	struct xfs_efi_log_format *dst_efi_fmt,
+	int			  continued)
 {
         uint i;
 	uint nextents = ((xfs_efi_log_format_t *)buf)->efi_nextents;
@@ -1580,7 +1601,7 @@ xfs_efi_copy_format(char *buf, uint len,
         uint len32 = sizeof(xfs_efi_log_format_32_t) + (nextents - 1) * sizeof(xfs_extent_32_t);
         uint len64 = sizeof(xfs_efi_log_format_64_t) + (nextents - 1) * sizeof(xfs_extent_64_t);
 
-        if (len == dst_len) {
+        if (len == dst_len || continued) {
                 memcpy((char *)dst_efi_fmt, buf, len);
                 return 0;
         } else if (len == len32) {
Index: b/logprint/log_print_all.c
===================================================================
--- a/logprint/log_print_all.c
+++ b/logprint/log_print_all.c
@@ -411,7 +411,7 @@ xlog_recover_print_efi(
 	    fprintf(stderr, _("%s: xlog_recover_print_efi: malloc failed\n"), progname);
 	    exit(1);
 	}
-	if (xfs_efi_copy_format((char*)src_f, src_len, f)) {
+	if (xfs_efi_copy_format((char*)src_f, src_len, f, 0)) {
 	    free(f);
 	    return;
 	}
Index: b/logprint/logprint.h
===================================================================
--- a/logprint/logprint.h
+++ b/logprint/logprint.h
@@ -47,6 +47,6 @@ extern void print_stars(void);
 
 extern xfs_inode_log_format_t *
 	xfs_inode_item_format_convert(char *, uint, xfs_inode_log_format_t *);
-extern int xfs_efi_copy_format(char *, uint, xfs_efi_log_format_t *);
+extern int xfs_efi_copy_format(char *, uint, xfs_efi_log_format_t *, int);
 
 #endif	/* LOGPRINT_H */


_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

       reply	other threads:[~2014-04-09 21:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20140409210013.095709266@sgi.com>
2014-04-09 21:00 ` Mark Tinguely [this message]
2014-04-14  1:42   ` [PATCH] xfsprogs: fix xfs_logprint EFI entry split on log buffer Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140409210048.859660076@sgi.com \
    --to=tinguely@sgi.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.