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]
Message-Id: <08322694-9793-437D-8CD3-B8A7C5DEACFA@dilger.ca>
Date:   Fri, 18 Dec 2020 15:03:33 -0700
From:   Andreas Dilger <adilger@...ger.ca>
To:     "Lyashkov, Alexey" <alexey.lyashkov@....com>
Cc:     "Theodore Y. Ts'o" <tytso@....edu>,
        Благодаренко Артём 
        <artem.blagodarenko@...il.com>,
        "linux-ext4@...r.kernel.org" <linux-ext4@...r.kernel.org>
Subject: Re: [PATCH] libfs: Fix DIO mode aligment

On Nov 19, 2020, at 5:26 AM, Lyashkov, Alexey <alexey.lyashkov@....com> wrote:
> 
> Tso,
> 
> This situation hit with modern hdd with 4k block size and e2image changed to use DIRECT IO instead of buffered.

It would be useful to include this patch for e2image as part of this submission,
so that this can be tested.  I suspect that O_DIRECT would be useful for other
tools (e.g. e2fsck, debugfs, etc.) since the IO manager would avoid double
buffering the data in both the kernel and userspace.

> e2fsprogs tries to read a super lock on offset 1k and it caused to set FS block size to 1k and second block reading.
> (many other places exist, but it simplest).

Are there actually other places where it is doing sub-block-size reads from disk?

It seems simpler to fix the superblock read at open to always read the first 4KB
into a buffer (and to make it easy to extend to 16KB or 64KB if sector sizes get
even larger), then find the superblock within the buffer to decide the blocksize.

That avoids the short/unaligned read from disk when opening the filesystem, without
the need to add complexity to the reading code to buffer all unaligned reads, for
a case that doesn't seem likely otherwise.  The only other possibility I can think
that would need this is a small-block filesystem image (e.g. 1KB) copied to a
large-sector device?  It isn't clear if the kernel would be able to mount that...

Cheers, Andreas

>        if (superblock) {
>                if (!block_size) {
>                        retval = EXT2_ET_INVALID_ARGUMENT;
>                        goto cleanup;
>                }
>                io_channel_set_blksize(fs->io, block_size);
>                group_block = superblock;
>                fs->orig_super = 0;
>        } else {
>                io_channel_set_blksize(fs->io, SUPERBLOCK_OFFSET); <<<<< this is problem
>                superblock = 1;
>                group_block = 0;
>                retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &fs->orig_super);
>                if (retval)
>                        goto cleanup;
>        }
>        retval = io_channel_read_blk(fs->io, superblock, -SUPERBLOCK_SIZE,
>                                     fs->super);
> 
> It caused errors like
> # e2image -Q /dev/md65 /tmp/node05_image_out
> e2image 1.45.6.cr1 (14-Aug-2020)
> e2image: Attempt to read block from filesystem resulted in short read while trying to open /dev/md65
> Couldn’t find valid filesystem superblock.
> 
> It looks like I don't first person to found a bug, as someone was add
> 
> Alex
> 
> On 17/11/2020, 22:19, "Theodore Y. Ts'o" <tytso@....edu> wrote:
> 
>    On Tue, Nov 17, 2020 at 06:30:11PM +0300, Благодаренко Артём wrote:
>> Hello,
>> 
>> Any thoughts about this change? Thanks.
> 
>    I'm trying to think of situations where this could actually trigger in
>    real life.  The only one I can think of is if a file system with a 1k
>    block file system is located on an an Advanced FormatDrive with a 4k
>    sector size.
> 
>    What was the use case where this was actually an issue?
> 
>         	     	      	    	     - Ted
> 


Cheers, Andreas






Download attachment "signature.asc" of type "application/pgp-signature" (874 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ