1. 22 9月, 2020 13 次提交
  2. 08 9月, 2020 21 次提交
    • Y
      block/bio-integrity: don't free 'buf' if bio_integrity_add_page() failed · 24331e56
      yu kuai 提交于
      commit a75ca930 upstream.
      
      commit e7bf90e5 ("block/bio-integrity: fix a memory leak bug") added
      a kfree() for 'buf' if bio_integrity_add_page() returns '0'. However,
      the object will be freed in bio_integrity_free() since 'bio->bi_opf' and
      'bio->bi_integrity' were set previousy in bio_integrity_alloc().
      
      Fixes: commit e7bf90e5 ("block/bio-integrity: fix a memory leak bug")
      Signed-off-by: Nyu kuai <yukuai3@huawei.com>
      Reviewed-by: NMing Lei <ming.lei@redhat.com>
      Reviewed-by: NBob Liu <bob.liu@oracle.com>
      Acked-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      24331e56
    • D
      arm64/ascend: set the correct dvpp mmap area when no MAP_DVPP flags · 0d940005
      Ding Tianhong 提交于
      ascend inclusion
      category: feature
      bugzilla: NA
      CVE: NA
      
      -------------------------------------------------
      
      The commit 4daf80d7164 ("arm64/ascend: Enable...") missed to set the
      correct dvpp mmap area when the user didn't set the MAP_DVPP flags,
      so add new area zone to fix this.
      
      And fix some coding style, rename the enable_map_dvpp to
      enable_mmap_dvpp.
      
      v2: return true if the input addr is DVPP_MMAP_BASE for dvpp_mmap_zone.
      
      Fixes: 4daf80d7164 ("arm64/ascend: Enable DvPP mmap features for Ascend Platform")
      Signed-off-by: NDing Tianhong <dingtianhong@huawei.com>
      Reviewed-by: NHanjun Guo <guohanjun@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      0d940005
    • J
      ext4: fix error pointer dereference · 5e7cbe34
      Jeffle Xu 提交于
      commit 8418897f upstream.
      
      Don't pass error pointers to brelse().
      
      commit 7159a986 ("ext4: fix some error pointer dereferences") has fixed
      some cases, fix the remaining one case.
      
      Once ext4_xattr_block_find()->ext4_sb_bread() failed, error pointer is
      stored in @bs->bh, which will be passed to brelse() in the cleanup
      routine of ext4_xattr_set_handle(). This will then cause a NULL panic
      crash in __brelse().
      
      BUG: unable to handle kernel NULL pointer dereference at 000000000000005b
      RIP: 0010:__brelse+0x1b/0x50
      Call Trace:
       ext4_xattr_set_handle+0x163/0x5d0
       ext4_xattr_set+0x95/0x110
       __vfs_setxattr+0x6b/0x80
       __vfs_setxattr_noperm+0x68/0x1b0
       vfs_setxattr+0xa0/0xb0
       setxattr+0x12c/0x1a0
       path_setxattr+0x8d/0xc0
       __x64_sys_setxattr+0x27/0x30
       do_syscall_64+0x60/0x250
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      In this case, @bs->bh stores '-EIO' actually.
      
      Fixes: fb265c9c ("ext4: add ext4_sb_bread() to disambiguate ENOMEM cases")
      Signed-off-by: NJeffle Xu <jefflexu@linux.alibaba.com>
      Reviewed-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
      Cc: stable@kernel.org # 2.6.19
      Reviewed-by: NRitesh Harjani <riteshh@linux.ibm.com>
      Reviewed-by: NJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/1587628004-95123-1-git-send-email-jefflexu@linux.alibaba.comSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      5e7cbe34
    • J
      ext4: Avoid freeing inodes on dirty list · 9f8162b2
      Jan Kara 提交于
      mainline inclusion
      from mainline-5.8-rc1
      commit ceff86fd
      category: bugfix
      bugzilla: 37213
      CVE: NA
      
      -------------------------------------------------
      
      When we are evicting inode with journalled data, we may race with
      transaction commit in the following way:
      
      CPU0					CPU1
      jbd2_journal_commit_transaction()	evict(inode)
      					  inode_io_list_del()
      					  inode_wait_for_writeback()
        process BJ_Forget list
          __jbd2_journal_insert_checkpoint()
          __jbd2_journal_refile_buffer()
            __jbd2_journal_unfile_buffer()
              if (test_clear_buffer_jbddirty(bh))
                mark_buffer_dirty(bh)
      	    __mark_inode_dirty(inode)
      					  ext4_evict_inode(inode)
      					    frees the inode
      
      This results in use-after-free issues in the writeback code (or
      the assertion added in the previous commit triggering).
      
      Fix the problem by removing inode from writeback lists once all the page
      cache is evicted and so inode cannot be added to writeback lists again.
      Signed-off-by: NJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20200421085445.5731-4-jack@suse.czSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: NLuo Meng <luomeng12@huawei.com>
      Reviewed-by: Nzhangyi (F) <yi.zhang@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      9f8162b2
    • J
      writeback: Export inode_io_list_del() · 2187329d
      Jan Kara 提交于
      mainline inclusion
      from mainline-5.8-rc1
      commit 4301efa4
      category: bugfix
      bugzilla: NA
      CVE: NA
      
      -------------------------------------------------
      
      Ext4 needs to remove inode from writeback lists after it is out of
      visibility of its journalling machinery (which can still dirty the
      inode). Export inode_io_list_del() for it.
      Signed-off-by: NJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20200421085445.5731-3-jack@suse.czSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: NLuo Meng <luomeng12@huawei.com>
      Reviewed-by: Nzhangyi (F) <yi.zhang@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      2187329d
    • L
      blktrace: ensure our debugfs dir exists · 8fad5e26
      Luis Chamberlain 提交于
      mainline inclusion
      from mainline-v5.9-rc1
      commit b431ef83
      category: bugfix
      bugzilla: 30213
      CVE: CVE-2019-19770
      
      ---------------------------
      
      We make an assumption that a debugfs directory exists, but since
      this can fail ensure it exists before allowing blktrace setup to
      complete. Otherwise we end up stuffing blktrace files on the debugfs
      root directory. In the worst case scenario this *in theory* can create
      an eventual panic *iff* in the future a similarly named file is created
      prior on the debugfs root directory. This theoretical crash can happen
      due to a recursive removal followed by a specific dentry removal.
      
      This doesn't fix any known crash, however I have seen the files
      go into the main debugfs root directory in cases where the debugfs
      directory was not created due to other internal bugs with blktrace
      now fixed.
      
      blktrace is also completely useless without this directory, so
      this ensures to userspace we only setup blktrace if the kernel
      can stuff files where they are supposed to go into.
      
      debugfs directory creations typically aren't checked for, and we have
      maintainers doing sweep removals of these checks, but since we need this
      check to ensure proper userspace blktrace functionality we make sure
      to annotate the justification for the check.
      Signed-off-by: NLuis Chamberlain <mcgrof@kernel.org>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NBart Van Assche <bvanassche@acm.org>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      
      Conflict: kernel/trace/blktrace.c
      Signed-off-by: NYu Kuai <yukuai3@huawei.com>
      Reviewed-by: NYufen Yu <yuyufen@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      8fad5e26
    • L
      blktrace: fix debugfs use after free · ffc8a249
      Luis Chamberlain 提交于
      mainline inclusion
      from mainline-v5.9-rc1
      commit bad8e64f
      category: bugfix
      bugzilla: 30213
      CVE: CVE-2019-19770
      
      ---------------------------
      
      On commit 6ac93117 ("blktrace: use existing disk debugfs directory")
      merged on v4.12 Omar fixed the original blktrace code for request-based
      drivers (multiqueue). This however left in place a possible crash, if you
      happen to abuse blktrace while racing to remove / add a device.
      
      We used to use asynchronous removal of the request_queue, and with that
      the issue was easier to reproduce. Now that we have reverted to
      synchronous removal of the request_queue, the issue is still possible to
      reproduce, its however just a bit more difficult.
      
      We essentially run two instances of break-blktrace which add/remove
      a loop device, and setup a blktrace and just never tear the blktrace
      down. We do this twice in parallel. This is easily reproduced with the
      script run_0004.sh from break-blktrace [0].
      
      We can end up with two types of panics each reflecting where we
      race, one a failed blktrace setup:
      
      [  252.426751] debugfs: Directory 'loop0' with parent 'block' already present!
      [  252.432265] BUG: kernel NULL pointer dereference, address: 00000000000000a0
      [  252.436592] #PF: supervisor write access in kernel mode
      [  252.439822] #PF: error_code(0x0002) - not-present page
      [  252.442967] PGD 0 P4D 0
      [  252.444656] Oops: 0002 [#1] SMP NOPTI
      [  252.446972] CPU: 10 PID: 1153 Comm: break-blktrace Tainted: G            E     5.7.0-rc2-next-20200420+ #164
      [  252.452673] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1 04/01/2014
      [  252.456343] RIP: 0010:down_write+0x15/0x40
      [  252.458146] Code: eb ca e8 ae 22 8d ff cc cc cc cc cc cc cc cc cc cc cc cc
                     cc cc 0f 1f 44 00 00 55 48 89 fd e8 52 db ff ff 31 c0 ba 01 00
                     00 00 <f0> 48 0f b1 55 00 75 0f 48 8b 04 25 c0 8b 01 00 48 89
                     45 08 5d
      [  252.463638] RSP: 0018:ffffa626415abcc8 EFLAGS: 00010246
      [  252.464950] RAX: 0000000000000000 RBX: ffff958c25f0f5c0 RCX: ffffff8100000000
      [  252.466727] RDX: 0000000000000001 RSI: ffffff8100000000 RDI: 00000000000000a0
      [  252.468482] RBP: 00000000000000a0 R08: 0000000000000000 R09: 0000000000000001
      [  252.470014] R10: 0000000000000000 R11: ffff958d1f9227ff R12: 0000000000000000
      [  252.471473] R13: ffff958c25ea5380 R14: ffffffff8cce15f1 R15: 00000000000000a0
      [  252.473346] FS:  00007f2e69dee540(0000) GS:ffff958c2fc80000(0000) knlGS:0000000000000000
      [  252.475225] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  252.476267] CR2: 00000000000000a0 CR3: 0000000427d10004 CR4: 0000000000360ee0
      [  252.477526] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [  252.478776] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [  252.479866] Call Trace:
      [  252.480322]  simple_recursive_removal+0x4e/0x2e0
      [  252.481078]  ? debugfs_remove+0x60/0x60
      [  252.481725]  ? relay_destroy_buf+0x77/0xb0
      [  252.482662]  debugfs_remove+0x40/0x60
      [  252.483518]  blk_remove_buf_file_callback+0x5/0x10
      [  252.484328]  relay_close_buf+0x2e/0x60
      [  252.484930]  relay_open+0x1ce/0x2c0
      [  252.485520]  do_blk_trace_setup+0x14f/0x2b0
      [  252.486187]  __blk_trace_setup+0x54/0xb0
      [  252.486803]  blk_trace_ioctl+0x90/0x140
      [  252.487423]  ? do_sys_openat2+0x1ab/0x2d0
      [  252.488053]  blkdev_ioctl+0x4d/0x260
      [  252.488636]  block_ioctl+0x39/0x40
      [  252.489139]  ksys_ioctl+0x87/0xc0
      [  252.489675]  __x64_sys_ioctl+0x16/0x20
      [  252.490380]  do_syscall_64+0x52/0x180
      [  252.491032]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      And the other on the device removal:
      
      [  128.528940] debugfs: Directory 'loop0' with parent 'block' already present!
      [  128.615325] BUG: kernel NULL pointer dereference, address: 00000000000000a0
      [  128.619537] #PF: supervisor write access in kernel mode
      [  128.622700] #PF: error_code(0x0002) - not-present page
      [  128.625842] PGD 0 P4D 0
      [  128.627585] Oops: 0002 [#1] SMP NOPTI
      [  128.629871] CPU: 12 PID: 544 Comm: break-blktrace Tainted: G            E     5.7.0-rc2-next-20200420+ #164
      [  128.635595] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1 04/01/2014
      [  128.640471] RIP: 0010:down_write+0x15/0x40
      [  128.643041] Code: eb ca e8 ae 22 8d ff cc cc cc cc cc cc cc cc cc cc cc cc
                     cc cc 0f 1f 44 00 00 55 48 89 fd e8 52 db ff ff 31 c0 ba 01 00
                     00 00 <f0> 48 0f b1 55 00 75 0f 65 48 8b 04 25 c0 8b 01 00 48 89
                     45 08 5d
      [  128.650180] RSP: 0018:ffffa9c3c05ebd78 EFLAGS: 00010246
      [  128.651820] RAX: 0000000000000000 RBX: ffff8ae9a6370240 RCX: ffffff8100000000
      [  128.653942] RDX: 0000000000000001 RSI: ffffff8100000000 RDI: 00000000000000a0
      [  128.655720] RBP: 00000000000000a0 R08: 0000000000000002 R09: ffff8ae9afd2d3d0
      [  128.657400] R10: 0000000000000056 R11: 0000000000000000 R12: 0000000000000000
      [  128.659099] R13: 0000000000000000 R14: 0000000000000003 R15: 00000000000000a0
      [  128.660500] FS:  00007febfd995540(0000) GS:ffff8ae9afd00000(0000) knlGS:0000000000000000
      [  128.662204] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  128.663426] CR2: 00000000000000a0 CR3: 0000000420042003 CR4: 0000000000360ee0
      [  128.664776] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [  128.666022] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [  128.667282] Call Trace:
      [  128.667801]  simple_recursive_removal+0x4e/0x2e0
      [  128.668663]  ? debugfs_remove+0x60/0x60
      [  128.669368]  debugfs_remove+0x40/0x60
      [  128.669985]  blk_trace_free+0xd/0x50
      [  128.670593]  __blk_trace_remove+0x27/0x40
      [  128.671274]  blk_trace_shutdown+0x30/0x40
      [  128.671935]  blk_release_queue+0x95/0xf0
      [  128.672589]  kobject_put+0xa5/0x1b0
      [  128.673188]  disk_release+0xa2/0xc0
      [  128.673786]  device_release+0x28/0x80
      [  128.674376]  kobject_put+0xa5/0x1b0
      [  128.674915]  loop_remove+0x39/0x50 [loop]
      [  128.675511]  loop_control_ioctl+0x113/0x130 [loop]
      [  128.676199]  ksys_ioctl+0x87/0xc0
      [  128.676708]  __x64_sys_ioctl+0x16/0x20
      [  128.677274]  do_syscall_64+0x52/0x180
      [  128.677823]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      The common theme here is:
      
      debugfs: Directory 'loop0' with parent 'block' already present
      
      This crash happens because of how blktrace uses the debugfs directory
      where it places its files. Upon init we always create the same directory
      which would be needed by blktrace but we only do this for make_request
      drivers (multiqueue) block drivers. When you race a removal of these
      devices with a blktrace setup you end up in a situation where the
      make_request recursive debugfs removal will sweep away the blktrace
      files and then later blktrace will also try to remove individual
      dentries which are already NULL. The inverse is also possible and hence
      the two types of use after frees.
      
      We don't create the block debugfs directory on init for these types of
      block devices:
      
        * request-based block driver block devices
        * every possible partition
        * scsi-generic
      
      And so, this race should in theory only be possible with make_request
      drivers.
      
      We can fix the UAF by simply re-using the debugfs directory for
      make_request drivers (multiqueue) and only creating the ephemeral
      directory for the other type of block devices. The new clarifications
      on relying on the q->blk_trace_mutex *and* also checking for q->blk_trace
      *prior* to processing a blktrace ensures the debugfs directories are
      only created if no possible directory name clashes are possible.
      
      This goes tested with:
      
        o nvme partitions
        o ISCSI with tgt, and blktracing against scsi-generic with:
          o block
          o tape
          o cdrom
          o media changer
        o blktests
      
      This patch is part of the work which disputes the severity of
      CVE-2019-19770 which shows this issue is not a core debugfs issue, but
      a misuse of debugfs within blktace.
      
      Fixes: 6ac93117 ("blktrace: use existing disk debugfs directory")
      Reported-by: syzbot+603294af2d01acfdd6da@syzkaller.appspotmail.com
      Signed-off-by: NLuis Chamberlain <mcgrof@kernel.org>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Cc: Bart Van Assche <bvanassche@acm.org>
      Cc: Omar Sandoval <osandov@fb.com>
      Cc: Hannes Reinecke <hare@suse.com>
      Cc: Nicolai Stange <nstange@suse.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Michal Hocko <mhocko@kernel.org>
      Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
      Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
      Cc: yu kuai <yukuai3@huawei.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      
      Conflict: kernel/trace/blktrace.c
       use 'q->mq_ops' instead of 'queue_is_mq(q)'
      Signed-off-by: NYu Kuai <yukuai3@huawei.com>
      Reviewed-by: NYufen Yu <yuyufen@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      ffc8a249
    • L
      loop: be paranoid on exit and prevent new additions / removals · a029d57b
      Luis Chamberlain 提交于
      [ Upstream commit 200f9337 ]
      
      Be pedantic on removal as well and hold the mutex.
      This should prevent uses of addition while we exit.
      Signed-off-by: NLuis Chamberlain <mcgrof@kernel.org>
      Reviewed-by: NMing Lei <ming.lei@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      a029d57b
    • Y
      Revert "block: rename 'q->debugfs_dir' and 'q->blk_trace->dir' in blk_unregister_queue()" · b764f806
      Yu Kuai 提交于
      hulk inclusion
      category: bugfix
      bugzilla: 30213
      CVE: CVE-2019-19770
      
      ---------------------------
      
      The UAF in blktrace was fixed by a different approch from mainline, thus
      revert our solution and backport related patches.
      Signed-off-by: NYu Kuai <yukuai3@huawei.com>
      Reviewed-by: NYufen Yu <yuyufen@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      b764f806
    • H
      ext4: force buffer up-to-date while marking it dirty · ab7f2b5c
      Harshad Shirwadkar 提交于
      mainline inclusion
      from mainline-v5.7-rc1
      commit f2eeca09
      category: bugfix
      bugzilla: 41998
      CVE: NA
      
      -----------------------------------------------
      
      Writeback errors can leave buffer in not up-to-date state when there
      are errors during background writes. Force buffer up-to-date while
      marking it dirty.
      Signed-off-by: NHarshad Shirwadkar <harshadshirwadkar@gmail.com>
      Link: https://lore.kernel.org/r/20191224190940.157952-1-harshadshirwadkar@gmail.comSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: NYe Bin <yebin10@huawei.com>
      Reviewed-by: Nzhangyi (F) <yi.zhang@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      ab7f2b5c
    • Q
      ext4: fix a data race at inode->i_disksize · fb6c78db
      Qiujun Huang 提交于
      mainline inclusion
      from mainline-5.7-rc1
      commit dce8e237
      category: bugfix
      bugzilla: 33842
      CVE: NA
      
      -------------------------------------------------
      
      KCSAN find inode->i_disksize could be accessed concurrently.
      
      BUG: KCSAN: data-race in ext4_mark_iloc_dirty / ext4_write_end
      
      write (marked) to 0xffff8b8932f40090 of 8 bytes by task 66792 on cpu 0:
       ext4_write_end+0x53f/0x5b0
       ext4_da_write_end+0x237/0x510
       generic_perform_write+0x1c4/0x2a0
       ext4_buffered_write_iter+0x13a/0x210
       ext4_file_write_iter+0xe2/0x9b0
       new_sync_write+0x29c/0x3a0
       __vfs_write+0x92/0xa0
       vfs_write+0xfc/0x2a0
       ksys_write+0xe8/0x140
       __x64_sys_write+0x4c/0x60
       do_syscall_64+0x8a/0x2a0
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      read to 0xffff8b8932f40090 of 8 bytes by task 14414 on cpu 1:
       ext4_mark_iloc_dirty+0x716/0x1190
       ext4_mark_inode_dirty+0xc9/0x360
       ext4_convert_unwritten_extents+0x1bc/0x2a0
       ext4_convert_unwritten_io_end_vec+0xc5/0x150
       ext4_put_io_end+0x82/0x130
       ext4_writepages+0xae7/0x16f0
       do_writepages+0x64/0x120
       __writeback_single_inode+0x7d/0x650
       writeback_sb_inodes+0x3a4/0x860
       __writeback_inodes_wb+0xc4/0x150
       wb_writeback+0x43f/0x510
       wb_workfn+0x3b2/0x8a0
       process_one_work+0x39b/0x7e0
       worker_thread+0x88/0x650
       kthread+0x1d4/0x1f0
       ret_from_fork+0x35/0x40
      
      The plain read is outside of inode->i_data_sem critical section
      which results in a data race. Fix it by adding READ_ONCE().
      Signed-off-by: NQiujun Huang <hqjagain@gmail.com>
      Link: https://lore.kernel.org/r/1582556566-3909-1-git-send-email-hqjagain@gmail.comSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: NLuo Meng <luomeng12@huawei.com>
      Reviewed-by: Nzhangyi (F) <yi.zhang@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      fb6c78db
    • Q
      ext4: fix a data race at inode->i_blocks · d2f0e947
      Qian Cai 提交于
      commit 28936b62 upstream.
      
      inode->i_blocks could be accessed concurrently as noticed by KCSAN,
      
       BUG: KCSAN: data-race in ext4_do_update_inode [ext4] / inode_add_bytes
      
       write to 0xffff9a00d4b982d0 of 8 bytes by task 22100 on cpu 118:
        inode_add_bytes+0x65/0xf0
        __inode_add_bytes at fs/stat.c:689
        (inlined by) inode_add_bytes at fs/stat.c:702
        ext4_mb_new_blocks+0x418/0xca0 [ext4]
        ext4_ext_map_blocks+0x1a6b/0x27b0 [ext4]
        ext4_map_blocks+0x1a9/0x950 [ext4]
        _ext4_get_block+0xfc/0x270 [ext4]
        ext4_get_block_unwritten+0x33/0x50 [ext4]
        __block_write_begin_int+0x22e/0xae0
        __block_write_begin+0x39/0x50
        ext4_write_begin+0x388/0xb50 [ext4]
        ext4_da_write_begin+0x35f/0x8f0 [ext4]
        generic_perform_write+0x15d/0x290
        ext4_buffered_write_iter+0x11f/0x210 [ext4]
        ext4_file_write_iter+0xce/0x9e0 [ext4]
        new_sync_write+0x29c/0x3b0
        __vfs_write+0x92/0xa0
        vfs_write+0x103/0x260
        ksys_write+0x9d/0x130
        __x64_sys_write+0x4c/0x60
        do_syscall_64+0x91/0xb05
        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
       read to 0xffff9a00d4b982d0 of 8 bytes by task 8 on cpu 65:
        ext4_do_update_inode+0x4a0/0xf60 [ext4]
        ext4_inode_blocks_set at fs/ext4/inode.c:4815
        ext4_mark_iloc_dirty+0xaf/0x160 [ext4]
        ext4_mark_inode_dirty+0x129/0x3e0 [ext4]
        ext4_convert_unwritten_extents+0x253/0x2d0 [ext4]
        ext4_convert_unwritten_io_end_vec+0xc5/0x150 [ext4]
        ext4_end_io_rsv_work+0x22c/0x350 [ext4]
        process_one_work+0x54f/0xb90
        worker_thread+0x80/0x5f0
        kthread+0x1cd/0x1f0
        ret_from_fork+0x27/0x50
      
       4 locks held by kworker/u256:0/8:
        #0: ffff9a025abc4328 ((wq_completion)ext4-rsv-conversion){+.+.}, at: process_one_work+0x443/0xb90
        #1: ffffab5a862dbe20 ((work_completion)(&ei->i_rsv_conversion_work)){+.+.}, at: process_one_work+0x443/0xb90
        #2: ffff9a025a9d0f58 (jbd2_handle){++++}, at: start_this_handle+0x1c1/0x9d0 [jbd2]
        #3: ffff9a00d4b985d8 (&(&ei->i_raw_lock)->rlock){+.+.}, at: ext4_do_update_inode+0xaa/0xf60 [ext4]
       irq event stamp: 3009267
       hardirqs last  enabled at (3009267): [<ffffffff980da9b7>] __find_get_block+0x107/0x790
       hardirqs last disabled at (3009266): [<ffffffff980da8f9>] __find_get_block+0x49/0x790
       softirqs last  enabled at (3009230): [<ffffffff98a0034c>] __do_softirq+0x34c/0x57c
       softirqs last disabled at (3009223): [<ffffffff97cc67a2>] irq_exit+0xa2/0xc0
      
       Reported by Kernel Concurrency Sanitizer on:
       CPU: 65 PID: 8 Comm: kworker/u256:0 Tainted: G L 5.6.0-rc2-next-20200221+ #7
       Hardware name: HPE ProLiant DL385 Gen10/ProLiant DL385 Gen10, BIOS A40 07/10/2019
       Workqueue: ext4-rsv-conversion ext4_end_io_rsv_work [ext4]
      
      The plain read is outside of inode->i_lock critical section which
      results in a data race. Fix it by adding READ_ONCE() there.
      
      Link: https://lore.kernel.org/r/20200222043258.2279-1-cai@lca.pwSigned-off-by: NQian Cai <cai@lca.pw>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      d2f0e947
    • Z
      jbd2: abort journal if free a async write error metadata buffer · 7d2b50de
      zhangyi (F) 提交于
      mainline inclusion
      from mainline-v5.9-rc2
      commit c044f3d8
      category: bugfix
      bugzilla: 34540
      CVE: NA
      ---------------------------
      
      If we free a metadata buffer which has been failed to async write out
      in the background, the jbd2 checkpoint procedure will not detect this
      failure in jbd2_log_do_checkpoint(), so it may lead to filesystem
      inconsistency after cleanup journal tail. This patch abort the journal
      if free a buffer has write_io_error flag to prevent potential further
      inconsistency.
      Signed-off-by: Nzhangyi (F) <yi.zhang@huawei.com>
      Link: https://lore.kernel.org/r/20200620025427.1756360-5-yi.zhang@huawei.comSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
      Reviewed-by: NYang Erkun <yangerkun@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      7d2b50de
    • Z
      ext4: abort the filesystem if failed to async write metadata buffer · 70b6a81b
      zhangyi (F) 提交于
      mainline inclusion
      from mainline-v5.9-rc2
      commit bc71726c
      category: bugfix
      bugzilla: 34540
      CVE: NA
      ---------------------------
      
      There is a risk of filesystem inconsistency if we failed to async write
      back metadata buffer in the background. Because of current buffer's end
      io procedure is handled by end_buffer_async_write() in the block layer,
      and it only clear the buffer's uptodate flag and mark the write_io_error
      flag, so ext4 cannot detect such failure immediately. In most cases of
      getting metadata buffer (e.g. ext4_read_inode_bitmap()), although the
      buffer's data is actually uptodate, it may still read data from disk
      because the buffer's uptodate flag has been cleared. Finally, it may
      lead to on-disk filesystem inconsistency if reading old data from the
      disk successfully and write them out again.
      
      This patch detect bdev mapping->wb_err when getting journal's write
      access and mark the filesystem error if bdev's mapping->wb_err was
      increased, this could prevent further writing and potential
      inconsistency.
      Signed-off-by: Nzhangyi (F) <yi.zhang@huawei.com>
      Suggested-by: NJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20200620025427.1756360-2-yi.zhang@huawei.comSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
      
      Conflict:
        fs/ext4/super.c
        fs/ext4/ext4_jbd2.c
      Signed-off-by: Nzhangyi (F) <yi.zhang@huawei.com>
      Reviewed-by: NYang Erkun <yangerkun@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      70b6a81b
    • S
      net: hns3: update hns3 version to 1.9.38.7 · c27f6ae5
      Shengzui You 提交于
      driver inclusion
      category: bugfix
      bugzilla: NA
      CVE: NA
      
      -----------------------------
      
      This patch is used to update driver version to 1.9.38.7.
      Signed-off-by: NShengzui You <youshengzui@huawei.com>
      Reviewed-by: NWeiwei Deng <dengweiwei@huawei.com>
      Reviewed-by: NZhaohui Zhong <zhongzhaohui@huawei.com>
      Reviewed-by: NJunxin Chen <chenjunxin1@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      c27f6ae5
    • Y
      net: hns3: initialize the message content sent to the VF · 9b9e9055
      Yufeng Mo 提交于
      driver inclusion
      category: bugfix
      bugzilla: NA
      CVE: NA
      
      ------------------------------------
      
      All content sent from the PF to the VF needs to be initialized
      or assigned a value. Otherwise, the content is a random value,
      which may cause information leakage. This is the case of msg_data[1]
      in hclge_get_link_mode(), which causes information leakage.
      Signed-off-by: NYufeng Mo <moyufeng@huawei.com>
      Reviewed-by: NPeng Li <lipeng321@huawei.com>
      Reviewed-by: NWeiwei Deng <dengweiwei@huawei.com>
      Reviewed-by: NZhaohui Zhong <zhongzhaohui@huawei.com>
      Reviewed-by: NJunxin Chen <chenjunxin1@huawei.com>
      Signed-off-by: NShengzui You <youshengzui@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      9b9e9055
    • G
      net: hns3: check vlan id before using it · 647f96f3
      Guojia Liao 提交于
      driver inclusion
      category: bugfix
      bugzilla: NA
      CVE: NA
      
      -------------------------------------
      
      The input parameters may not be reliable. Before using the vlan id,
      we should check this parameter. Otherwise some unexpect error may occur.
      Signed-off-by: NGuojia Liao <liaoguojia@huawei.com>
      Reviewed-by: NPeng Li <lipeng321@huawei.com>
      Reviewed-by: NWeiwei Deng <dengweiwei@huawei.com>
      Reviewed-by: NZhaohui Zhong <zhongzhaohui@huawei.com>
      Reviewed-by: NJunxin Chen <chenjunxin1@huawei.com>
      Signed-off-by: NShengzui You <youshengzui@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      647f96f3
    • G
      net: hns3: check RSS key index before using · 0975ff77
      Guojia Liao 提交于
      driver inclusion
      category: bugfix
      bugzilla: NA
      CVE: NA
      
      ---------------------------------
      
      The input parameters may not be reliable. Before using the
      rss hash key index, we should check this parameter. Otherwise
      out-of-bounds array may occur.
      Signed-off-by: NGuojia Liao <liaoguojia@huawei.com>
      Reviewed-by: NPeng Li <lipeng321@huawei.com>
      Reviewed-by: NWeiwei Deng <dengweiwei@huawei.com>
      Reviewed-by: NZhaohui Zhong <zhongzhaohui@huawei.com>
      Reviewed-by: NJunxin Chen <chenjunxin1@huawei.com>
      Signed-off-by: NShengzui You <youshengzui@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      0975ff77
    • Y
      net: hns3: check cmdq message parameters sent from VF · 6de25bac
      Yufeng Mo 提交于
      driver inclusion
      category: bugfix
      bugzilla: NA
      CVE: NA
      
      -----------------------------------
      
      The parameters sent from VF may be unreliable. If these
      parameters are used directly, memory overwriting may occur.
      Therefore, we need to check parameters before using.
      Signed-off-by: NYufeng Mo <moyufeng@huawei.com>
      Reviewed-by: NPeng Li <lipeng321@huawei.com>
      Reviewed-by: NWeiwei Deng <dengweiwei@huawei.com>
      Reviewed-by: NZhaohui Zhong <zhongzhaohui@huawei.com>
      Reviewed-by: NJunxin Chen <chenjunxin1@huawei.com>
      Signed-off-by: NShengzui You <youshengzui@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      6de25bac
    • Y
      config: add certs dir to CONFIG_MODULE_SIG_KEY · 5ee9b558
      Yang Yingliang 提交于
      hulk inclusion
      category: bugfix
      bugzilla: NA
      CVE: NA
      
      ---------------------------
      
      make[1]: *** No rule to make target 'signing_key.pem', needed by 'certs/signing_key.x509'.  Stop.
      Fix the compile error by add certs dir to CONFIG_MODULE_SIG_KEY.
      Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      5ee9b558
    • C
      net/hinic: Fix Oops when probing hinic driver · e3e20339
      Chiqijun 提交于
      driver inclusion
      category: bugfix
      bugzilla: 4472
      
      -----------------------------------------------------------------------
      
      When the first mbox/cmdq command times out, the driver reschedules the
      work/tasklet, but the private data is not assigned, resulting in null
      pointer access.
      
      To fix this bug we delete the private data of work/tasklet, and get eq
      with container_of from work or setting eq as tasklet's private data.
      Signed-off-by: NChiqijun <chiqijun@huawei.com>
      Reviewed-by: NZengweiliang <zengweiliang.zengweiliang@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      e3e20339
  3. 31 8月, 2020 6 次提交