1. 07 3月, 2021 1 次提交
    • J
      ext4: add reclaim checks to xattr code · 163f0ec1
      Jan Kara 提交于
      Syzbot is reporting that ext4 can enter fs reclaim from kvmalloc() while
      the transaction is started like:
      
        fs_reclaim_acquire+0x117/0x150 mm/page_alloc.c:4340
        might_alloc include/linux/sched/mm.h:193 [inline]
        slab_pre_alloc_hook mm/slab.h:493 [inline]
        slab_alloc_node mm/slub.c:2817 [inline]
        __kmalloc_node+0x5f/0x430 mm/slub.c:4015
        kmalloc_node include/linux/slab.h:575 [inline]
        kvmalloc_node+0x61/0xf0 mm/util.c:587
        kvmalloc include/linux/mm.h:781 [inline]
        ext4_xattr_inode_cache_find fs/ext4/xattr.c:1465 [inline]
        ext4_xattr_inode_lookup_create fs/ext4/xattr.c:1508 [inline]
        ext4_xattr_set_entry+0x1ce6/0x3780 fs/ext4/xattr.c:1649
        ext4_xattr_ibody_set+0x78/0x2b0 fs/ext4/xattr.c:2224
        ext4_xattr_set_handle+0x8f4/0x13e0 fs/ext4/xattr.c:2380
        ext4_xattr_set+0x13a/0x340 fs/ext4/xattr.c:2493
      
      This should be impossible since transaction start sets PF_MEMALLOC_NOFS.
      Add some assertions to the code to catch if something isn't working as
      expected early.
      
      Link: https://lore.kernel.org/linux-ext4/000000000000563a0205bafb7970@google.com/Signed-off-by: NJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20210222171626.21884-1-jack@suse.czSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
      163f0ec1
  2. 23 12月, 2020 2 次提交
  3. 10 12月, 2020 1 次提交
  4. 22 10月, 2020 1 次提交
    • H
      ext4: main fast-commit commit path · aa75f4d3
      Harshad Shirwadkar 提交于
      This patch adds main fast commit commit path handlers. The overall
      patch can be divided into two inter-related parts:
      
      (A) Metadata updates tracking
      
          This part consists of helper functions to track changes that need
          to be committed during a commit operation. These updates are
          maintained by Ext4 in different in-memory queues. Following are
          the APIs and their short description that are implemented in this
          patch:
      
          - ext4_fc_track_link/unlink/creat() - Track unlink. link and creat
            operations
          - ext4_fc_track_range() - Track changed logical block offsets
            inodes
          - ext4_fc_track_inode() - Track inodes
          - ext4_fc_mark_ineligible() - Mark file system fast commit
            ineligible()
          - ext4_fc_start_update() / ext4_fc_stop_update() /
            ext4_fc_start_ineligible() / ext4_fc_stop_ineligible() These
            functions are useful for co-ordinating inode updates with
            commits.
      
      (B) Main commit Path
      
          This part consists of functions to convert updates tracked in
          in-memory data structures into on-disk commits. Function
          ext4_fc_commit() is the main entry point to commit path.
      Reported-by: Nkernel test robot <lkp@intel.com>
      Signed-off-by: NHarshad Shirwadkar <harshadshirwadkar@gmail.com>
      Link: https://lore.kernel.org/r/20201015203802.3597742-6-harshadshirwadkar@gmail.comSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
      aa75f4d3
  5. 06 8月, 2020 1 次提交
  6. 13 6月, 2020 1 次提交
  7. 04 6月, 2020 2 次提交
  8. 02 4月, 2020 1 次提交
  9. 18 1月, 2020 1 次提交
  10. 27 12月, 2019 1 次提交
  11. 06 11月, 2019 3 次提交
  12. 10 4月, 2019 1 次提交
  13. 22 2月, 2019 1 次提交
  14. 20 12月, 2018 2 次提交
    • T
      ext4: avoid declaring fs inconsistent due to invalid file handles · 8a363970
      Theodore Ts'o 提交于
      If we receive a file handle, either from NFS or open_by_handle_at(2),
      and it points at an inode which has not been initialized, and the file
      system has metadata checksums enabled, we shouldn't try to get the
      inode, discover the checksum is invalid, and then declare the file
      system as being inconsistent.
      
      This can be reproduced by creating a test file system via "mke2fs -t
      ext4 -O metadata_csum /tmp/foo.img 8M", mounting it, cd'ing into that
      directory, and then running the following program.
      
      #define _GNU_SOURCE
      #include <fcntl.h>
      
      struct handle {
      	struct file_handle fh;
      	unsigned char fid[MAX_HANDLE_SZ];
      };
      
      int main(int argc, char **argv)
      {
      	struct handle h = {{8, 1 }, { 12, }};
      
      	open_by_handle_at(AT_FDCWD, &h.fh, O_RDONLY);
      	return 0;
      }
      
      Google-Bug-Id: 120690101
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      8a363970
    • T
      ext4: include terminating u32 in size of xattr entries when expanding inodes · a805622a
      Theodore Ts'o 提交于
      In ext4_expand_extra_isize_ea(), we calculate the total size of the
      xattr header, plus the xattr entries so we know how much of the
      beginning part of the xattrs to move when expanding the inode extra
      size.  We need to include the terminating u32 at the end of the xattr
      entries, or else if there is uninitialized, non-zero bytes after the
      xattr entries and before the xattr values, the list of xattr entries
      won't be properly terminated.
      Reported-by: NSteve Graham <stgraham2000@gmail.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      a805622a
  15. 26 11月, 2018 1 次提交
    • T
      ext4: add ext4_sb_bread() to disambiguate ENOMEM cases · fb265c9c
      Theodore Ts'o 提交于
      Today, when sb_bread() returns NULL, this can either be because of an
      I/O error or because the system failed to allocate the buffer.  Since
      it's an old interface, changing would require changing many call
      sites.
      
      So instead we create our own ext4_sb_bread(), which also allows us to
      set the REQ_META flag.
      
      Also fixed a problem in the xattr code where a NULL return in a
      function could also mean that the xattr was not found, which could
      lead to the wrong error getting returned to userspace.
      
      Fixes: ac27a0ec ("ext4: initial copy of files from ext3")
      Cc: stable@kernel.org # 2.6.19
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      fb265c9c
  16. 10 11月, 2018 1 次提交
    • V
      ext4: missing !bh check in ext4_xattr_inode_write() · eb6984fa
      Vasily Averin 提交于
      According to Ted Ts'o ext4_getblk() called in ext4_xattr_inode_write()
      should not return bh = NULL
      
      The only time that bh could be NULL, then, would be in the case of
      something really going wrong; a programming error elsewhere (perhaps a
      wild pointer dereference) or I/O error causing on-disk file system
      corruption (although that would be highly unlikely given that we had
      *just* allocated the blocks and so the metadata blocks in question
      probably would still be in the cache).
      
      Fixes: e50e5129 ("ext4: xattr-in-inode support")
      Signed-off-by: NVasily Averin <vvs@virtuozzo.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org # 4.13
      eb6984fa
  17. 08 11月, 2018 4 次提交
  18. 07 11月, 2018 1 次提交
  19. 02 8月, 2018 1 次提交
  20. 17 6月, 2018 2 次提交
  21. 13 6月, 2018 2 次提交
  22. 23 5月, 2018 1 次提交
    • T
      ext4: correctly handle a zero-length xattr with a non-zero e_value_offs · 8a2b307c
      Theodore Ts'o 提交于
      Ext4 will always create ext4 extended attributes which do not have a
      value (where e_value_size is zero) with e_value_offs set to zero.  In
      most places e_value_offs will not be used in a substantive way if
      e_value_size is zero.
      
      There was one exception to this, which is in ext4_xattr_set_entry(),
      where if there is a maliciously crafted file system where there is an
      extended attribute with e_value_offs is non-zero and e_value_size is
      0, the attempt to remove this xattr will result in a negative value
      getting passed to memmove, leading to the following sadness:
      
      [   41.225365] EXT4-fs (loop0): mounted filesystem with ordered data mode. Opts: (null)
      [   44.538641] BUG: unable to handle kernel paging request at ffff9ec9a3000000
      [   44.538733] IP: __memmove+0x81/0x1a0
      [   44.538755] PGD 1249bd067 P4D 1249bd067 PUD 1249c1067 PMD 80000001230000e1
      [   44.538793] Oops: 0003 [#1] SMP PTI
      [   44.539074] CPU: 0 PID: 1470 Comm: poc Not tainted 4.16.0-rc1+ #1
          ...
      [   44.539475] Call Trace:
      [   44.539832]  ext4_xattr_set_entry+0x9e7/0xf80
          ...
      [   44.539972]  ext4_xattr_block_set+0x212/0xea0
          ...
      [   44.540041]  ext4_xattr_set_handle+0x514/0x610
      [   44.540065]  ext4_xattr_set+0x7f/0x120
      [   44.540090]  __vfs_removexattr+0x4d/0x60
      [   44.540112]  vfs_removexattr+0x75/0xe0
      [   44.540132]  removexattr+0x4d/0x80
          ...
      [   44.540279]  path_removexattr+0x91/0xb0
      [   44.540300]  SyS_removexattr+0xf/0x20
      [   44.540322]  do_syscall_64+0x71/0x120
      [   44.540344]  entry_SYSCALL_64_after_hwframe+0x21/0x86
      
      https://bugzilla.kernel.org/show_bug.cgi?id=199347
      
      This addresses CVE-2018-10840.
      Reported-by: N"Xu, Wen" <wen.xu@gatech.edu>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Reviewed-by: NAndreas Dilger <adilger@dilger.ca>
      Cc: stable@kernel.org
      Fixes: dec214d0 ("ext4: xattr inode deduplication")
      8a2b307c
  23. 31 3月, 2018 3 次提交
  24. 30 3月, 2018 1 次提交
  25. 29 1月, 2018 1 次提交
  26. 02 11月, 2017 1 次提交
    • G
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman 提交于
      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 <5
         lines).
      
      All documentation files were explicitly excluded.
      
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
      
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
      
         For non */uapi/* files that summary was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0                                              11139
      
         and resulted in the first patch in this series.
      
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0 WITH Linux-syscall-note                        930
      
         and resulted in the second patch in this series.
      
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|------
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
      
         and that resulted in the third patch in this series.
      
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
      
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
      
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
      
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
      
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      Reviewed-by: NKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: NPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
  27. 25 8月, 2017 1 次提交
    • T
      ext4: backward compatibility support for Lustre ea_inode implementation · a6d05676
      Tahsin Erdogan 提交于
      Original Lustre ea_inode feature did not have ref counts on xattr inodes
      because there was always one parent that referenced it. New
      implementation expects ref count to be initialized which is not true for
      Lustre case. Handle this by detecting Lustre created xattr inode and set
      its ref count to 1.
      
      The quota handling of xattr inodes have also changed with deduplication
      support. New implementation manually manages quotas to support sharing
      across multiple users. A consequence is that, a referencing inode
      incorporates the blocks of xattr inode into its own i_block field.
      
      We need to know how a xattr inode was created so that we can reverse the
      block charges during reference removal. This is handled by introducing a
      EXT4_STATE_LUSTRE_EA_INODE flag. The flag is set on a xattr inode if
      inode appears to have been created by Lustre. During xattr inode reference
      removal, the manual quota uncharge is skipped if the flag is set.
      Signed-off-by: NTahsin Erdogan <tahsin@google.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      a6d05676
  28. 14 8月, 2017 1 次提交