1. 20 Jun, 2022 1 commit
    • Greg Kroah-Hartman's avatar
      Merge tag 'iio-fixes-for-5.19a' of... · 315f7e15
      Greg Kroah-Hartman authored
      Merge tag 'iio-fixes-for-5.19a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next
      
      Jonathan writes:
      
      1st set of IIO fixes for the 5.19 cycle.
      
      Most of these have been in next for a long time. Unfortunately there
      was one stray patch in the branch (wasn't a fix), so I've just rebased
      to remove that.
      
      * testing
        - Fix a missing MODULE_LICENSE() warning by restricting possible build
          configs.
      * Various drivers
        - Fix ordering of iio_get_trigger() being called before
          iio_trigger_register()
      * adi,admv1014
        - Fix dubious x & !y warning.
      * adi,axi-adc
        - Fix missing of_node_put() in error and normal paths.
      * aspeed,adc
        - Add missing of_node_put()
      * fsl,mma8452
        - Fix broken probing from device tree.
        - Drop check on return value of i2c write to device to cause reset as
          ACK will be missing (device reset before sending it).
      * fsl,vf610
        - Fix documentation of in_conversion_mode ABI.
      * iio-trig-sysfs
        - Ensure irq work has finished before freeing the trigger.
      * invensense,mpu3050
       - Disable regulators in error path.
      * invensense,icm42600
        - Fix collision of enum value of 0 with error path where 0 is no match.
      * renesas,rzg2l_Adc
        - Add missing fwnode_handle_put() in error path.
      * rescale
        - Fix a boolean logic bug for detection of raw + scale affecting an
          obscure corner case.
      * semtech,sx9324
        - Check return value of read of pin_defs
      * st,stm32-adc:
        - Fix interaction across ADC instances for some supported devices.
        - Drop false spurious IRQ messages.
        - Fix calibration value handling.  If we can't calibrate don't expose the
          vref_int channel.
        - Fix maximum clock rate for stm32pm15x
      * ti,ads131e08
        - Add missing fwnode_handle_put() in error paths.
      * xilinx,ams
        - Fix variable checked for error from platform_get_irq()
      * x-powers,axp288
        - Overide TS_PIN bias current for boards where it is not correctly
          initialized.
      * yamaha,yas530
        - Fix inverted check on calibration data being all zeros.
      
      * tag 'iio-fixes-for-5.19a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (26 commits)
        iio:proximity:sx9324: Check ret value of device_property_read_u32_array()
        iio: accel: mma8452: ignore the return value of reset operation
        iio: adc: stm32: fix maximum clock rate for stm32mp15x
        iio: adc: stm32: fix vrefint wrong calibration value handling
        iio: imu: inv_icm42600: Fix broken icm42600 (chip id 0 value)
        iio: adc: vf610: fix conversion mode sysfs node name
        iio: adc: adi-axi-adc: Fix refcount leak in adi_axi_adc_attach_client
        iio: test: fix missing MODULE_LICENSE for IIO_RESCALE=m
        iio:humidity:hts221: rearrange iio trigger get and register
        iio:chemical:ccs811: rearrange iio trigger get and register
        iio:accel:mxc4005: rearrange iio trigger get and register
        iio:accel:kxcjk-1013: rearrange iio trigger get and register
        iio:accel:bma180: rearrange iio trigger get and register
        iio: afe: rescale: Fix boolean logic bug
        iio: adc: aspeed: Fix refcount leak in aspeed_adc_set_trim_data
        iio: adc: stm32: Fix IRQs on STM32F4 by removing custom spurious IRQs message
        iio: adc: stm32: Fix ADCs iteration in irq handler
        iio: adc: ti-ads131e08: add missing fwnode_handle_put() in ads131e08_alloc_channels()
        iio: adc: rzg2l_adc: add missing fwnode_handle_put() in rzg2l_adc_parse_properties()
        iio: trigger: sysfs: fix use-after-free on remove
        ...
      315f7e15
  2. 19 Jun, 2022 33 commits
  3. 18 Jun, 2022 6 commits
    • Xiang wangx's avatar
    • Zhang Yi's avatar
      ext4: add reserved GDT blocks check · b55c3cd1
      Zhang Yi authored
      We capture a NULL pointer issue when resizing a corrupt ext4 image which
      is freshly clear resize_inode feature (not run e2fsck). It could be
      simply reproduced by following steps. The problem is because of the
      resize_inode feature was cleared, and it will convert the filesystem to
      meta_bg mode in ext4_resize_fs(), but the es->s_reserved_gdt_blocks was
      not reduced to zero, so could we mistakenly call reserve_backup_gdb()
      and passing an uninitialized resize_inode to it when adding new group
      descriptors.
      
       mkfs.ext4 /dev/sda 3G
       tune2fs -O ^resize_inode /dev/sda #forget to run requested e2fsck
       mount /dev/sda /mnt
       resize2fs /dev/sda 8G
      
       ========
       BUG: kernel NULL pointer dereference, address: 0000000000000028
       CPU: 19 PID: 3243 Comm: resize2fs Not tainted 5.18.0-rc7-00001-gfde086c5ebfd #748
       ...
       RIP: 0010:ext4_flex_group_add+0xe08/0x2570
       ...
       Call Trace:
        <TASK>
        ext4_resize_fs+0xbec/0x1660
        __ext4_ioctl+0x1749/0x24e0
        ext4_ioctl+0x12/0x20
        __x64_sys_ioctl+0xa6/0x110
        do_syscall_64+0x3b/0x90
        entry_SYSCALL_64_after_hwframe+0x44/0xae
       RIP: 0033:0x7f2dd739617b
       ========
      
      The fix is simple, add a check in ext4_resize_begin() to make sure that
      the es->s_reserved_gdt_blocks is zero when the resize_inode feature is
      disabled.
      
      Cc: stable@kernel.org
      Signed-off-by: default avatarZhang Yi <yi.zhang@huawei.com>
      Reviewed-by: default avatarRitesh Harjani <ritesh.list@gmail.com>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20220601092717.763694-1-yi.zhang@huawei.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      b55c3cd1
    • Ding Xiang's avatar
      ext4: make variable "count" signed · bc75a6eb
      Ding Xiang authored
      Since dx_make_map() may return -EFSCORRUPTED now, so change "count" to
      be a signed integer so we can correctly check for an error code returned
      by dx_make_map().
      
      Fixes: 46c116b9 ("ext4: verify dir block before splitting it")
      Cc: stable@kernel.org
      Signed-off-by: default avatarDing Xiang <dingxiang@cmss.chinamobile.com>
      Link: https://lore.kernel.org/r/20220530100047.537598-1-dingxiang@cmss.chinamobile.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      bc75a6eb
    • Baokun Li's avatar
      ext4: correct the judgment of BUG in ext4_mb_normalize_request · cf4ff938
      Baokun Li authored
      ext4_mb_normalize_request() can move logical start of allocated blocks
      to reduce fragmentation and better utilize preallocation. However logical
      block requested as a start of allocation (ac->ac_o_ex.fe_logical) should
      always be covered by allocated blocks so we should check that by
      modifying and to or in the assertion.
      Signed-off-by: default avatarBaokun Li <libaokun1@huawei.com>
      Reviewed-by: default avatarRitesh Harjani <ritesh.list@gmail.com>
      Link: https://lore.kernel.org/r/20220528110017.354175-3-libaokun1@huawei.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      cf4ff938
    • Baokun Li's avatar
      ext4: fix bug_on ext4_mb_use_inode_pa · a08f789d
      Baokun Li authored
      Hulk Robot reported a BUG_ON:
      ==================================================================
      kernel BUG at fs/ext4/mballoc.c:3211!
      [...]
      RIP: 0010:ext4_mb_mark_diskspace_used.cold+0x85/0x136f
      [...]
      Call Trace:
       ext4_mb_new_blocks+0x9df/0x5d30
       ext4_ext_map_blocks+0x1803/0x4d80
       ext4_map_blocks+0x3a4/0x1a10
       ext4_writepages+0x126d/0x2c30
       do_writepages+0x7f/0x1b0
       __filemap_fdatawrite_range+0x285/0x3b0
       file_write_and_wait_range+0xb1/0x140
       ext4_sync_file+0x1aa/0xca0
       vfs_fsync_range+0xfb/0x260
       do_fsync+0x48/0xa0
      [...]
      ==================================================================
      
      Above issue may happen as follows:
      -------------------------------------
      do_fsync
       vfs_fsync_range
        ext4_sync_file
         file_write_and_wait_range
          __filemap_fdatawrite_range
           do_writepages
            ext4_writepages
             mpage_map_and_submit_extent
              mpage_map_one_extent
               ext4_map_blocks
                ext4_mb_new_blocks
                 ext4_mb_normalize_request
                  >>> start + size <= ac->ac_o_ex.fe_logical
                 ext4_mb_regular_allocator
                  ext4_mb_simple_scan_group
                   ext4_mb_use_best_found
                    ext4_mb_new_preallocation
                     ext4_mb_new_inode_pa
                      ext4_mb_use_inode_pa
                       >>> set ac->ac_b_ex.fe_len <= 0
                 ext4_mb_mark_diskspace_used
                  >>> BUG_ON(ac->ac_b_ex.fe_len <= 0);
      
      we can easily reproduce this problem with the following commands:
      	`fallocate -l100M disk`
      	`mkfs.ext4 -b 1024 -g 256 disk`
      	`mount disk /mnt`
      	`fsstress -d /mnt -l 0 -n 1000 -p 1`
      
      The size must be smaller than or equal to EXT4_BLOCKS_PER_GROUP.
      Therefore, "start + size <= ac->ac_o_ex.fe_logical" may occur
      when the size is truncated. So start should be the start position of
      the group where ac_o_ex.fe_logical is located after alignment.
      In addition, when the value of fe_logical or EXT4_BLOCKS_PER_GROUP
      is very large, the value calculated by start_off is more accurate.
      
      Cc: stable@kernel.org
      Fixes: cd648b8a ("ext4: trim allocation requests to group size")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarBaokun Li <libaokun1@huawei.com>
      Reviewed-by: default avatarRitesh Harjani <ritesh.list@gmail.com>
      Link: https://lore.kernel.org/r/20220528110017.354175-2-libaokun1@huawei.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      a08f789d
    • Eric Biggers's avatar
      ext4: fix up test_dummy_encryption handling for new mount API · 85456054
      Eric Biggers authored
      Since ext4 was converted to the new mount API, the test_dummy_encryption
      mount option isn't being handled entirely correctly, because the needed
      fscrypt_set_test_dummy_encryption() helper function combines
      parsing/checking/applying into one function.  That doesn't work well
      with the new mount API, which split these into separate steps.
      
      This was sort of okay anyway, due to the parsing logic that was copied
      from fscrypt_set_test_dummy_encryption() into ext4_parse_param(),
      combined with an additional check in ext4_check_test_dummy_encryption().
      However, these overlooked the case of changing the value of
      test_dummy_encryption on remount, which isn't allowed but ext4 wasn't
      detecting until ext4_apply_options() when it's too late to fail.
      Another bug is that if test_dummy_encryption was specified multiple
      times with an argument, memory was leaked.
      
      Fix this up properly by using the new helper functions that allow
      splitting up the parse/check/apply steps for test_dummy_encryption.
      
      Fixes: cebe85d5 ("ext4: switch to the new mount api")
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Link: https://lore.kernel.org/r/20220526040412.173025-1-ebiggers@kernel.orgSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      85456054