22 Aug, 2020

1 commit

  • This is a regression introduced by the patch "migrate from ll_rw_block
    usage to BIO".

    Bio_alloc() is limited to 256 pages (1 Mbyte). This can cause a failure
    when reading 1 Mbyte block filesystems. The problem is a datablock can be
    fully (or almost uncompressed), requiring 256 pages, but, because blocks
    are not aligned to page boundaries, it may require 257 pages to read.

    Bio_kmalloc() can handle 1024 pages, and so use this for the edge
    condition.

    Fixes: 93e72b3c612a ("squashfs: migrate from ll_rw_block usage to BIO")
    Reported-by: Nicolas Prochazka
    Reported-by: Tomoatsu Shimada
    Signed-off-by: Phillip Lougher
    Signed-off-by: Andrew Morton
    Reviewed-by: Guenter Roeck
    Cc: Philippe Liard
    Cc: Christoph Hellwig
    Cc: Adrien Schildknecht
    Cc: Daniel Rosenberg
    Cc:
    Link: http://lkml.kernel.org/r/20200815035637.15319-1-phillip@squashfs.org.uk
    Signed-off-by: Linus Torvalds

    Phillip Lougher
     

25 Jul, 2020

1 commit

  • This is a regression introduced by the "migrate from ll_rw_block usage
    to BIO" patch.

    Squashfs packs structures on byte boundaries, and due to that the length
    field (of the metadata block) may not be fully in the current block.
    The new code rewrote and introduced a faulty check for that edge case.

    Fixes: 93e72b3c612adcaca1 ("squashfs: migrate from ll_rw_block usage to BIO")
    Reported-by: Bernd Amend
    Signed-off-by: Phillip Lougher
    Signed-off-by: Andrew Morton
    Cc: Christoph Hellwig
    Cc: Adrien Schildknecht
    Cc: Guenter Roeck
    Cc: Daniel Rosenberg
    Link: http://lkml.kernel.org/r/20200717195536.16069-1-phillip@squashfs.org.uk
    Signed-off-by: Linus Torvalds

    Phillip Lougher
     

03 Jun, 2020

1 commit

  • ll_rw_block() function has been deprecated in favor of BIO which appears
    to come with large performance improvements.

    This patch decreases boot time by close to 40% when using squashfs for
    the root file-system. This is observed at least in the context of
    starting an Android VM on Chrome OS using crosvm. The patch was tested
    on 4.19 as well as master.

    This patch is largely based on Adrien Schildknecht's patch that was
    originally sent as https://lkml.org/lkml/2017/9/22/814 though with some
    significant changes and simplifications while also taking Phillip
    Lougher's feedback into account, around preserving support for
    FILE_CACHE in particular.

    [akpm@linux-foundation.org: fix build error reported by Randy]
    Link: http://lkml.kernel.org/r/319997c2-5fc8-f889-2ea3-d913308a7c1f@infradead.org
    Signed-off-by: Philippe Liard
    Signed-off-by: Andrew Morton
    Reviewed-by: Christoph Hellwig
    Cc: Adrien Schildknecht
    Cc: Phillip Lougher
    Cc: Guenter Roeck
    Cc: Daniel Rosenberg
    Link: https://chromium.googlesource.com/chromiumos/platform/crosvm
    Link: http://lkml.kernel.org/r/20191106074238.186023-1-pliard@google.com
    Signed-off-by: Linus Torvalds

    Philippe Liard
     

24 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 or at your option any
    later version this program is distributed in the hope that it will
    be useful but without any warranty without even the implied warranty
    of merchantability or fitness for a particular purpose see the gnu
    general public license for more details you should have received a
    copy of the gnu general public license along with this program if
    not write to the free software foundation 51 franklin street fifth
    floor boston ma 02110 1301 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 23 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Kate Stewart
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190520170857.458548087@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

31 Jul, 2018

1 commit

  • Anatoly reports another squashfs fuzzing issue, where the decompression
    parameters themselves are in a compressed block.

    This causes squashfs_read_data() to be called in order to read the
    decompression options before the decompression stream having been set
    up, making squashfs go sideways.

    Reported-by: Anatoly Trosinenko
    Acked-by: Phillip Lougher
    Cc: stable@kernel.org
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

01 Nov, 2016

1 commit


08 Jun, 2016

1 commit


05 Apr, 2016

1 commit

  • PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
    ago with promise that one day it will be possible to implement page
    cache with bigger chunks than PAGE_SIZE.

    This promise never materialized. And unlikely will.

    We have many places where PAGE_CACHE_SIZE assumed to be equal to
    PAGE_SIZE. And it's constant source of confusion on whether
    PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
    especially on the border between fs and mm.

    Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
    breakage to be doable.

    Let's stop pretending that pages in page cache are special. They are
    not.

    The changes are pretty straight-forward:

    - << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> ;

    - >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> ;

    - PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};

    - page_cache_get() -> get_page();

    - page_cache_release() -> put_page();

    This patch contains automated changes generated with coccinelle using
    script below. For some reason, coccinelle doesn't patch header files.
    I've called spatch for them manually.

    The only adjustment after coccinelle is revert of changes to
    PAGE_CAHCE_ALIGN definition: we are going to drop it later.

    There are few places in the code where coccinelle didn't reach. I'll
    fix them manually in a separate patch. Comments and documentation also
    will be addressed with the separate patch.

    virtual patch

    @@
    expression E;
    @@
    - E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
    + E

    @@
    expression E;
    @@
    - E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
    + E

    @@
    @@
    - PAGE_CACHE_SHIFT
    + PAGE_SHIFT

    @@
    @@
    - PAGE_CACHE_SIZE
    + PAGE_SIZE

    @@
    @@
    - PAGE_CACHE_MASK
    + PAGE_MASK

    @@
    expression E;
    @@
    - PAGE_CACHE_ALIGN(E)
    + PAGE_ALIGN(E)

    @@
    expression E;
    @@
    - page_cache_get(E)
    + get_page(E)

    @@
    expression E;
    @@
    - page_cache_release(E)
    + put_page(E)

    Signed-off-by: Kirill A. Shutemov
    Acked-by: Michal Hocko
    Signed-off-by: Linus Torvalds

    Kirill A. Shutemov
     

20 Nov, 2013

2 commits

  • Further generalise the decompressors by adding a page handler
    abstraction. This adds helpers to allow the decompressors
    to access and process the output buffers in an implementation
    independant manner.

    This allows different types of output buffer to be passed
    to the decompressors, with the implementation specific
    aspects handled at decompression time, but without the
    knowledge being held in the decompressor wrapper code.

    This will allow the decompressors to handle Squashfs
    cache buffers, and page cache pages.

    This patch adds the abstraction and an implementation for
    the caches.

    Signed-off-by: Phillip Lougher
    Reviewed-by: Minchan Kim

    Phillip Lougher
     
  • The decompressor interface and code was written from
    the point of view of single-threaded operation. In doing
    so it mixed a lot of single-threaded implementation specific
    aspects into the decompressor code and elsewhere which makes it
    difficult to seamlessly support multiple different decompressor
    implementations.

    This patch does the following:

    1. It removes compressor_options parsing from the decompressor
    init() function. This allows the decompressor init() function
    to be dynamically called to instantiate multiple decompressors,
    without the compressor options needing to be read and parsed each
    time.

    2. It moves threading and all sleeping operations out of the
    decompressors. In doing so, it makes the decompressors
    non-blocking wrappers which only deal with interfacing with
    the decompressor implementation.

    3. It splits decompressor.[ch] into decompressor generic functions
    in decompressor.[ch], and moves the single threaded
    decompressor implementation into decompressor_single.c.

    The result of this patch is Squashfs should now be able to
    support multiple decompressors by adding new decompressor_xxx.c
    files with specialised implementations of the functions in
    decompressor_single.c

    Signed-off-by: Phillip Lougher
    Reviewed-by: Minchan Kim

    Phillip Lougher
     

05 Sep, 2013

1 commit


10 Mar, 2012

1 commit


26 May, 2011

1 commit


26 Jan, 2011

1 commit

  • Fix potential use of uninitialised variable caused by recent
    decompressor code optimisations.

    In zlib_uncompress (zlib_wrapper.c) we have

    int zlib_err, zlib_init = 0;
    ...
    do {
    ...
    if (avail == 0) {
    offset = 0;
    put_bh(bh[k++]);
    continue;
    }
    ...
    zlib_err = zlib_inflate(stream, Z_SYNC_FLUSH);
    ...
    } while (zlib_err == Z_OK);

    If continue is executed (avail == 0) then the while condition will be
    evaluated testing zlib_err, which is uninitialised first time around the
    loop.

    Fix this by getting rid of the 'if (avail == 0)' condition test, this
    edge condition should not be being handled in the decompressor code, and
    instead handle it generically in the caller code.

    Similarly for xz_wrapper.c.

    Incidentally, on most architectures (bar Mips and Parisc), no
    uninitialised variable warning is generated by gcc, this is because the
    while condition test on continue is optimised out and not performed
    (when executing continue zlib_err has not been changed since entering
    the loop, and logically if the while condition was true previously, then
    it's still true).

    Signed-off-by: Phillip Lougher
    Reported-by: Jesper Juhl
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Phillip Lougher
     

14 Jan, 2011

1 commit


25 Apr, 2010

1 commit

  • Sizing the buffer based on block size is incorrect, leading
    to a potential buffer over-run on 4K block size file systems
    (because the metadata block size is always 8K). This bug
    doesn't seem have triggered because 4K block size file systems
    are not default, and also because metadata blocks after
    compression tend to be less than 4K.

    Signed-off-by: Phillip Lougher

    Phillip Lougher
     

21 Jan, 2010

3 commits


12 Mar, 2009

1 commit

  • The corrupted filesystem patch added a check against zlib trying to
    output too much data in the presence of data corruption. This check
    triggered if zlib_inflate asked to be called again (Z_OK) with
    avail_out == 0 and no more output buffers available. This check proves
    to be rather dumb, as it incorrectly catches the case where zlib has
    generated all the output, but there are still input bytes to be processed.

    This patch does a number of things. It removes the original check and
    replaces it with code to not move to the next output buffer if there
    are no more output buffers available, relying on zlib to error if it
    wants an extra output buffer in the case of data corruption. It
    also replaces the Z_NO_FLUSH flag with the more correct Z_SYNC_FLUSH
    flag, and makes the error messages more understandable to
    non-technical users.

    Signed-off-by: Phillip Lougher
    Reported-by: Stefan Lippers-Hollmann

    Phillip Lougher
     

05 Mar, 2009

1 commit


05 Jan, 2009

1 commit