linux: btrfs: fix NULL pointer dereference when deleting device by invalid id
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
linux-azure (Ubuntu) |
Invalid
|
Undecided
|
Unassigned | ||
Focal |
In Progress
|
Medium
|
Tim Gardner | ||
linux-azure-5.8 (Ubuntu) |
Invalid
|
Undecided
|
Unassigned | ||
Focal |
Fix Released
|
Medium
|
Tim Gardner | ||
linux-hwe-5.8 (Ubuntu) |
Invalid
|
Undecided
|
Unassigned | ||
Focal |
Fix Committed
|
Medium
|
Tim Gardner |
Bug Description
[BUG]
It's easy to trigger NULL pointer dereference, just by removing a
non-existing device id:
# mkfs.btrfs -f -m single -d single /dev/test/scratch1 \
# mount /dev/test/scratch1 /mnt/btrfs
# btrfs device remove 3 /mnt/btrfs
Then we have the following kernel NULL pointer dereference:
BUG: kernel NULL pointer dereference, address: 0000000000000000
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 0 P4D 0
Oops: 0000 [#1] PREEMPT SMP NOPTI
CPU: 9 PID: 649 Comm: btrfs Not tainted 5.14.0-rc3-custom+ #35
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015
RIP: 0010:btrfs_
btrfs_
? lock_is_
? find_held_
? do_user_
? lock_release+
? __x64_sys_
__x64_
do_syscall_
entry_
[CAUSE]
Commit a27a94c2b0c7 ("btrfs: Make btrfs_find_
btrfs_device directly") moves the "missing" device path check into
btrfs_rm_device().
But btrfs_rm_device() itself can have case where it only receives
@devid, with NULL as @device_path.
In that case, calling strcmp() on NULL will trigger the NULL pointer
dereference.
Before that commit, we handle the "missing" case inside
btrfs_find_
if @devid is provided, thus no way to trigger the bug.
[FIX]
Before calling strcmp(), also make sure @device_path is not NULL.
CVE References
Changed in linux-hwe-5.8 (Ubuntu Focal): | |
status: | New → In Progress |
assignee: | nobody → Tim Gardner (timg-tpi) |
importance: | Undecided → Medium |
Changed in linux-hwe-5.8 (Ubuntu): | |
status: | New → Invalid |
Changed in linux-azure-5.8 (Ubuntu Focal): | |
status: | New → In Progress |
importance: | Undecided → Medium |
assignee: | nobody → Tim Gardner (timg-tpi) |
Changed in linux-azure-5.8 (Ubuntu): | |
status: | New → Invalid |
Changed in linux-azure (Ubuntu Focal): | |
status: | New → In Progress |
importance: | Undecided → Medium |
assignee: | nobody → Tim Gardner (timg-tpi) |
Changed in linux-azure (Ubuntu): | |
status: | New → Invalid |
Changed in linux-hwe-5.8 (Ubuntu Focal): | |
status: | In Progress → Fix Committed |
tags: |
added: verification-done-focal removed: verification-needed-focal |
This bug is awaiting verification that the linux-hwe- 5.8/5.8. 0-66.74 kernel in -proposed solves the problem. Please test the kernel and update this bug with the results. If the problem is solved, change the tag 'verification- needed- focal' to 'verification- done-focal' . If the problem still exists, change the tag 'verification- needed- focal' to 'verification- failed- focal'.
If verification is not done by 5 working days from today, this fix will be dropped from the source code, and this bug will be closed.
See https:/ /wiki.ubuntu. com/Testing/ EnableProposed for documentation how to enable and use -proposed. Thank you!