1. 21 11月, 2019 19 次提交
    • K
      fuse: use READ_ONCE on congestion_threshold and max_background · d7b412e1
      Kirill Tkhai 提交于
      [ Upstream commit 2a23f2b8adbe4bd584f936f7ac17a99750eed9d7 ]
      
      Since they are of unsigned int type, it's allowed to read them
      unlocked during reporting to userspace. Let's underline this fact
      with READ_ONCE() macroses.
      Signed-off-by: NKirill Tkhai <ktkhai@virtuozzo.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      d7b412e1
    • C
      f2fs: mark inode dirty explicitly in recover_inode() · 36ffc9a7
      Chao Yu 提交于
      [ Upstream commit 4a1728cad6340bfbe17bd17fd158b2165cd99508 ]
      
      Mark inode dirty explicitly in the end of recover_inode() to make sure
      that all recoverable fields can be persisted later.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      36ffc9a7
    • C
      f2fs: fix to recover inode's project id during POR · a4bd303d
      Chao Yu 提交于
      [ Upstream commit f4474aa6e5e901ee4af21f39f1b9115aaaaec503 ]
      
      Testcase to reproduce this bug:
      1. mkfs.f2fs -O extra_attr -O project_quota /dev/sdd
      2. mount -t f2fs /dev/sdd /mnt/f2fs
      3. touch /mnt/f2fs/file
      4. sync
      5. chattr -p 1 /mnt/f2fs/file
      6. xfs_io -f /mnt/f2fs/file -c "fsync"
      7. godown /mnt/f2fs
      8. umount /mnt/f2fs
      9. mount -t f2fs /dev/sdd /mnt/f2fs
      10. lsattr -p /mnt/f2fs/file
      
          0 -----------------N- /mnt/f2fs/file
      
      But actually, we expect the correct result is:
      
          1 -----------------N- /mnt/f2fs/file
      
      The reason is we didn't recover inode.i_projid field during mount,
      fix it.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      a4bd303d
    • J
      f2fs: update i_size after DIO completion · 7bae8b6b
      Jaegeuk Kim 提交于
      [ Upstream commit 0a4daae5ffea39f5015334e4d18a6a80b447cae4 ]
      
      This is related to
      ee70daab ("xfs: update i_size after unwritten conversion in dio completion")
      
      If we update i_size during dio_write, dio_read can read out stale data, which
      breaks xfstests/465.
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      7bae8b6b
    • C
      f2fs: fix remount problem of option io_bits · 6fce50c1
      Chengguang Xu 提交于
      [ Upstream commit c6b1867b1da3b1203b4c49988afeebdcbdf65499 ]
      
      Currently we show mount option "io_bits=%u" as "io_size=%uKB",
      it will cause option parsing problem(unrecognized mount option)
      in remount.
      Signed-off-by: NChengguang Xu <cgxu519@gmx.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      6fce50c1
    • C
      f2fs: fix to recover inode's uid/gid during POR · dfc81686
      Chao Yu 提交于
      [ Upstream commit dc4cd1257c86451cec3e8e352cc376348e4f4af4 ]
      
      Step to reproduce this bug:
      1. logon as root
      2. mount -t f2fs /dev/sdd /mnt;
      3. touch /mnt/file;
      4. chown system /mnt/file; chgrp system /mnt/file;
      5. xfs_io -f /mnt/file -c "fsync";
      6. godown /mnt;
      7. umount /mnt;
      8. mount -t f2fs /dev/sdd /mnt;
      
      After step 8) we will expect file's uid/gid are all system, but during
      recovery, these two fields were not been recovered, fix it.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      dfc81686
    • J
      f2fs: avoid infinite loop in f2fs_alloc_nid · c783946e
      Jaegeuk Kim 提交于
      [ Upstream commit f84262b0862d43b71b3e80a036cdd9d82e620367 ]
      
      If we have an error in f2fs_build_free_nids, we're able to fall into a loop
      to find free nids.
      Suggested-by: NChao Yu <chao@kernel.org>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      c783946e
    • B
      kernfs: Fix range checks in kernfs_get_target_path · ada2a0f1
      Bernd Edlinger 提交于
      [ Upstream commit a75e78f21f9ad4b810868c89dbbabcc3931591ca ]
      
      The terminating NUL byte is only there because the buffer is
      allocated with kzalloc(PAGE_SIZE, GFP_KERNEL), but since the
      range-check is off-by-one, and PAGE_SIZE==PATH_MAX, the
      returned string may not be zero-terminated if it is exactly
      PATH_MAX characters long.  Furthermore also the initial loop
      may theoretically exceed PATH_MAX and cause a fault.
      Signed-off-by: NBernd Edlinger <bernd.edlinger@hotmail.de>
      Acked-by: NTejun Heo <tj@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      ada2a0f1
    • A
      media: dvb: fix compat ioctl translation · 914282c6
      Arnd Bergmann 提交于
      [ Upstream commit 1ccbeeb888ac33627d91f1ccf0b84ef3bcadef24 ]
      
      The VIDEO_GET_EVENT and VIDEO_STILLPICTURE was added back in 2005 but
      it never worked because the command number is wrong.
      
      Using the right command number means we have a better chance of them
      actually doing the right thing, though clearly nobody has ever tried
      it successfully.
      
      I noticed these while auditing the remaining users of compat_time_t
      for y2038 bugs. This one is fine in that regard, it just never did
      anything.
      
      Fixes: 6e87abd0 ("[DVB]: Add compat ioctl handling.")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      914282c6
    • W
      f2fs: fix setattr project check upon fssetxattr ioctl · a1f14df3
      Wang Shilong 提交于
      [ Upstream commit c8e927579e00a182eda07e4c45df9c8c699c8ded ]
      
      Currently, project quota could be changed by fssetxattr
      ioctl, and existed permission check inode_owner_or_capable()
      is obviously not enough, just think that common users could
      change project id of file, that could make users to
      break project quota easily.
      
      This patch try to follow same regular of xfs project
      quota:
      
      "Project Quota ID state is only allowed to change from
      within the init namespace. Enforce that restriction only
      if we are trying to change the quota ID state.
      Everything else is allowed in user namespaces."
      
      Besides that, check and set project id'state should
      be an atomic operation, protect whole operation with
      inode lock.
      Signed-off-by: NWang Shilong <wshilong@ddn.com>
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      a1f14df3
    • C
      f2fs: fix memory leak of percpu counter in fill_super() · 7b55102c
      Chao Yu 提交于
      [ Upstream commit 4a70e255449c9a13eed7a6eeecc85a1ea63cef76 ]
      
      In fill_super -> init_percpu_info, we should destroy percpu counter
      in error path, otherwise memory allcoated for percpu counter will
      leak.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      7b55102c
    • C
      f2fs: fix memory leak of write_io in fill_super() · 88303730
      Chao Yu 提交于
      [ Upstream commit 0b2103e886e6de9802e1170e57c573443286a483 ]
      
      It needs to release memory allocated for sbi->write_io in error path,
      otherwise, it will cause memory leak.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      88303730
    • J
      f2fs: submit bio after shutdown · eca5b74e
      Jaegeuk Kim 提交于
      [ Upstream commit 5ce805869cbed93267ed26552ff76e30f05c91f7 ]
      
      Sometimes, some merged IOs could get a chance to be submitted, resulting in
      system hang in shutdown test. This issues IOs all the time after shutdown.
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      eca5b74e
    • J
      udf: Fix crash during mount · 0204720d
      Jan Kara 提交于
      [ Upstream commit b085fbe2ef7fa7489903c45271ae7b7a52b0f9ab ]
      
      Fix a crash during an attempt to mount a filesystem that has both
      Unallocated Space Table and Unallocated Space Bitmap. Such filesystem
      actually violates the UDF standard so we just have to properly detect
      such situation and refuse to mount such filesystem read-write. When we
      are at it, verify also other constraints on the allocation information
      mandated by the standard.
      Reported-by: NAnatoly Trosinenko <anatoly.trosinenko@gmail.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      0204720d
    • J
      f2fs: avoid wrong decrypted data from disk · 23ad83c3
      Jaegeuk Kim 提交于
      [ Upstream commit 0ded69f632bb717be9aeea3ae74e29050fcb060c ]
      
      1. Create a file in an encrypted directory
      2. Do GC & drop caches
      3. Read stale data before its bio for metapage was not issued yet
      Reviewed-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      23ad83c3
    • B
      gfs2: Don't set GFS2_RDF_UPTODATE when the lvb is updated · 48b128cd
      Bob Peterson 提交于
      [ Upstream commit 4f36cb36c9d14340bb200d2ad9117b03ce992cfe ]
      
      The GFS2_RDF_UPTODATE flag in the rgrp is used to determine when
      a rgrp buffer is valid. It's cleared when the glock is invalidated,
      signifying that the buffer data is now invalid. But before this
      patch, function update_rgrp_lvb was setting the flag when it
      determined it had a valid lvb. But that's an invalid assumption:
      just because you have a valid lvb doesn't mean you have valid
      buffers. After all, another node may have made the lvb valid,
      and this node just fetched it from the glock via dlm.
      
      Consider this scenario:
      1. The file system is mounted with RGRPLVB option.
      2. In gfs2_inplace_reserve it locks the rgrp glock EX, but thanks
         to GL_SKIP, it skips the gfs2_rgrp_bh_get.
      3. Since loops == 0 and the allocation target (ap->target) is
         bigger than the largest known chunk of blocks in the rgrp
         (rs->rs_rbm.rgd->rd_extfail_pt) it skips that rgrp and bypasses
         the call to gfs2_rgrp_bh_get there as well.
      4. update_rgrp_lvb sees the lvb MAGIC number is valid, so bypasses
         gfs2_rgrp_bh_get, but it still sets sets GFS2_RDF_UPTODATE due
         to this invalid assumption.
      5. The next time update_rgrp_lvb is called, it sees the bit is set
         and just returns 0, assuming both the lvb and rgrp are both
         uptodate. But since this is a smaller allocation, or space has
         been freed by another node, thus adjusting the lvb values,
         it decides to use the rgrp for allocations, with invalid rd_free
         due to the fact it was never updated.
      
      This patch changes update_rgrp_lvb so it doesn't set the UPTODATE
      flag anymore. That way, it has no choice but to fetch the latest
      values.
      Signed-off-by: NBob Peterson <rpeterso@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      48b128cd
    • A
      ecryptfs_lookup_interpose(): lower_dentry->d_parent is not stable either · bdae2f7b
      Al Viro 提交于
      commit 762c69685ff7ad5ad7fee0656671e20a0c9c864d upstream.
      
      We need to get the underlying dentry of parent; sure, absent the races
      it is the parent of underlying dentry, but there's nothing to prevent
      losing a timeslice to preemtion in the middle of evaluation of
      lower_dentry->d_parent->d_inode, having another process move lower_dentry
      around and have its (ex)parent not pinned anymore and freed on memory
      pressure.  Then we regain CPU and try to fetch ->d_inode from memory
      that is freed by that point.
      
      dentry->d_parent *is* stable here - it's an argument of ->lookup() and
      we are guaranteed that it won't be moved anywhere until we feed it
      to d_add/d_splice_alias.  So we safely go that way to get to its
      underlying dentry.
      
      Cc: stable@vger.kernel.org # since 2009 or so
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bdae2f7b
    • A
      ecryptfs_lookup_interpose(): lower_dentry->d_inode is not stable · beb3860c
      Al Viro 提交于
      commit e72b9dd6a5f17d0fb51f16f8685f3004361e83d0 upstream.
      
      lower_dentry can't go from positive to negative (we have it pinned),
      but it *can* go from negative to positive.  So fetching ->d_inode
      into a local variable, doing a blocking allocation, checking that
      now ->d_inode is non-NULL and feeding the value we'd fetched
      earlier to a function that won't accept NULL is not a good idea.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      beb3860c
    • F
      Btrfs: fix log context list corruption after rename exchange operation · 47d06a15
      Filipe Manana 提交于
      commit e6c617102c7e4ac1398cb0b98ff1f0727755b520 upstream.
      
      During rename exchange we might have successfully log the new name in the
      source root's log tree, in which case we leave our log context (allocated
      on stack) in the root's list of log contextes. However we might fail to
      log the new name in the destination root, in which case we fallback to
      a transaction commit later and never sync the log of the source root,
      which causes the source root log context to remain in the list of log
      contextes. This later causes invalid memory accesses because the context
      was allocated on stack and after rename exchange finishes the stack gets
      reused and overwritten for other purposes.
      
      The kernel's linked list corruption detector (CONFIG_DEBUG_LIST=y) can
      detect this and report something like the following:
      
        [  691.489929] ------------[ cut here ]------------
        [  691.489947] list_add corruption. prev->next should be next (ffff88819c944530), but was ffff8881c23f7be4. (prev=ffff8881c23f7a38).
        [  691.489967] WARNING: CPU: 2 PID: 28933 at lib/list_debug.c:28 __list_add_valid+0x95/0xe0
        (...)
        [  691.489998] CPU: 2 PID: 28933 Comm: fsstress Not tainted 5.4.0-rc6-btrfs-next-62 #1
        [  691.490001] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-0-ga698c8995f-prebuilt.qemu.org 04/01/2014
        [  691.490003] RIP: 0010:__list_add_valid+0x95/0xe0
        (...)
        [  691.490007] RSP: 0018:ffff8881f0b3faf8 EFLAGS: 00010282
        [  691.490010] RAX: 0000000000000000 RBX: ffff88819c944530 RCX: 0000000000000000
        [  691.490011] RDX: 0000000000000001 RSI: 0000000000000008 RDI: ffffffffa2c497e0
        [  691.490013] RBP: ffff8881f0b3fe68 R08: ffffed103eaa4115 R09: ffffed103eaa4114
        [  691.490015] R10: ffff88819c944000 R11: ffffed103eaa4115 R12: 7fffffffffffffff
        [  691.490016] R13: ffff8881b4035610 R14: ffff8881e7b84728 R15: 1ffff1103e167f7b
        [  691.490019] FS:  00007f4b25ea2e80(0000) GS:ffff8881f5500000(0000) knlGS:0000000000000000
        [  691.490021] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        [  691.490022] CR2: 00007fffbb2d4eec CR3: 00000001f2a4a004 CR4: 00000000003606e0
        [  691.490025] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        [  691.490027] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        [  691.490029] Call Trace:
        [  691.490058]  btrfs_log_inode_parent+0x667/0x2730 [btrfs]
        [  691.490083]  ? join_transaction+0x24a/0xce0 [btrfs]
        [  691.490107]  ? btrfs_end_log_trans+0x80/0x80 [btrfs]
        [  691.490111]  ? dget_parent+0xb8/0x460
        [  691.490116]  ? lock_downgrade+0x6b0/0x6b0
        [  691.490121]  ? rwlock_bug.part.0+0x90/0x90
        [  691.490127]  ? do_raw_spin_unlock+0x142/0x220
        [  691.490151]  btrfs_log_dentry_safe+0x65/0x90 [btrfs]
        [  691.490172]  btrfs_sync_file+0x9f1/0xc00 [btrfs]
        [  691.490195]  ? btrfs_file_write_iter+0x1800/0x1800 [btrfs]
        [  691.490198]  ? rcu_read_lock_any_held.part.11+0x20/0x20
        [  691.490204]  ? __do_sys_newstat+0x88/0xd0
        [  691.490207]  ? cp_new_stat+0x5d0/0x5d0
        [  691.490218]  ? do_fsync+0x38/0x60
        [  691.490220]  do_fsync+0x38/0x60
        [  691.490224]  __x64_sys_fdatasync+0x32/0x40
        [  691.490228]  do_syscall_64+0x9f/0x540
        [  691.490233]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
        [  691.490235] RIP: 0033:0x7f4b253ad5f0
        (...)
        [  691.490239] RSP: 002b:00007fffbb2d6078 EFLAGS: 00000246 ORIG_RAX: 000000000000004b
        [  691.490242] RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f4b253ad5f0
        [  691.490244] RDX: 00007fffbb2d5fe0 RSI: 00007fffbb2d5fe0 RDI: 0000000000000003
        [  691.490245] RBP: 000000000000000d R08: 0000000000000001 R09: 00007fffbb2d608c
        [  691.490247] R10: 00000000000002e8 R11: 0000000000000246 R12: 00000000000001f4
        [  691.490248] R13: 0000000051eb851f R14: 00007fffbb2d6120 R15: 00005635a498bda0
      
      This started happening recently when running some test cases from fstests
      like btrfs/004 for example, because support for rename exchange was added
      last week to fsstress from fstests.
      
      So fix this by deleting the log context for the source root from the list
      if we have logged the new name in the source root.
      Reported-by: NSu Yue <Damenly_Su@gmx.com>
      Fixes: d4682ba0 ("Btrfs: sync log after logging new name")
      CC: stable@vger.kernel.org # 4.19+
      Tested-by: NSu Yue <Damenly_Su@gmx.com>
      Signed-off-by: NFilipe Manana <fdmanana@suse.com>
      Signed-off-by: NDavid Sterba <dsterba@suse.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      47d06a15
  2. 13 11月, 2019 11 次提交
  3. 10 11月, 2019 1 次提交
    • D
      cifs: Fix cifsInodeInfo lock_sem deadlock when reconnect occurs · 80b42f43
      Dave Wysochanski 提交于
      [ Upstream commit d46b0da7a33dd8c99d969834f682267a45444ab3 ]
      
      There's a deadlock that is possible and can easily be seen with
      a test where multiple readers open/read/close of the same file
      and a disruption occurs causing reconnect.  The deadlock is due
      a reader thread inside cifs_strict_readv calling down_read and
      obtaining lock_sem, and then after reconnect inside
      cifs_reopen_file calling down_read a second time.  If in
      between the two down_read calls, a down_write comes from
      another process, deadlock occurs.
      
              CPU0                    CPU1
              ----                    ----
      cifs_strict_readv()
       down_read(&cifsi->lock_sem);
                                     _cifsFileInfo_put
                                        OR
                                     cifs_new_fileinfo
                                      down_write(&cifsi->lock_sem);
      cifs_reopen_file()
       down_read(&cifsi->lock_sem);
      
      Fix the above by changing all down_write(lock_sem) calls to
      down_write_trylock(lock_sem)/msleep() loop, which in turn
      makes the second down_read call benign since it will never
      block behind the writer while holding lock_sem.
      Signed-off-by: NDave Wysochanski <dwysocha@redhat.com>
      Suggested-by: NRonnie Sahlberg <lsahlber@redhat.com>
      Reviewed--by: NRonnie Sahlberg <lsahlber@redhat.com>
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      80b42f43
  4. 06 11月, 2019 9 次提交