26 Jan, 2019

1 commit

  • [ Upstream commit a788c5272769ddbcdbab297cf386413eeac04463 ]

    jffs2_sync_fs makes the assumption that if CONFIG_JFFS2_FS_WRITEBUFFER
    is defined then a write buffer is available and has been initialized.
    However, this does is not the case when the mtd device has no
    out-of-band buffer:

    int jffs2_nand_flash_setup(struct jffs2_sb_info *c)
    {
    if (!c->mtd->oobsize)
    return 0;
    ...

    The resulting call to cancel_delayed_work_sync passing a uninitialized
    (but zeroed) delayed_work struct forces lockdep to become disabled.

    [ 90.050639] overlayfs: upper fs does not support tmpfile.
    [ 90.652264] INFO: trying to register non-static key.
    [ 90.662171] the code is fine but needs lockdep annotation.
    [ 90.673090] turning off the locking correctness validator.
    [ 90.684021] CPU: 0 PID: 1762 Comm: mount_root Not tainted 4.14.63 #0
    [ 90.696672] Stack : 00000000 00000000 80d8f6a2 00000038 805f0000 80444600 8fe364f4 805dfbe7
    [ 90.713349] 80563a30 000006e2 8068370c 00000001 00000000 00000001 8e2fdc48 ffffffff
    [ 90.730020] 00000000 00000000 80d90000 00000000 00000106 00000000 6465746e 312e3420
    [ 90.746690] 6b636f6c 03bf0000 f8000000 20676e69 00000000 80000000 00000000 8e2c2a90
    [ 90.763362] 80d90000 00000001 00000000 8e2c2a90 00000003 80260dc0 08052098 80680000
    [ 90.780033] ...
    [ 90.784902] Call Trace:
    [ 90.789793] [] show_stack+0xb8/0x148
    [ 90.798659] [] register_lock_class+0x270/0x55c
    [ 90.809247] [] __lock_acquire+0x13c/0xf7c
    [ 90.818964] [] lock_acquire+0x194/0x1dc
    [ 90.828345] [] flush_work+0x200/0x24c
    [ 90.837374] [] __cancel_work_timer+0x158/0x210
    [ 90.847958] [] jffs2_sync_fs+0x20/0x54
    [ 90.857173] [] iterate_supers+0xf4/0x120
    [ 90.866729] [] sys_sync+0x44/0x9c
    [ 90.875067] [] syscall_common+0x34/0x58

    Signed-off-by: Daniel Santos
    Reviewed-by: Hou Tao
    Signed-off-by: Boris Brezillon
    Signed-off-by: Sasha Levin

    Daniel Santos
     

14 Nov, 2018

1 commit

  • commit 92e2921f7eee63450a5f953f4b15dc6210219430 upstream.

    When an invalid mount option is passed to jffs2, jffs2_parse_options()
    will fail and jffs2_sb_info will be freed, but then jffs2_sb_info will
    be used (use-after-free) and freeed (double-free) in jffs2_kill_sb().

    Fix it by removing the buggy invocation of kfree() when getting invalid
    mount options.

    Fixes: 92abc475d8de ("jffs2: implement mount option parsing and compression overriding")
    Cc: stable@kernel.org
    Signed-off-by: Hou Tao
    Reviewed-by: Richard Weinberger
    Signed-off-by: Boris Brezillon
    Signed-off-by: Greg Kroah-Hartman

    Hou Tao
     

30 May, 2018

1 commit

  • commit 1e2e547a93a00ebc21582c06ca3c6cfea2a309ee upstream.

    For anything NFS-exported we do _not_ want to unlock new inode
    before it has grown an alias; original set of fixes got the
    ordering right, but missed the nasty complication in case of
    lockdep being enabled - unlock_new_inode() does
    lockdep_annotate_inode_mutex_key(inode)
    which can only be done before anyone gets a chance to touch
    ->i_mutex. Unfortunately, flipping the order and doing
    unlock_new_inode() before d_instantiate() opens a window when
    mkdir can race with open-by-fhandle on a guessed fhandle, leading
    to multiple aliases for a directory inode and all the breakage
    that follows from that.

    Correct solution: a new primitive (d_instantiate_new())
    combining these two in the right order - lockdep annotate, then
    d_instantiate(), then the rest of unlock_new_inode(). All
    combinations of d_instantiate() with unlock_new_inode() should
    be converted to that.

    Cc: stable@kernel.org # 2.6.29 and later
    Tested-by: Mike Marshall
    Reviewed-by: Andreas Dilger
    Signed-off-by: Al Viro
    Signed-off-by: Greg Kroah-Hartman

    Al Viro
     

26 Apr, 2018

1 commit

  • [ Upstream commit 5bdd0c6f89fba430e18d636493398389dadc3b17 ]

    If jffs2_iget() fails for a newly-allocated inode, jffs2_do_clear_inode()
    can get called twice in the error handling path, the first call in
    jffs2_iget() itself and the second through iget_failed(). This can result
    to a use-after-free error in the second jffs2_do_clear_inode() call, such
    as shown by the oops below wherein the second jffs2_do_clear_inode() call
    was trying to free node fragments that were already freed in the first
    jffs2_do_clear_inode() call.

    [ 78.178860] jffs2: error: (1904) jffs2_do_read_inode_internal: CRC failed for read_inode of inode 24 at physical location 0x1fc00c
    [ 78.178914] Unable to handle kernel paging request at virtual address 6b6b6b6b6b6b6b7b
    [ 78.185871] pgd = ffffffc03a567000
    [ 78.188794] [6b6b6b6b6b6b6b7b] *pgd=0000000000000000, *pud=0000000000000000
    [ 78.194968] Internal error: Oops: 96000004 [#1] PREEMPT SMP
    ...
    [ 78.513147] PC is at rb_first_postorder+0xc/0x28
    [ 78.516503] LR is at jffs2_kill_fragtree+0x28/0x90 [jffs2]
    [ 78.520672] pc : [] lr : [] pstate: 60000105
    [ 78.526757] sp : ffffff800cea38f0
    [ 78.528753] x29: ffffff800cea38f0 x28: ffffffc01f3f8e80
    [ 78.532754] x27: 0000000000000000 x26: ffffff800cea3c70
    [ 78.536756] x25: 00000000dc67c8ae x24: ffffffc033d6945d
    [ 78.540759] x23: ffffffc036811740 x22: ffffff800891a5b8
    [ 78.544760] x21: 0000000000000000 x20: 0000000000000000
    [ 78.548762] x19: ffffffc037d48910 x18: ffffff800891a588
    [ 78.552764] x17: 0000000000000800 x16: 0000000000000c00
    [ 78.556766] x15: 0000000000000010 x14: 6f2065646f6e695f
    [ 78.560767] x13: 6461657220726f66 x12: 2064656c69616620
    [ 78.564769] x11: 435243203a6c616e x10: 7265746e695f6564
    [ 78.568771] x9 : 6f6e695f64616572 x8 : ffffffc037974038
    [ 78.572774] x7 : bbbbbbbbbbbbbbbb x6 : 0000000000000008
    [ 78.576775] x5 : 002f91d85bd44a2f x4 : 0000000000000000
    [ 78.580777] x3 : 0000000000000000 x2 : 000000403755e000
    [ 78.584779] x1 : 6b6b6b6b6b6b6b6b x0 : 6b6b6b6b6b6b6b6b
    ...
    [ 79.038551] [] rb_first_postorder+0xc/0x28
    [ 79.042962] [] jffs2_do_clear_inode+0x88/0x100 [jffs2]
    [ 79.048395] [] jffs2_evict_inode+0x3c/0x48 [jffs2]
    [ 79.053443] [] evict+0xb0/0x168
    [ 79.056835] [] iput+0x1c0/0x200
    [ 79.060228] [] iget_failed+0x30/0x3c
    [ 79.064097] [] jffs2_iget+0x2d8/0x360 [jffs2]
    [ 79.068740] [] jffs2_lookup+0xe8/0x130 [jffs2]
    [ 79.073434] [] lookup_slow+0x118/0x190
    [ 79.077435] [] walk_component+0xfc/0x28c
    [ 79.081610] [] path_lookupat+0x84/0x108
    [ 79.085699] [] filename_lookup+0x88/0x100
    [ 79.089960] [] user_path_at_empty+0x58/0x6c
    [ 79.094396] [] vfs_statx+0xa4/0x114
    [ 79.098138] [] SyS_newfstatat+0x58/0x98
    [ 79.102227] [] __sys_trace_return+0x0/0x4
    [ 79.106489] Code: d65f03c0 f9400001 b40000e1 aa0103e0 (f9400821)

    The jffs2_do_clear_inode() call in jffs2_iget() is unnecessary since
    iget_failed() will eventually call jffs2_do_clear_inode() if needed, so
    just remove it.

    Fixes: 5451f79f5f81 ("iget: stop JFFS2 from using iget() and read_inode()")
    Reviewed-by: Richard Weinberger
    Signed-off-by: Jake Daryll Obina
    Signed-off-by: Al Viro
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Jake Daryll Obina
     

24 Apr, 2018

1 commit


02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

15 Sep, 2017

1 commit

  • Pull mount flag updates from Al Viro:
    "Another chunk of fmount preparations from dhowells; only trivial
    conflicts for that part. It separates MS_... bits (very grotty
    mount(2) ABI) from the struct super_block ->s_flags (kernel-internal,
    only a small subset of MS_... stuff).

    This does *not* convert the filesystems to new constants; only the
    infrastructure is done here. The next step in that series is where the
    conflicts would be; that's the conversion of filesystems. It's purely
    mechanical and it's better done after the merge, so if you could run
    something like

    list=$(for i in MS_RDONLY MS_NOSUID MS_NODEV MS_NOEXEC MS_SYNCHRONOUS MS_MANDLOCK MS_DIRSYNC MS_NOATIME MS_NODIRATIME MS_SILENT MS_POSIXACL MS_KERNMOUNT MS_I_VERSION MS_LAZYTIME; do git grep -l $i fs drivers/staging/lustre drivers/mtd ipc mm include/linux; done|sort|uniq|grep -v '^fs/namespace.c$')

    sed -i -e 's/\/SB_RDONLY/g' \
    -e 's/\/SB_NOSUID/g' \
    -e 's/\/SB_NODEV/g' \
    -e 's/\/SB_NOEXEC/g' \
    -e 's/\/SB_SYNCHRONOUS/g' \
    -e 's/\/SB_MANDLOCK/g' \
    -e 's/\/SB_DIRSYNC/g' \
    -e 's/\/SB_NOATIME/g' \
    -e 's/\/SB_NODIRATIME/g' \
    -e 's/\/SB_SILENT/g' \
    -e 's/\/SB_POSIXACL/g' \
    -e 's/\/SB_KERNMOUNT/g' \
    -e 's/\/SB_I_VERSION/g' \
    -e 's/\/SB_LAZYTIME/g' \
    $list

    and commit it with something along the lines of 'convert filesystems
    away from use of MS_... constants' as commit message, it would save a
    quite a bit of headache next cycle"

    * 'work.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    VFS: Differentiate mount flags (MS_*) from internal superblock flags
    VFS: Convert sb->s_flags & MS_RDONLY to sb_rdonly(sb)
    vfs: Add sb_rdonly(sb) to query the MS_RDONLY flag on s_flags

    Linus Torvalds
     

10 Sep, 2017

1 commit

  • Pull MTD updates from Boris Brezillon:
    "General updates:
    - Constify pci_device_id in various drivers
    - Constify device_type
    - Remove pad control code from the Gemini driver
    - Use %pOF to print OF node full_name
    - Various fixes in the physmap_of driver
    - Remove unused vars in mtdswap
    - Check devm_kzalloc() return value in the spear_smi driver
    - Check clk_prepare_enable() return code in the st_spi_fsm driver
    - Create per MTD device debugfs enties

    NAND updates, from Boris Brezillon:
    - Fix memory leaks in the core
    - Remove unused NAND locking support
    - Rename nand.h into rawnand.h (preparing support for spi NANDs)
    - Use NAND_MAX_ID_LEN where appropriate
    - Fix support for 20nm Hynix chips
    - Fix support for Samsung and Hynix SLC NANDs
    - Various cleanup, improvements and fixes in the qcom driver
    - Fixes for bugs detected by various static code analysis tools
    - Fix mxc ooblayout definition
    - Add a new part_parsers to tmio and sharpsl platform data in order
    to define a custom list of partition parsers
    - Request the reset line in exclusive mode in the sunxi driver
    - Fix a build error in the orion-nand driver when compiled for ARMv4
    - Allow 64-bit mvebu platforms to select the PXA3XX driver

    SPI NOR updates, from Cyrille Pitchen and Marek Vasut:
    - add support to the JEDEC JESD216B specification (SFDP tables).
    - add support to the Intel Denverton SPI flash controller.
    - fix error recovery for Spansion/Cypress SPI NOR memories.
    - fix 4-byte address management for the Aspeed SPI controller.
    - add support to some Microchip SST26 memory parts
    - remove unneeded pinctrl header Write a message for tag:"

    * tag 'for-linus-20170904' of git://git.infradead.org/linux-mtd: (74 commits)
    mtd: nand: complain loudly when chip->bits_per_cell is not correctly initialized
    mtd: nand: make Samsung SLC NAND usable again
    mtd: nand: tmio: Register partitions using the parsers
    mfd: tmio: Add partition parsers platform data
    mtd: nand: sharpsl: Register partitions using the parsers
    mtd: nand: sharpsl: Add partition parsers platform data
    mtd: nand: qcom: Support for IPQ8074 QPIC NAND controller
    mtd: nand: qcom: support for IPQ4019 QPIC NAND controller
    dt-bindings: qcom_nandc: IPQ8074 QPIC NAND documentation
    dt-bindings: qcom_nandc: IPQ4019 QPIC NAND documentation
    dt-bindings: qcom_nandc: fix the ipq806x device tree example
    mtd: nand: qcom: support for different DEV_CMD register offsets
    mtd: nand: qcom: QPIC data descriptors handling
    mtd: nand: qcom: enable BAM or ADM mode
    mtd: nand: qcom: erased codeword detection configuration
    mtd: nand: qcom: support for read location registers
    mtd: nand: qcom: support for passing flags in DMA helper functions
    mtd: nand: qcom: add BAM DMA descriptor handling
    mtd: nand: qcom: allocate BAM transaction
    mtd: nand: qcom: DMA mapping support for register read buffer
    ...

    Linus Torvalds
     

13 Aug, 2017

1 commit

  • We are planning to share more code between different NAND based
    devices (SPI NAND, OneNAND and raw NANDs), but before doing that
    we need to move the existing include/linux/mtd/nand.h file into
    include/linux/mtd/rawnand.h so we can later create a nand.h header
    containing all common structure and function prototypes.

    Signed-off-by: Boris Brezillon
    Signed-off-by: Peter Pan
    Acked-by: Vladimir Zapolskiy
    Acked-by: Alexander Sverdlin
    Acked-by: Wenyou Yang
    Acked-by: Krzysztof Kozlowski
    Acked-by: Han Xu
    Acked-by: H Hartley Sweeten
    Acked-by: Shawn Guo
    Acked-by: Gregory CLEMENT
    Acked-by: Neil Armstrong
    Acked-by: Masahiro Yamada
    Acked-By: Harvey Hunt
    Acked-by: Tony Lindgren
    Acked-by: Krzysztof Halasa

    Boris Brezillon
     

01 Aug, 2017

1 commit

  • This patch converts most of the in-kernel filesystems that do writeback
    out of the pagecache to report errors using the errseq_t-based
    infrastructure that was recently added. This allows them to report
    errors once for each open file description.

    Most filesystems have a fairly straightforward fsync operation. They
    call filemap_write_and_wait_range to write back all of the data and
    wait on it, and then (sometimes) sync out the metadata.

    For those filesystems this is a straightforward conversion from calling
    filemap_write_and_wait_range in their fsync operation to calling
    file_write_and_wait_range.

    Acked-by: Jan Kara
    Acked-by: Dave Kleikamp
    Signed-off-by: Jeff Layton

    Jeff Layton
     

17 Jul, 2017

1 commit

  • Firstly by applying the following with coccinelle's spatch:

    @@ expression SB; @@
    -SB->s_flags & MS_RDONLY
    +sb_rdonly(SB)

    to effect the conversion to sb_rdonly(sb), then by applying:

    @@ expression A, SB; @@
    (
    -(!sb_rdonly(SB)) && A
    +!sb_rdonly(SB) && A
    |
    -A != (sb_rdonly(SB))
    +A != sb_rdonly(SB)
    |
    -A == (sb_rdonly(SB))
    +A == sb_rdonly(SB)
    |
    -!(sb_rdonly(SB))
    +!sb_rdonly(SB)
    |
    -A && (sb_rdonly(SB))
    +A && sb_rdonly(SB)
    |
    -A || (sb_rdonly(SB))
    +A || sb_rdonly(SB)
    |
    -(sb_rdonly(SB)) != A
    +sb_rdonly(SB) != A
    |
    -(sb_rdonly(SB)) == A
    +sb_rdonly(SB) == A
    |
    -(sb_rdonly(SB)) && A
    +sb_rdonly(SB) && A
    |
    -(sb_rdonly(SB)) || A
    +sb_rdonly(SB) || A
    )

    @@ expression A, B, SB; @@
    (
    -(sb_rdonly(SB)) ? 1 : 0
    +sb_rdonly(SB)
    |
    -(sb_rdonly(SB)) ? A : B
    +sb_rdonly(SB) ? A : B
    )

    to remove left over excess bracketage and finally by applying:

    @@ expression A, SB; @@
    (
    -(A & MS_RDONLY) != sb_rdonly(SB)
    +(bool)(A & MS_RDONLY) != sb_rdonly(SB)
    |
    -(A & MS_RDONLY) == sb_rdonly(SB)
    +(bool)(A & MS_RDONLY) == sb_rdonly(SB)
    )

    to make comparisons against the result of sb_rdonly() (which is a bool)
    work correctly.

    Signed-off-by: David Howells

    David Howells
     

20 Apr, 2017

1 commit


02 Mar, 2017

3 commits


09 Dec, 2016

1 commit


11 Oct, 2016

3 commits

  • Pull more vfs updates from Al Viro:
    ">rename2() work from Miklos + current_time() from Deepa"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    fs: Replace current_fs_time() with current_time()
    fs: Replace CURRENT_TIME_SEC with current_time() for inode timestamps
    fs: Replace CURRENT_TIME with current_time() for inode timestamps
    fs: proc: Delete inode time initializations in proc_alloc_inode()
    vfs: Add current_time() api
    vfs: add note about i_op->rename changes to porting
    fs: rename "rename2" i_op to "rename"
    vfs: remove unused i_op->rename
    fs: make remaining filesystems use .rename2
    libfs: support RENAME_NOREPLACE in simple_rename()
    fs: support RENAME_NOREPLACE for local filesystems
    ncpfs: fix unused variable warning

    Linus Torvalds
     
  • Al Viro
     
  • Pull vfs xattr updates from Al Viro:
    "xattr stuff from Andreas

    This completes the switch to xattr_handler ->get()/->set() from
    ->getxattr/->setxattr/->removexattr"

    * 'work.xattr' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    vfs: Remove {get,set,remove}xattr inode operations
    xattr: Stop calling {get,set,remove}xattr inode operations
    vfs: Check for the IOP_XATTR flag in listxattr
    xattr: Add __vfs_{get,set,remove}xattr helpers
    libfs: Use IOP_XATTR flag for empty directory handling
    vfs: Use IOP_XATTR flag for bad-inode handling
    vfs: Add IOP_XATTR inode operations flag
    vfs: Move xattr_resolve_name to the front of fs/xattr.c
    ecryptfs: Switch to generic xattr handlers
    sockfs: Get rid of getxattr iop
    sockfs: getxattr: Fail with -EOPNOTSUPP for invalid attribute names
    kernfs: Switch to generic xattr handlers
    hfs: Switch to generic xattr handlers
    jffs2: Remove jffs2_{get,set,remove}xattr macros
    xattr: Remove unnecessary NULL attribute name check

    Linus Torvalds
     

08 Oct, 2016

1 commit


07 Oct, 2016

1 commit

  • When CONFIG_JFFS2_FS_XATTR is off, jffs2_xattr_handlers is defined as
    NULL. With sb->s_xattr == NULL, the generic_{get,set,remove}xattr
    functions produce the same result as setting the {get,set,remove}xattr
    inode operations to NULL, so there is no need for these macros.

    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Al Viro

    Andreas Gruenbacher
     

28 Sep, 2016

1 commit

  • CURRENT_TIME_SEC is not y2038 safe. current_time() will
    be transitioned to use 64 bit time along with vfs in a
    separate patch.
    There is no plan to transistion CURRENT_TIME_SEC to use
    y2038 safe time interfaces.

    current_time() will also be extended to use superblock
    range checking parameters when range checking is introduced.

    This works because alloc_super() fills in the the s_time_gran
    in super block to NSEC_PER_SEC.

    Signed-off-by: Deepa Dinamani
    Acked-by: Jan Kara
    Signed-off-by: Al Viro

    Deepa Dinamani
     

27 Sep, 2016

2 commits

  • Generated patch:

    sed -i "s/\.rename2\t/\.rename\t\t/" `git grep -wl rename2`
    sed -i "s/\brename2\b/rename/g" `git grep -wl rename2`

    Signed-off-by: Miklos Szeredi

    Miklos Szeredi
     
  • This is trivial to do:

    - add flags argument to foo_rename()
    - check if flags doesn't have any other than RENAME_NOREPLACE
    - assign foo_rename() to .rename2 instead of .rename

    Filesystems converted:

    affs, bfs, exofs, ext2, hfs, hfsplus, jffs2, jfs, logfs, minix, msdos,
    nilfs2, omfs, reiserfs, sysvfs, ubifs, udf, ufs, vfat.

    Signed-off-by: Miklos Szeredi
    Acked-by: Boaz Harrosh
    Acked-by: Richard Weinberger
    Acked-by: Bob Copeland
    Acked-by: Jan Kara
    Cc: Theodore Ts'o
    Cc: Jaegeuk Kim
    Cc: OGAWA Hirofumi
    Cc: Mikulas Patocka
    Cc: David Woodhouse
    Cc: Dave Kleikamp
    Cc: Ryusuke Konishi
    Cc: Christoph Hellwig

    Miklos Szeredi
     

22 Sep, 2016

2 commits

  • inode_change_ok() will be resposible for clearing capabilities and IMA
    extended attributes and as such will need dentry. Give it as an argument
    to inode_change_ok() instead of an inode. Also rename inode_change_ok()
    to setattr_prepare() to better relect that it does also some
    modifications in addition to checks.

    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jan Kara

    Jan Kara
     
  • When file permissions are modified via chmod(2) and the user is not in
    the owning group or capable of CAP_FSETID, the setgid bit is cleared in
    inode_change_ok(). Setting a POSIX ACL via setxattr(2) sets the file
    permissions as well as the new ACL, but doesn't clear the setgid bit in
    a similar way; this allows to bypass the check in chmod(2). Fix that.

    References: CVE-2016-7097
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Jeff Layton
    Signed-off-by: Jan Kara
    Signed-off-by: Andreas Gruenbacher

    Jan Kara
     

11 Jun, 2016

1 commit

  • We always mixed in the parent pointer into the dentry name hash, but we
    did it late at lookup time. It turns out that we can simplify that
    lookup-time action by salting the hash with the parent pointer early
    instead of late.

    A few other users of our string hashes also wanted to mix in their own
    pointers into the hash, and those are updated to use the same mechanism.

    Hash users that don't have any particular initial salt can just use the
    NULL pointer as a no-salt.

    Cc: Vegard Nossum
    Cc: George Spelvin
    Cc: Al Viro
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

28 May, 2016

1 commit


09 May, 2016

1 commit


03 May, 2016

1 commit


11 Apr, 2016

2 commits


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
     

31 Mar, 2016

1 commit

  • When get_acl() is called for an inode whose ACL is not cached yet, the
    get_acl inode operation is called to fetch the ACL from the filesystem.
    The inode operation is responsible for updating the cached acl with
    set_cached_acl(). This is done without locking at the VFS level, so
    another task can call set_cached_acl() or forget_cached_acl() before the
    get_acl inode operation gets to calling set_cached_acl(), and then
    get_acl's call to set_cached_acl() results in caching an outdate ACL.

    Prevent this from happening by setting the cached ACL pointer to a
    task-specific sentinel value before calling the get_acl inode operation.
    Move the responsibility for updating the cached ACL from the get_acl
    inode operations to get_acl(). There, only set the cached ACL if the
    sentinel value hasn't changed.

    The sentinel values are chosen to have odd values. Likewise, the value
    of ACL_NOT_CACHED is odd. In contrast, ACL object pointers always have
    an even value (ACLs are aligned in memory). This allows to distinguish
    uncached ACLs values from ACL objects.

    In addition, switch from guarding inode->i_acl and inode->i_default_acl
    upates by the inode->i_lock spinlock to using xchg() and cmpxchg().

    Filesystems that do not want ACLs returned from their get_acl inode
    operations to be cached must call forget_cached_acl() to prevent the VFS
    from doing so.

    (Patch written by Al Viro and Andreas Gruenbacher.)

    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Al Viro

    Andreas Gruenbacher
     

25 Mar, 2016

1 commit

  • Pull MTD updates from Brian Norris:
    "NAND:
    - Add sunxi_nand randomizer support
    - begin refactoring NAND ecclayout structs
    - fix pxa3xx_nand dmaengine usage
    - brcmnand: fix support for v7.1 controller
    - add Qualcomm NAND controller driver

    SPI NOR:
    - add new ls1021a, ls2080a support to Freescale QuadSPI
    - add new flash ID entries
    - support bottom-block protection for Winbond flash
    - support Status Register Write Protect
    - remove broken QPI support for Micron SPI flash

    JFFS2:
    - improve post-mount CRC scan efficiency

    General:
    - refactor bcm63xxpart parser, to later extend for NAND
    - add writebuf size parameter to mtdram

    Other minor code quality improvements"

    * tag 'for-linus-20160324' of git://git.infradead.org/linux-mtd: (72 commits)
    mtd: nand: remove kerneldoc for removed function parameter
    mtd: nand: Qualcomm NAND controller driver
    dt/bindings: qcom_nandc: Add DT bindings
    mtd: nand: don't select chip in nand_chip's block_bad op
    mtd: spi-nor: support lock/unlock for a few Winbond chips
    mtd: spi-nor: add TB (Top/Bottom) protect support
    mtd: spi-nor: add SPI_NOR_HAS_LOCK flag
    mtd: spi-nor: use BIT() for flash_info flags
    mtd: spi-nor: disallow further writes to SR if WP# is low
    mtd: spi-nor: make lock/unlock bounds checks more obvious and robust
    mtd: spi-nor: silently drop lock/unlock for already locked/unlocked region
    mtd: spi-nor: wait for SR_WIP to clear on initial unlock
    mtd: nand: simplify nand_bch_init() usage
    mtd: mtdswap: remove useless if (!mtd->ecclayout) test
    mtd: create an mtd_oobavail() helper and make use of it
    mtd: kill the ecclayout->oobavail field
    mtd: nand: check status before reporting timeout
    mtd: bcm63xxpart: give width specifier an 'int', not 'size_t'
    mtd: mtdram: Add parameter for setting writebuf size
    mtd: nand: pxa3xx_nand: kill unused field 'drcmr_cmd'
    ...

    Linus Torvalds
     

12 Mar, 2016

1 commit


08 Mar, 2016

2 commits


01 Mar, 2016

1 commit

  • We need to finish doing the CRC checks before we can allow writes to
    happen, and we currently process the inodes in order. This means a call
    to jffs2_get_ino_cache() for each possible inode# up to c->highest_ino.

    There may be a lot of lookups which fail, if the inode# space is used
    sparsely. And the inode# space is *often* used sparsely, if a file
    system contains a lot of stuff that was put there in the original
    image, followed by lots of creation and deletion of new files.

    Instead of processing them numerically with a lookup each time, just
    walk the hash buckets instead.

    [fix locking typo reported by Dan Carpenter]
    Signed-off-by: David Woodhouse

    David Woodhouse
     

25 Feb, 2016

1 commit

  • When a directory is deleted, we don't take too much care about killing off
    all the dirents that belong to it — on the basis that on remount, the scan
    will conclude that the directory is dead anyway.

    This doesn't work though, when the deleted directory contained a child
    directory which was moved *out*. In the early stages of the fs build
    we can then end up with an apparent hard link, with the child directory
    appearing both in its true location, and as a child of the original
    directory which are this stage of the mount process we don't *yet* know
    is defunct.

    To resolve this, take out the early special-casing of the "directories
    shall not have hard links" rule in jffs2_build_inode_pass1(), and let the
    normal nlink processing happen for directories as well as other inodes.

    Then later in the build process we can set ic->pino_nlink to the parent
    inode#, as is required for directories during normal operaton, instead
    of the nlink. And complain only *then* about hard links which are still
    in evidence even after killing off all the unreachable paths.

    Reported-by: Liu Song
    Signed-off-by: David Woodhouse
    Cc: stable@vger.kernel.org

    David Woodhouse