Repository navigation
btrfs: fix integer overflow in bd_btrfs_create_volume argument counter - #1218
Conversation
bd_btrfs_create_volume() used guint8 for both num_args and next_arg when constructing the mkfs.btrfs argv array. When the number of input devices combined with optional parameters (label, data_level, md_level) exceeded 255, the 8-bit counter wrapped around to a much smaller value, causing g_new0() to allocate a buffer far too small for the actual number of arguments. The subsequent argv population then wrote past the allocated boundary, corrupting heap metadata and potentially leading to arbitrary code execution. Fix it by widening num_args and next_arg from guint8 to guint, which provides a 32-bit range sufficient for any realistic argument count. Signed-off-by: Kou Wenqi <kouwenqi@kylinos.cn>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
Jenkins, ok to test. |
6cef17e
into
storaged-project:master
bd_btrfs_create_volume() used guint8 for both num_args and next_arg when constructing the mkfs.btrfs argv array. When the number of input devices combined with optional parameters (label, data_level, md_level) exceeded 255, the 8-bit counter wrapped around to a much smaller value, causing g_new0() to allocate a buffer far too small for the actual number of arguments. The subsequent argv population then wrote past the allocated boundary, corrupting heap metadata and potentially leading to arbitrary code execution.
Fix it by widening num_args and next_arg from guint8 to guint, which provides a 32-bit range sufficient for any realistic argument count.
Summary by CodeRabbit