In the Linux kernel, the following vulnerability has been resolved:
md/raid1: Fix stack memory use after return in raid1_reshape
In the raid1reshape function, newpool is allocated on the stack and assigned to conf->r1biopool. This results in conf->r1bio_pool.wait.head pointing to a stack address. Accessing this address later can lead to a kernel panic.
Example access path:
raid1reshape() { // newpool is on the stack mempoolt newpool, oldpool; // initialize newpool.wait.head to stack address mempoolinit(&newpool, ...); conf->r1biopool = newpool; }
raid1readrequest() or raid1writerequest() { allocr1bio() { mempoolalloc() { // if pool->alloc fails removeelement() { --pool->currnr; } } } }
mempoolfree() { if (pool->currnr < pool->minnr) { // pool->wait.head is a stack address // wakeup() will try to access this invalid address // which leads to a kernel panic return; wake_up(&pool->wait); } }
Fix: reinit conf->r1bio_pool.wait after assigning newpool.