public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Kalpak Shah <kalpak-KYPl3Ael/zSakBO8gow8eQ@public.gmane.org>
To: Peter Staubach <staubach-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Lustre-discuss
	<Lustre-discuss-KYPl3Ael/zSakBO8gow8eQ@public.gmane.org>,
	linux-ext4 <linux-ext4-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	tytso <tytso-3s7WtUTddSA@public.gmane.org>,
	Andreas Dilger <adilger-KYPl3Ael/zSakBO8gow8eQ@public.gmane.org>
Subject: Re: [PATCH] Correction to check_filetype()
Date: Wed, 21 Feb 2007 20:56:18 +0530	[thread overview]
Message-ID: <1172071578.5928.8.camel@garfield> (raw)
In-Reply-To: <45DC5BFF.4000302-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

Hi Peter,

Thanks for pointing out the typo. In the kernel, struct ext3_dir_entry_2 has a 8-bit name_len field followed by 8-bit field for filetype. Whereas in e2fsck, struct ext2_dir_entry has a 16-bit name_len field, the upper 8 bits of which store the filetype. Hence e2fsck masks the upper 8 bits while using name_len.

Here is the patch with the change.


Signed-off-by: Andreas Dilger <adilger-KYPl3Ael/zSakBO8gow8eQ@public.gmane.org>
Signed-off-by: Kalpak Shah <kalpak-KYPl3Ael/zSakBO8gow8eQ@public.gmane.org>


Index: e2fsprogs-1.39/e2fsck/pass2.c
===================================================================
--- e2fsprogs-1.39.orig/e2fsck/pass2.c
+++ e2fsprogs-1.39/e2fsck/pass2.c
@@ -495,7 +495,9 @@ static _INLINE_ int check_filetype(e2fsc
                return 1;
        }

-       if (ext2fs_test_inode_bitmap(ctx->inode_dir_map, dirent->inode)) {
+       if (ext2fs_test_inode_bitmap(ctx->inode_dir_map, dirent->inode) ||
+           ((dirent->name_len & 0xFF) <= 2 && dirent->name[0] == '.' &&
+            (dirent->name[1] == '.' || dirent->name[1] == '\0'))) {
                should_be = EXT2_FT_DIR;
        } else if (ext2fs_test_inode_bitmap(ctx->inode_reg_map,
                                            dirent->inode)) {

Thanks,
Kalpak Shah. <kalpak-KYPl3Ael/zSakBO8gow8eQ@public.gmane.org>


On Wed, 2007-02-21 at 09:49 -0500, Peter Staubach wrote:
> Kalpak Shah wrote:
> > Hi,
> >
> > If the mode of a directory gets corrupted, check_filetype() makes wrong decisions for all its sub-directories. For example, using debugfs we can corrupt the mode of a directory to 0140755 (i.e. a socket). e2fsck will set the filetype of all its subdirectories as 6 (filetype for socket). All the subdirectories would be moved to lost+found, and in second run of e2fsck their filetype would be set back to 2.
> >
> > By the time we come to check_filetype(), we have already verified the "." and ".." entries, so we special case these dirents in check_filetype().
> >
> > Please consider for review.
> >
> > Signed-off-by: Andreas Dilger <adilger-KYPl3Ael/zSakBO8gow8eQ@public.gmane.org>
> > Signed-off-by: Kalpak Shah <kalpak-KYPl3Ael/zSakBO8gow8eQ@public.gmane.org>
> >
> >
> > Index: e2fsprogs-1.39/e2fsck/pass2.c
> > ===================================================================
> > --- e2fsprogs-1.39.orig/e2fsck/pass2.c
> > +++ e2fsprogs-1.39/e2fsck/pass2.c
> > @@ -495,7 +495,9 @@ static _INLINE_ int check_filetype(e2fsc
> >                 return 1;
> >         }
> >
> > -       if (ext2fs_test_inode_bitmap(ctx->inode_dir_map, dirent->inode)) {
> > +       if (ext2fs_test_inode_bitmap(ctx->inode_dir_map, dirent->inode) ||
> > +           ((dirent->name_len && 0xFF) <= 2 && dirent->name[0] == '.' &&
> >   
> 
> What is the "&& 0xFF" part for?  At the very least, it should probably
> be "& 0xFF".  It doesn't seem like this mask should be needed at all
> though, I think.
> 
>     Thanx...
> 
>        ps
> 
> > +            (dirent->name[1] == '.' || dirent->name[1] == '\0'))) {
> >                 should_be = EXT2_FT_DIR;
> >         } else if (ext2fs_test_inode_bitmap(ctx->inode_reg_map,
> >                                             dirent->inode)) {
> >
> >
> > -
> > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >   

  parent reply	other threads:[~2007-02-21 15:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-21  9:15 [PATCH] Correction to check_filetype() Kalpak Shah
2007-02-21 11:49 ` Kalpak Shah
2007-02-21 14:49 ` Peter Staubach
     [not found]   ` <45DC5BFF.4000302-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2007-02-21 15:26     ` Kalpak Shah [this message]
2007-03-31  0:44 ` Theodore Tso
     [not found]   ` <20070331004417.GJ3198-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2007-03-31  8:16     ` Andreas Dilger
2007-03-31 12:35       ` Theodore Tso
2007-03-31 14:39         ` Theodore Tso
2007-03-31 19:40           ` Kalpak Shah
     [not found]           ` <20070331143926.GG25539-AKGzg7BKzIDYtjvyW6yDsg@public.gmane.org>
2007-04-03 17:37             ` Andreas Dilger
2007-04-03 19:58               ` Theodore Tso

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=1172071578.5928.8.camel@garfield \
    --to=kalpak-kypl3ael/zsakbo8gow8eq@public.gmane.org \
    --cc=Lustre-discuss-KYPl3Ael/zSakBO8gow8eQ@public.gmane.org \
    --cc=adilger-KYPl3Ael/zSakBO8gow8eQ@public.gmane.org \
    --cc=linux-ext4-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=staubach-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=tytso-3s7WtUTddSA@public.gmane.org \
    /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