lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 2 Aug 2023 09:17:05 +0800
From:   Stephen Zhang <starzhangzsd@...il.com>
To:     "Darrick J. Wong" <djwong@...nel.org>
Cc:     tytso@....edu, adilger.kernel@...ger.ca, yi.zhang@...wei.com,
        linux-ext4@...r.kernel.org, linux-kernel@...r.kernel.org,
        zhangshida@...inos.cn, stable@...nel.org,
        Andreas Dilger <adilger@...ger.ca>
Subject: Re: [PATCH v3] ext4: Fix rec_len verify error

Darrick J. Wong <djwong@...nel.org> 于2023年8月1日周二 23:18写道:
>
>
> This is sitll missing some pieces; what about this clause at line 367:
>
>         if (t->det_reserved_zero1 ||
>             le16_to_cpu(t->det_rec_len) != sizeof(struct ext4_dir_entry_tail) ||
>             t->det_reserved_zero2 ||
>             t->det_reserved_ft != EXT4_FT_DIR_CSUM)
>                 return NULL;
>

Yeah...

> > @@ -445,13 +445,13 @@ static struct dx_countlimit *get_dx_countlimit(struct inode *inode,
> >       struct ext4_dir_entry *dp;
> >       struct dx_root_info *root;
> >       int count_offset;
> > +     int blocksize = EXT4_BLOCK_SIZE(inode->i_sb);
> >
> > -     if (le16_to_cpu(dirent->rec_len) == EXT4_BLOCK_SIZE(inode->i_sb))
> > +     if (ext4_rec_len_from_disk(dirent->rec_len, blocksize) == blocksize)
> >               count_offset = 8;
> > -     else if (le16_to_cpu(dirent->rec_len) == 12) {
> > +     else if (ext4_rec_len_from_disk(dirent->rec_len, blocksize) == 12) {
>
> Why not lift this ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ to a
> local variable?  @dirent doesn't change, right?
>

Will do.

> >               dp = (struct ext4_dir_entry *)(((void *)dirent) + 12);
> > -             if (le16_to_cpu(dp->rec_len) !=
> > -                 EXT4_BLOCK_SIZE(inode->i_sb) - 12)
> > +             if (ext4_rec_len_from_disk(dp->rec_len, blocksize) != blocksize - 12)
> >                       return NULL;
> >               root = (struct dx_root_info *)(((void *)dp + 12));
> >               if (root->reserved_zero ||
>
> What about dx_make_map?
>

dx_make_map(
     ....
     map_tail->size = le16_to_cpu(de->rec_len);

That might be a questionable one...
map_tail->size is 16 bit, while the key reason we want ext4_rec_len_from_disk
is converting 16-bit rec_len disk form to a in-memory form consisting of like 17
bits...i.e. 0x10000.

Cheers,
Shida


> Here's all the opencoded access I could find:
>
> $ git grep le16.*rec_len fs/ext4/
> fs/ext4/namei.c:356:                le16_to_cpu(d->rec_len));
> fs/ext4/namei.c:367:        le16_to_cpu(t->det_rec_len) != sizeof(struct ext4_dir_entry_tail) ||
> fs/ext4/namei.c:449:    if (le16_to_cpu(dirent->rec_len) == EXT4_BLOCK_SIZE(inode->i_sb))
> fs/ext4/namei.c:451:    else if (le16_to_cpu(dirent->rec_len) == 12) {
> fs/ext4/namei.c:453:            if (le16_to_cpu(dp->rec_len) !=
> fs/ext4/namei.c:1338:                   map_tail->size = le16_to_cpu(de->rec_len);
>
> --D
>
> > --
> > 2.27.0
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ