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
     

04 Mar, 2013

1 commit

  • Modify the request_module to prefix the file system type with "fs-"
    and add aliases to all of the filesystems that can be built as modules
    to match.

    A common practice is to build all of the kernel code and leave code
    that is not commonly needed as modules, with the result that many
    users are exposed to any bug anywhere in the kernel.

    Looking for filesystems with a fs- prefix limits the pool of possible
    modules that can be loaded by mount to just filesystems trivially
    making things safer with no real cost.

    Using aliases means user space can control the policy of which
    filesystem modules are auto-loaded by editing /etc/modprobe.d/*.conf
    with blacklist and alias directives. Allowing simple, safe,
    well understood work-arounds to known problematic software.

    This also addresses a rare but unfortunate problem where the filesystem
    name is not the same as it's module name and module auto-loading
    would not work. While writing this patch I saw a handful of such
    cases. The most significant being autofs that lives in the module
    autofs4.

    This is relevant to user namespaces because we can reach the request
    module in get_fs_type() without having any special permissions, and
    people get uncomfortable when a user specified string (in this case
    the filesystem type) goes all of the way to request_module.

    After having looked at this issue I don't think there is any
    particular reason to perform any filtering or permission checks beyond
    making it clear in the module request that we want a filesystem
    module. The common pattern in the kernel is to call request_module()
    without regards to the users permissions. In general all a filesystem
    module does once loaded is call register_filesystem() and go to sleep.
    Which means there is not much attack surface exposed by loading a
    filesytem module unless the filesystem is mounted. In a user
    namespace filesystems are not mounted unless .fs_flags = FS_USERNS_MOUNT,
    which most filesystems do not set today.

    Acked-by: Serge Hallyn
    Acked-by: Kees Cook
    Reported-by: Kees Cook
    Signed-off-by: "Eric W. Biederman"

    Eric W. Biederman
     

14 Jul, 2012

1 commit

  • Pass mount flags to sget() so that it can use them in initialising a new
    superblock before the set function is called. They could also be passed to the
    compare function.

    Signed-off-by: David Howells
    Signed-off-by: Al Viro

    David Howells
     

21 Mar, 2012

3 commits


28 Jan, 2012

2 commits

  • Or hit an assertion in map_invalidatepage() instead.

    Signed-off-by: Joern Engel

    Joern Engel
     
  • While unmounting the file system LogFS calls generic_shutdown_super.
    The function does file system independent superblock shutdown.
    However, it might result in call file system specific inode eviction.

    LogFS marks FS shutting down by setting bit LOGFS_SB_FLAG_SHUTDOWN in
    super->s_flags. Since, inode eviction might call truncate on inode,
    following BUG is observed when file system is unmounted:

    ------------[ cut here ]------------
    kernel BUG at /home/prasad/logfs/segment.c:362!
    invalid opcode: 0000 [#1] PREEMPT SMP
    CPU 3
    Modules linked in: logfs binfmt_misc ppdev virtio_blk parport_pc lp
    parport psmouse floppy virtio_pci serio_raw virtio_ring virtio

    Pid: 1933, comm: umount Not tainted 3.0.0+ #4 Bochs Bochs
    RIP: 0010:[] []
    logfs_segment_write+0x211/0x230 [logfs]
    RSP: 0018:ffff880062d7b9e8 EFLAGS: 00010202
    RAX: 000000000000000e RBX: ffff88006eca9000 RCX: 0000000000000000
    RDX: ffff88006fd87c40 RSI: ffffea00014ff468 RDI: ffff88007b68e000
    RBP: ffff880062d7ba48 R08: 8000000020451430 R09: 0000000000000000
    R10: dead000000100100 R11: 0000000000000000 R12: ffff88006fd87c40
    R13: ffffea00014ff468 R14: ffff88005ad0a460 R15: 0000000000000000
    FS: 00007f25d50ea760(0000) GS:ffff88007fd80000(0000)
    knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
    CR2: 0000000000d05e48 CR3: 0000000062c72000 CR4: 00000000000006e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
    Process umount (pid: 1933, threadinfo ffff880062d7a000,
    task ffff880070b44500)
    Stack:
    ffff880062d7ba38 ffff88005ad0a508 0000000000001000 0000000000000000
    8000000020451430 ffffea00014ff468 ffff880062d7ba48 ffff88005ad0a460
    ffff880062d7bad8 ffffea00014ff468 ffff88006fd87c40 0000000000000000
    Call Trace:
    [] logfs_write_i0+0x12e/0x190 [logfs]
    [] __logfs_write_rec+0x140/0x220 [logfs]
    [] __logfs_write_rec+0xf2/0x220 [logfs]
    [] logfs_write_rec+0x64/0xd0 [logfs]
    [] __logfs_write_buf+0x106/0x110 [logfs]
    [] logfs_write_buf+0x4e/0x80 [logfs]
    [] __logfs_write_inode+0x98/0x110 [logfs]
    [] logfs_truncate+0x54/0x290 [logfs]
    [] logfs_evict_inode+0xdc/0x190 [logfs]
    [] evict+0x85/0x170
    [] iput+0xe6/0x1b0
    [] shrink_dcache_for_umount_subtree+0x218/0x280
    [] shrink_dcache_for_umount+0x51/0x90
    [] generic_shutdown_super+0x2c/0x100
    [] logfs_kill_sb+0x57/0xf0 [logfs]
    [] deactivate_locked_super+0x45/0x70
    [] deactivate_super+0x4a/0x70
    [] mntput_no_expire+0xa4/0xf0
    [] sys_umount+0x6f/0x380
    [] system_call_fastpath+0x16/0x1b
    Code: 55 c8 49 8d b6 a8 00 00 00 45 89 f9 45 89 e8 4c 89 e1 4c 89 55
    b8 c7 04 24 00 00 00 00 e8 68 fc ff ff 4c 8b 55 b8 e9 3c ff ff ff
    0b 0f 0b c7 45 c0 00 00 00 00 e9 44 fe ff ff 66 66 66 66 66
    RIP [] logfs_segment_write+0x211/0x230 [logfs]
    RSP
    ---[ end trace fe6b040cea952290 ]---

    Therefore, move super->s_flags setting after the fs-indenpendent work
    has been finished.

    Reviewed-by: Joern Engel
    Signed-off-by: Prasad Joshi

    Prasad Joshi
     

07 Nov, 2011

1 commit

  • * 'modsplit-Oct31_2011' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux: (230 commits)
    Revert "tracing: Include module.h in define_trace.h"
    irq: don't put module.h into irq.h for tracking irqgen modules.
    bluetooth: macroize two small inlines to avoid module.h
    ip_vs.h: fix implicit use of module_get/module_put from module.h
    nf_conntrack.h: fix up fallout from implicit moduleparam.h presence
    include: replace linux/module.h with "struct module" wherever possible
    include: convert various register fcns to macros to avoid include chaining
    crypto.h: remove unused crypto_tfm_alg_modname() inline
    uwb.h: fix implicit use of asm/page.h for PAGE_SIZE
    pm_runtime.h: explicitly requires notifier.h
    linux/dmaengine.h: fix implicit use of bitmap.h and asm/page.h
    miscdevice.h: fix up implicit use of lists and types
    stop_machine.h: fix implicit use of smp.h for smp_processor_id
    of: fix implicit use of errno.h in include/linux/of.h
    of_platform.h: delete needless include
    acpi: remove module.h include from platform/aclinux.h
    miscdevice.h: delete unnecessary inclusion of module.h
    device_cgroup.h: delete needless include
    net: sch_generic remove redundant use of
    net: inet_timewait_sock doesnt need
    ...

    Fix up trivial conflicts (other header files, and removal of the ab3550 mfd driver) in
    - drivers/media/dvb/frontends/dibx000_common.c
    - drivers/media/video/{mt9m111.c,ov6650.c}
    - drivers/mfd/ab3550-core.c
    - include/linux/dmaengine.h

    Linus Torvalds
     

01 Nov, 2011

2 commits

  • memchr_inv() is mainly used to check whether the whole buffer is filled
    with just a specified byte.

    The function name and prototype are stolen from logfs and the
    implementation is from SLUB.

    Signed-off-by: Akinobu Mita
    Acked-by: Christoph Lameter
    Acked-by: Pekka Enberg
    Cc: Matt Mackall
    Acked-by: Joern Engel
    Cc: Marcin Slusarz
    Cc: Eric Dumazet
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Akinobu Mita
     
  • Some files were using the complete module.h infrastructure without
    actually including the header at all. Fix them up in advance so
    once the implicit presence is removed, we won't get failures like this:

    CC [M] fs/nfsd/nfssvc.o
    fs/nfsd/nfssvc.c: In function 'nfsd_create_serv':
    fs/nfsd/nfssvc.c:335: error: 'THIS_MODULE' undeclared (first use in this function)
    fs/nfsd/nfssvc.c:335: error: (Each undeclared identifier is reported only once
    fs/nfsd/nfssvc.c:335: error: for each function it appears in.)
    fs/nfsd/nfssvc.c: In function 'nfsd':
    fs/nfsd/nfssvc.c:555: error: implicit declaration of function 'module_put_and_exit'
    make[3]: *** [fs/nfsd/nfssvc.o] Error 1

    Signed-off-by: Paul Gortmaker

    Paul Gortmaker
     

04 May, 2011

1 commit

  • In particular, s_freeing_list needs to be initialized early, since it is
    used on some of the error paths when mounts fail. The mapping inode,
    for example, would be initialized and then free'd on an error path
    before s_freeing_list was initialized, but the inode drop operation
    needs the s_freeing_list to be set up.

    Normally you'd never see this, because not only is logfs fairly rare,
    but a successful mount will never have any issues.

    Reported-by: werner
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

29 Oct, 2010

5 commits


10 Aug, 2010

1 commit


18 May, 2010

1 commit

  • * git://git.kernel.org/pub/scm/linux/kernel/git/joern/logfs:
    logfs: handle powerfail on NAND flash
    logfs: handle errors from get_mtd_device()
    logfs: remove unused variable
    logfs: fix sync
    logfs: fix compile failure
    logfs: initialize li->li_refcount
    logfs: commit reservations under space pressure
    logfs: survive logfs_buf_recover read errors
    logfs: Close i_ino reuse race
    logfs: fix logfs_seek_hole()
    logfs: Return -EINVAL if filesystem image doesn't match
    LogFS: Fix typo in b6349ac8
    logfs: testing the wrong variable

    Linus Torvalds
     

15 May, 2010

1 commit


06 May, 2010

1 commit

  • When CONFIG_BLOCK is not enabled:

    fs/logfs/super.c:142: error: implicit declaration of function 'bdev_get_queue'
    fs/logfs/super.c:142: error: invalid type argument of '->' (have 'int')

    Found by Randy Dunlap

    Signed-off-by: Joern Engel

    Joern Engel
     

02 May, 2010

1 commit


29 Apr, 2010

1 commit


22 Apr, 2010

1 commit

  • * git://git.kernel.org/pub/scm/linux/kernel/git/joern/logfs:
    [LogFS] Split large truncated into smaller chunks
    [LogFS] Set s_bdi
    [LogFS] Prevent mempool_destroy NULL pointer dereference
    [LogFS] Move assertion
    [LogFS] Plug 8 byte information leak
    [LogFS] Prevent memory corruption on large deletes
    [LogFS] Remove unused method

    Fix trivial conflict with added header includes in fs/logfs/super.c

    Linus Torvalds
     

18 Apr, 2010

1 commit

  • Since 32a88aa1 sync() was turned into a NOP for logfs. Worse, sync()
    would not return an error, giving the illusion that writeout had
    actually happened.

    Afaics jffs2 was broken as well.

    Signed-off-by: Joern Engel

    Joern Engel
     

15 Apr, 2010

1 commit


13 Apr, 2010

1 commit

  • Removing sufficiently large files would create aliases for a large
    number of segments. This in turn results in a large number of journal
    entries and an overflow of s_je_array.

    Cheap fix is to add a BUG_ON, turning memory corruption into something
    annoying, but less dangerous. Real fix is to count the number of
    affected segments and prevent the problem completely.

    Signed-off-by: Joern Engel

    Joern Engel
     

05 Apr, 2010

1 commit


30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

27 Mar, 2010

4 commits


05 Mar, 2010

3 commits


21 Nov, 2009

1 commit