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: <20200830035300.GX14765@casper.infradead.org>
Date:   Sun, 30 Aug 2020 04:53:00 +0100
From:   Matthew Wilcox <willy@...radead.org>
To:     OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH] fat: Avoid oops when bdi->io_pages==0

On Sun, Aug 30, 2020 at 10:54:35AM +0900, OGAWA Hirofumi wrote:
> Matthew Wilcox <willy@...radead.org> writes:
> 
> > On Sun, Aug 30, 2020 at 09:59:41AM +0900, OGAWA Hirofumi wrote:
> >> On one system, there was bdi->io_pages==0. This seems to be the bug of
> >> a driver somewhere, and should fix it though. Anyway, it is better to
> >> avoid the divide-by-zero Oops.
> >> 
> >> So this check it.
> >> 
> >> Signed-off-by: OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>
> >> Cc: <stable@...r.kernel.org>
> >> ---
> >>  fs/fat/fatent.c |    2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >> 
> >> diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c
> >> index f7e3304..98a1c4f 100644
> >> --- a/fs/fat/fatent.c	2020-08-30 06:52:47.251564566 +0900
> >> +++ b/fs/fat/fatent.c	2020-08-30 06:54:05.838319213 +0900
> >> @@ -660,7 +660,7 @@ static void fat_ra_init(struct super_blo
> >>  	if (fatent->entry >= ent_limit)
> >>  		return;
> >>  
> >> -	if (ra_pages > sb->s_bdi->io_pages)
> >> +	if (sb->s_bdi->io_pages && ra_pages > sb->s_bdi->io_pages)
> >>  		ra_pages = rounddown(ra_pages, sb->s_bdi->io_pages);
> >
> > Wait, rounddown?  ->io_pages is supposed to be the maximum number of
> > pages to readahead.  Shouldn't this be max() instead of rounddown()?

Sorry, I meant 'min', not 'max'.

> Hm, io_pages is limited by driver setting too, and io_pages can be lower
> than ra_pages, e.g. usb storage.
> 
> Assuming ra_pages is user intent of readahead window. So if io_pages is
> lower than ra_pages, this try ra_pages to align of io_pages chunk, but
> not bigger than ra_pages. Because if block layer splits I/O requests to
> hard limit, then I/O is not optimal.
> 
> So it is intent, I can be misunderstanding though.

Looking at this some more, I'm not sure it makes sense to consult ->io_pages
at all.  I see how it gets set to 0 -- the admin can write '1' to
/sys/block/<device>/queue/max_sectors_kb and that gets turned into 0
in ->io_pages.

But I'm not sure it makes any sense to respect that.  Looking at mm/readahead.c, all it does is limit the size of a read request which exceeds the current readahead window.  It's not used to limit the readahead window itself.  For
example:

        unsigned long max_pages = ra->ra_pages;
...
        if (req_size > max_pages && bdi->io_pages > max_pages)
                max_pages = min(req_size, bdi->io_pages);

Setting io_pages below ra_pages has no effect.  So maybe fat should also
disregard it?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ