-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
quota: Check next/prev free block number after reading from quota file
Following process: Init: v2_read_file_info: <3> dqi_free_blk 0 dqi_free_entry 5 dqi_blks 6 Step 1. chown bin f_a -> dquot_acquire -> v2_write_dquot: qtree_write_dquot do_insert_tree find_free_dqentry get_free_dqblk write_blk(info->dqi_blocks) // info->dqi_blocks = 6, failure. The content in physical block (corresponding to blk 6) is random. Step 2. chown root f_a -> dquot_transfer -> dqput_all -> dqput -> ext4_release_dquot -> v2_release_dquot -> qtree_delete_dquot: dquot_release remove_tree free_dqentry put_free_dqblk(6) info->dqi_free_blk = blk // info->dqi_free_blk = 6 Step 3. drop cache (buffer head for block 6 is released) Step 4. chown bin f_b -> dquot_acquire -> commit_dqblk -> v2_write_dquot: qtree_write_dquot do_insert_tree find_free_dqentry get_free_dqblk dh = (struct qt_disk_dqdbheader *)buf blk = info->dqi_free_blk // 6 ret = read_blk(info, blk, buf) // The content of buf is random info->dqi_free_blk = le32_to_cpu(dh->dqdh_next_free) // random blk Step 5. chown bin f_c -> notify_change -> ext4_setattr -> dquot_transfer: dquot = dqget -> acquire_dquot -> ext4_acquire_dquot -> dquot_acquire -> commit_dqblk -> v2_write_dquot -> dq_insert_tree: do_insert_tree find_free_dqentry get_free_dqblk blk = info->dqi_free_blk // If blk < 0 and blk is not an error code, it will be returned as dquot transfer_to[USRQUOTA] = dquot // A random negative value __dquot_transfer(transfer_to) dquot_add_inodes(transfer_to[cnt]) spin_lock(&dquot->dq_dqb_lock) // page fault , which will lead to kernel page fault: Quota error (device sda): qtree_write_dquot: Error -8000 occurred while creating quota BUG: unable to handle page fault for address: ffffffffffffe120 #PF: supervisor write access in kernel mode #PF: error_code(0x0002) - not-present page Oops: 0002 [#1] PREEMPT SMP CPU: 0 PID: 5974 Comm: chown Not tainted 6.0.0-rc1-00004 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996) RIP: 0010:_raw_spin_lock+0x3a/0x90 Call Trace: dquot_add_inodes+0x28/0x270 __dquot_transfer+0x377/0x840 dquot_transfer+0xde/0x540 ext4_setattr+0x405/0x14d0 notify_change+0x68e/0x9f0 chown_common+0x300/0x430 __x64_sys_fchownat+0x29/0x40 In order to avoid accessing invalid quota memory address, this patch adds block number checking of next/prev free block read from quota file. Fetch a reproducer in [Link]. Link: https://bugzilla.kernel.org/show_bug.cgi?id=216372 Fixes: 1da177e ("Linux-2.6.12-rc2") CC: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220923134555.2623931-2-chengzhihao1@huawei.com Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Jan Kara <jack@suse.cz>
- x86_vdso_for_v6.3_rc1
- x86_urgent_for_6.4-rc4
- x86_urgent_for_v6.4_rc6
- x86_urgent_for_v6.4_rc2
- x86_urgent_for_v6.3
- x86_urgent_for_v6.3_rc7
- x86_urgent_for_v6.3_rc6
- x86_urgent_for_v6.3_rc4
- x86_urgent_for_v6.3_rc3
- x86_urgent_for_v6.3_rc2
- x86_urgent_for_v6.2_rc7
- x86_urgent_for_v6.2_rc6
- x86_urgent_for_v6.2_rc4
- x86_urgent_for_v6.2_rc2
- x86_urgent_for_v6.1_rc7
- x86_urgent_for_v6.1_rc6
- x86_urgent_for_v6.1_rc4
- x86_urgent_for_v6.0_rc2
- x86_tdx_for_6.4
- x86_tdx_for_6.3
- x86_tdx_for_6.2
- x86_splitlock_for_6.2
- x86_shstk_for_6.4
- x86_sgx_for_6.2
- x86_sev_for_v6.4_rc1
- x86_sev_for_v6.2
- x86_paravirt_for_v6.4_rc1
- x86_paravirt_for_v6.2
- x86_mm_for_6.4
- x86_mm_for_6.2_v2
- x86_misc_for_v6.4_rc1
- x86_microcode_for_v6.3_rc1
- x86_microcode_for_v6.2
- x86_fpu_for_6.4
- x86_fpu_for_6.2
- x86_cpu_for_v6.4_rc1
- x86_cpu_for_v6.3_rc1
- x86_cpu_for_v6.2
- x86_core_for_v6.2
- x86_cleanups_for_v6.4_rc1
- x86_cache_for_6.4
- x86_cache_for_6.2
- x86_cache_for_v6.3_rc1
- x86_boot_for_v6.2
- x86_asm_for_v6.2
- x86_alternatives_for_v6.3_rc1
- x86_alternatives_for_v6.2
- x86_acpi_for_v6.4_rc1
- x86-urgent-2023-05-28
- x86-urgent-2023-03-05
- x86-urgent-2023-02-19
- x86-urgent-2023-02-11
- x86-urgent-2023-01-04
- x86-urgent-2022-12-12
- x86-platform-2023-02-20
- x86-mm-2023-02-20
- x86-misc-2022-12-10
- x86-fpu-2023-02-20
- x86-core-2023-02-20
- x86-cleanups-2023-02-20
- x86-cleanups-2022-12-10
- x86-build-2023-02-20
- x86-boot-2023-02-20
- x86-asm-2023-02-20
- x86-apic-2023-04-24
- x86-apic-2022-12-10
- v6.9-rc4
- v6.9-rc3
- v6.9-rc2
- v6.9-rc1
- v6.8.6
- v6.8.5
- v6.8.4
- v6.8.3
- v6.8.2
- v6.8.1
- v6.8
- v6.8-rc7
- v6.8-rc6
- v6.8-rc5
- v6.8-rc4
- v6.8-rc3
- v6.8-rc2
- v6.8-rc1
- v6.7.12
- v6.7.11
- v6.7.10
- v6.7.9
- v6.7.8
- v6.7.7
- v6.7.6
- v6.7.5
- v6.7.4
- v6.7.3
- v6.7.2
- v6.7.1
- v6.7
- v6.7-rc8
- v6.7-rc7
- v6.7-rc6
- v6.7-rc5
- v6.7-rc4
- v6.7-rc3
- v6.7-rc2
- v6.7-rc1
- v6.6.27
- v6.6.26
- v6.6.25
- v6.6.24
- v6.6.23
- v6.6.22
- v6.6.21
- v6.6.20
- v6.6.19
- v6.6.18
- v6.6.17
- v6.6.16
- v6.6.15
- v6.6.14
- v6.6.13
- v6.6.12
- v6.6.11
- v6.6.10
- v6.6.9
- v6.6.8
- v6.6.7
- v6.6.6
- v6.6.5
- v6.6.4
- v6.6.3
- v6.6.2
- v6.6.1
- v6.6
- v6.6-rc7
- v6.6-rc6
- v6.6-rc5
- v6.6-rc4
- v6.6-rc3
- v6.6-rc2
- v6.6-rc1
- v6.5.13
- v6.5.12
- v6.5.11
- v6.5.10
- v6.5.9
- v6.5.8
- v6.5.7
- v6.5.6
- v6.5.5
- v6.5.4
- v6.5.3
- v6.5.2
- v6.5.1
- v6.5
- v6.5-rc7
- v6.5-rc6
- v6.5-rc5
- v6.5-rc4
- v6.5-rc3
- v6.5-rc2
- v6.5-rc1
- v6.4.16
- v6.4.15
- v6.4.14
- v6.4.13
- v6.4.12
- v6.4.11
- v6.4.10
- v6.4.9
- v6.4.8
- v6.4.7
- v6.4.6
- v6.4.5
- v6.4.4
- v6.4.3
- v6.4.2
- v6.4.1
- v6.4
- v6.4-rc7
- v6.4-rc6
- v6.4-rc5
- v6.4-rc4
- v6.4-rc3
- v6.4-rc2
- v6.4-rc1
- v6.3.13
- v6.3.12
- v6.3.11
- v6.3.10
- v6.3.9
- v6.3.8
- v6.3.7
- v6.3.6
- v6.3.5
- v6.3.4
- v6.3.3
- v6.3.2
- v6.3.1
- v6.3
- v6.3-rc7
- v6.3-rc6
- v6.3-rc5
- v6.3-rc4
- v6.3-rc3
- v6.3-rc2
- v6.3-rc1
- v6.2.16
- v6.2.15
- v6.2.14
- v6.2.13
- v6.2.12
- v6.2.11
- v6.2.10
- v6.2.9
- v6.2.8
- v6.2.7
- v6.2.6
- v6.2.5
- v6.2.4
- v6.2.3
- v6.2.2
- v6.2.1
- v6.2
- v6.2-rc8
- v6.2-rc7
- v6.2-rc6
- v6.2-rc5
- v6.2-rc4
- v6.2-rc3
- v6.2-rc2
- v6.2-rc1
- v6.1.86
- v6.1.85
- v6.1.84
- v6.1.83
- v6.1.82
- v6.1.81
- v6.1.80
- v6.1.79
- v6.1.78
- v6.1.77
- v6.1.76
- v6.1.75
- v6.1.74
- v6.1.73
- v6.1.72
- v6.1.71
- v6.1.70
- v6.1.69
- v6.1.68
- v6.1.67
- v6.1.66
- v6.1.65
- v6.1.64
- v6.1.63
- v6.1.62
- v6.1.61
- v6.1.60
- v6.1.59
- v6.1.58
- v6.1.57
- v6.1.56
- v6.1.55
- v6.1.54
- v6.1.53
- v6.1.52
- v6.1.51
- v6.1.50
- v6.1.49
- v6.1.48
- v6.1.47
- v6.1.46
- v6.1.45
- v6.1.44
- v6.1.43
- v6.1.42
- v6.1.41
- v6.1.40
- v6.1.39
- v6.1.38
- v6.1.37
- v6.1.36
- v6.1.35
- v6.1.34
- v6.1.33
- v6.1.32
- v6.1.31
- v6.1.30
- v6.1.29
- v6.1.28
- v6.1.27
- v6.1.26
- v6.1.25
- v6.1.24
- v6.1.23
- v6.1.22
- v6.1.21
- v6.1.20
- v6.1.19
- v6.1.18
- v6.1.17
- v6.1.16
- v6.1.15
- v6.1.14
- v6.1.13
- v6.1.12
- v6.1.11
- v6.1.10
- v6.1.9
- v6.1.8
- v6.1.7
- v6.1.6
- v6.1.5
- v6.1.4
- v6.1.3
- v6.1.2
- v6.1.1
- v6.1
- v6.1-rc8
- v6.1-rc7
- v6.1-rc6
- v6.1-rc5
- v6.1-rc4
- v6.1-rc3
- v6.1-rc2
- v6.1-rc1
- unmap-fix-20230629
- timers-urgent-2023-02-19
- timers-urgent-2023-01-12
- timers-core-2023-04-28
- timers-core-2023-04-24
- timers-core-2023-02-20
- timers-core-2022-12-10
- timers_urgent_for_v6.4_rc2
- timers_urgent_for_v6.1_rc8
- timers_urgent_for_v6.1_rc7
- thermal-6.6-rc1
- thermal-6.6-rc1-3
- thermal-6.6-rc1-2
- thermal-6.5-rc4
- thermal-6.5-rc1
- thermal-6.4-rc8
- thermal-6.4-rc4
- thermal-6.4-rc1
- thermal-6.4-rc1-3
- thermal-6.4-rc1-2
- thermal-6.3-rc7
- thermal-6.3-rc5
- thermal-6.3-rc4
- thermal-6.3-rc2
- thermal-6.3-rc1
- thermal-6.3-rc1-2
- thermal-6.2-rc6
- thermal-6.2-rc5
- thermal-6.2-rc3
- thermal-6.2-rc1
- thermal-6.2-rc1-2
- thermal-6.1-rc2
- tags/kvm-6.2-2
- tags/kvm-6.2-1
- smp-core-2023-04-27
- smp-core-2022-12-10
- sched-urgent-2023-02-17
- sched-urgent-2023-01-12
- sched-core-2023-04-27
- sched-core-2023-02-20
- sched-core-2022-12-12
- sched_urgent_for_v6.4_rc2
- sched_urgent_for_v6.3_rc7
- sched_urgent_for_v6.3_rc4
- sched_urgent_for_v6.2_rc6
- sched_urgent_for_v6.1_rc6
- sched_urgent_for_v6.1_rc2
- ras_urgent_for_v6.3_rc3
- ras_core_for_v6.4_rc1
- ras_core_for_v6.3_rc1
- ras_core_for_v6.2
- pm-6.6-rc1
- pm-6.6-rc1-3
- pm-6.6-rc1-2
- pm-6.5-rc6
- pm-6.5-rc5
- pm-6.5-rc4
- pm-6.5-rc3
- pm-6.5-rc2
- pm-6.5-rc1
- pm-6.5-rc1-2
- pm-6.4-rc4
- pm-6.4-rc3
- pm-6.4-rc1
- pm-6.4-rc1-2
- pm-6.3-rc7
- pm-6.3-rc3
- pm-6.3-rc1
- pm-6.3-rc1-2
- pm-6.2-rc9
- pm-6.2-rc8
- pm-6.2-rc4
- pm-6.2-rc1
- pm-6.1-rc7
- pm-6.1-rc3
- pm-6.1-rc2
- perf-urgent-2023-05-28
- perf-urgent-2023-01-12
- perf-urgent-2023-01-06
- perf-core-2023-04-27
- perf-core-2023-02-20
- perf-core-2022-12-12
- perf_urgent_for_v6.4_rc2
- perf_urgent_for_v6.3_rc6
- perf_urgent_for_v6.3_rc4
- perf_urgent_for_v6.3_rc3
- perf_urgent_for_v6.2_rc7
- perf_urgent_for_v6.2_rc6
- perf_urgent_for_v6.2_rc4
- perf_urgent_for_v6.2_rc2
- perf_urgent_for_v6.1_rc8
- perf_urgent_for_v6.1_rc7
- perf_urgent_for_v6.1_rc6
- perf_urgent_for_v6.1_rc4
- perf_urgent_for_v6.1_rc3
- perf_urgent_for_v6.1_rc2
- objtool-urgent-2023-05-28
- objtool-core-2023-04-27
- objtool-core-2023-03-02
- objtool_urgent_for_v6.1_rc7
- objtool_urgent_for_v6.1_rc2
- next-20230912
- next-20230809
- next-20230803
- next-20230801
- next-20230724
- next-20230721
- next-20230718
- next-20230717
- next-20230714
- next-20230706
- next-20230620
- next-20230608
- next-20230512
- next-20230511
- next-20230508
- next-20230504
- next-20230426
- next-20230419
- next-20230411
- next-20230405
- next-20230324
- next-20230320
- next-20230302
- next-20230228
- next-20230217
- next-20230208
- next-20230206
- next-20230203
- next-20230123
- next-20230105
- next-20221226
- next-20221220
- next-20221202
- next-20221129
- next-20221014
- next-20221013
- md-next-20230825
- md-next-20230817
- md-next-20230814-resend
- md-next-20230729
- md-next-20230623
- md-next-20230613
- md-next-2023-04-28
- md-fixes-20230630
- md-fixes-2023-05-24
- md-fixes-2023-03-29
- mariux-6.12.40-484
- mariux-6.12.29-483
- mariux-6.12.27-482
- mariux-6.12.23-481
- mariux-6.12.23-480
- mariux-6.12.11-479
- mariux-6.6.35-477
- mariux-6.6.27-472
- mariux-6.6.26-471
- mariux-6.6.25-470
- mariux-6.6.24-469
- mariux-6.6.23-468
- mariux-6.6.22-467
- mariux-6.6.22-466
- mariux-6.6.22-465
- mariux-6.6.21-464
- mariux-6.6.20-463
- mariux-6.6.19-462
- mariux-6.6.12-461
- mariux-6.6.11-460
- mariux-6.5.2-455
- mariux-6.5.2-452
- mariux-6.5.2-451
- mariux-6.1.53-458
- mariux-6.1.52-456
- mariux-6.1.39-450
- mariux-6.1.7-446
- locking-urgent-2023-02-11
- locking-core-2023-05-05
- locking-core-2023-02-20
- locking-core-2022-12-12
- locking_urgent_for_v6.4_rc2
- locking_urgent_for_v6.2_rc2
- locking_urgent_for_v6.1_rc6
- irq-urgent-2023-05-28
- irq-urgent-2023-03-05
- irq-urgent-2023-02-19
- irq-core-2023-04-24
- irq-core-2023-02-20
- irq-core-2022-12-10
- irq_urgent_for_v6.4_rc5
- irq_urgent_for_v6.3
- irq_urgent_for_v6.2_rc6
- hwmon-for-v6.3
- hwmon-for-v6.3-rc4
- hwmon-for-v6.3-rc3
- hwmon-for-v6.2
- hwmon-for-v6.2-rc1
- hwmon-for-v6.1-rc8
- hwmon-for-v6.1-rc4
- hwmon-for-v6.1-rc2
- core-urgent-2023-01-12
- core-entry-2023-04-24
- core-debugobjects-2023-05-28
- core-debugobjects-2023-05-06
- core-debugobjects-2023-04-24
- core-debugobjects-2022-12-10
- core_urgent_for_v6.3_rc4
- core_urgent_for_v6.2_rc4
- ata-6.6-rc1
- ata-6.5-rc5
- ata-6.5-rc4
- ata-6.5-rc3
- ata-6.5-rc1
- ata-6.4-rc7
- ata-6.4-rc5
- ata-6.4-rc3
- ata-6.4-rc1
- ata-6.3-rc7
- ata-6.3-rc3
- ata-6.3-rc1
- ata-6.3-fix
- ata-6.2-rc8
- ata-6.2-rc7
- ata-6.2-rc4
- ata-6.2-rc2
- ata-6.2-rc1
- ata-6.1-rc8
- ata-6.1-rc5
- ata-6.1-rc4
- ata-6.1-rc2
- amd-drm-next-6.4-2023-03-31
- amd-drm-next-6.4-2023-03-17
- amd-drm-next-6.3-2023-02-17
- amd-drm-next-6.3-2023-02-03
- amd-drm-next-6.3-2023-01-27
- amd-drm-next-6.3-2023-01-20
- amd-drm-next-6.3-2023-01-13
- amd-drm-next-6.3-2023-01-06
- amd-drm-next-6.2-2022-12-07
- amd-drm-next-6.2-2022-12-02
- amd-drm-next-6.2-2022-11-25
- amd-drm-next-6.2-2022-11-18
- amd-drm-next-6.2-2022-11-11
- amd-drm-next-6.2-2022-11-04
- amd-drm-fixes-6.3-2023-03-30
- amd-drm-fixes-6.3-2023-03-29
- amd-drm-fixes-6.3-2023-03-23
- amd-drm-fixes-6.3-2023-03-15
- amd-drm-fixes-6.3-2023-03-09
- amd-drm-fixes-6.3-2023-03-02
- amd-drm-fixes-6.2-2023-02-15
- amd-drm-fixes-6.2-2023-02-09
- amd-drm-fixes-6.2-2023-02-08
- amd-drm-fixes-6.2-2023-02-01
- amd-drm-fixes-6.2-2023-01-25
- amd-drm-fixes-6.2-2023-01-19
- amd-drm-fixes-6.2-2023-01-11
- amd-drm-fixes-6.2-2023-01-04
- amd-drm-fixes-6.2-2022-12-21
- amd-drm-fixes-6.2-2022-12-15
- amd-drm-fixes-6.1-2022-12-07
- amd-drm-fixes-6.1-2022-12-01
- amd-drm-fixes-6.1-2022-11-23
- amd-drm-fixes-6.1-2022-11-16
- amd-drm-fixes-6.1-2022-11-09
- amd-drm-fixes-6.1-2022-11-02
- amd-drm-fixes-6.1-2022-10-26-1
- amd-drm-fixes-6.1-2022-10-20
- amd-drm-fixes-6.1-2022-10-19
- acpi-6.6-rc1
- acpi-6.5-rc8
- acpi-6.5-rc6
- acpi-6.5-rc1
- acpi-6.5-rc1-3
- acpi-6.5-rc1-2
- acpi-6.4-rc8
- acpi-6.4-rc3
- acpi-6.4-rc1
- acpi-6.4-rc1-3
- acpi-6.4-rc1-2
- acpi-6.3-rc7
- acpi-6.3-rc6
- acpi-6.3-rc5
- acpi-6.3-rc4
- acpi-6.3-rc3
- acpi-6.3-rc1
- acpi-6.3-rc1-2
- acpi-6.2-rc6
- acpi-6.2-rc5
- acpi-6.2-rc4
- acpi-6.2-rc2
- acpi-6.2-rc1
- acpi-6.2-rc1-2
- acpi-6.1-rc4
- acpi-6.1-rc3
- acpi-6.1-rc2
- Ubuntu-unstable-6.5.0-4.4
- Ubuntu-unstable-6.5.0-2.2
- Ubuntu-unstable-6.5.0-1.1
- Ubuntu-unstable-6.4.0-8.8
- Ubuntu-unstable-6.4.0-5.5
- Ubuntu-unstable-6.3.0-2.2
- Ubuntu-unstable-6.3.0-1.1
- Ubuntu-unstable-6.1.0-9.9
- Ubuntu-lowlatency-6.2.0-1014.14
- Ubuntu-lowlatency-6.2.0-1010.10
- Ubuntu-lowlatency-6.2.0-1009.9
- Ubuntu-lowlatency-6.2.0-1008.8
- Ubuntu-lowlatency-6.2.0-1005.5
- Ubuntu-lowlatency-6.2.0-1004.4
- Ubuntu-lowlatency-6.2.0-1003.3
- Ubuntu-lowlatency-6.2.0-1002.2
- Ubuntu-lowlatency-6.2.0-1001.1
- Ubuntu-lowlatency-6.1.0-1001.1
- Ubuntu-6.2.0-34.34
- Ubuntu-6.2.0-32.32
- Ubuntu-6.2.0-30.30
- Ubuntu-6.2.0-27.28
- Ubuntu-6.2.0-26.26
- Ubuntu-6.2.0-25.25
- Ubuntu-6.2.0-23.23
- Ubuntu-6.2.0-21.21
- Ubuntu-6.2.0-20.20
- Ubuntu-6.2.0-19.19
- Ubuntu-6.2.0-18.18
- Ubuntu-6.2.0-17.17
- Ubuntu-6.1.0-16.16
- Ubuntu-6.1.0-15.15
- Ubuntu-6.1.0-14.14
- Ubuntu-6.1.0-13.13
- Ubuntu-6.1.0-12.12
Zhihao Cheng
authored and
Jan Kara
committed
Sep 29, 2022
1 parent
e7c7fbb
commit 6c8ea8b
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters