cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Bob Peterson <rpeterso@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [fsck.gfs2 patch] fsck.gfs2: Change basic dentry checks for too long of file names
Date: Fri, 9 Jan 2015 14:14:08 -0500 (EST)	[thread overview]
Message-ID: <1013707670.6840364.1420830848488.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1271926811.6839573.1420830748659.JavaMail.zimbra@redhat.com>

Hi,

This is the first in a series of patches to fsck.gfs2. I've uncovered some
problems during recent testing, and these patches fix them.

This patch adds a check to the basic dentry check such that it will reject
any dirents that have a file name more than the maximum allowed.

Regards,

Bob Peterson
Red Hat File Systems

Signed-off-by: Bob Peterson <rpeterso@redhat.com> 
---
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 1559d8e..bdcf77c 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -468,7 +468,8 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 		}
 	}
 
-	if (de->de_rec_len < GFS2_DIRENT_SIZE(de->de_name_len)) {
+	if (de->de_rec_len < GFS2_DIRENT_SIZE(de->de_name_len) ||
+	    de->de_name_len > GFS2_FNAMESIZE) {
 		log_err( _("Dir entry with bad record or name length\n"
 			"\tRecord length = %u\n\tName length = %u\n"),
 			de->de_rec_len, de->de_name_len);
@@ -476,9 +477,12 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
 			log_err( _("Directory entry not fixed.\n"));
 			return 0;
 		}
+		/* Don't be tempted to do this:
 		fsck_blockmap_set(ip, ip->i_di.di_num.no_addr,
 				  _("corrupt directory entry"),
 				  gfs2_inode_invalid);
+		We can't free it because another dir may have a valid reference
+		to it. Just return 1 so we can delete the bad dirent. */
 		log_err( _("Bad directory entry deleted.\n"));
 		return 1;
 	}



           reply	other threads:[~2015-01-09 19:14 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1271926811.6839573.1420830748659.JavaMail.zimbra@redhat.com>]

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=1013707670.6840364.1420830848488.JavaMail.zimbra@redhat.com \
    --to=rpeterso@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).