From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A8884657F4; Tue, 16 Jun 2026 16:01:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781625687; cv=none; b=ouFQzdxCupJTlXP548hmBOV8PgIpcgGa7bdU8JQy0HHC8iO7KaUL/MmW5VxVCKSxsKwHXm7hfwGgbtFISQfZTMsaZM9rwz57ASXy+JT363/yGMjGEv/d6RsDqrt8pYX7xc4pgGJh+RsDEt3FzEBSiU+TK81JDrEqgFp0g+gocAA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781625687; c=relaxed/simple; bh=yWZQ9Zzvo4ze2rISTioBZItG+1BMSu0fz+9GzwD273k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ecLN4R28ZSYc1pO83RlsxJDMnkUqeK+AkI6qvXs6vKMu4j5yMJUAXVV2H95PqLEEwU1nbD4sNEGo96I7huO8ZbRsI6RNEZVGi9loSGr3NdDmQw3pgEzU1gHD/LPtC7FwOPe54G3+i1VnwJI0suVs3Ia5Y0XM2+V7Ktkb9agE1MI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Upx2vcUq; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Upx2vcUq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53FA31F000E9; Tue, 16 Jun 2026 16:01:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781625686; bh=fNGw/nexpVTFo8Drau6MTQMqO8io0EDU6KQ9hhF9TqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Upx2vcUqrQ9Iig5IxC43Tia49BjZ9wOgvo4NRSmzogRHCD+v9HJlWAD1xWM90ECdr 6kUtoEwJl8IYYmbxlJDB6LHrwmDA20XtXS7YSAPiBLp8kyM2yuq66l5+fNq1yAYUlb W+f1CQ7Ny9sdhtp+3oNdlU53dW50pFfCVHzWOFg0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christoph Hellwig , Sergey Senozhatsky , Cunlong Li , Jens Axboe , Minchan Kim , Yisheng Xie , Andrew Morton Subject: [PATCH 6.18 189/325] zram: fix use-after-free in zram_bvec_write_partial() Date: Tue, 16 Jun 2026 20:29:45 +0530 Message-ID: <20260616145107.323521970@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145057.827196531@linuxfoundation.org> References: <20260616145057.827196531@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cunlong Li commit 732fd9f0b9c1cdc6dfd77162ded60df005182cc0 upstream. zram_read_page() picks the sync or async backing device read path based on whether the parent bio is NULL. zram_bvec_write_partial() passes its parent bio down, so for ZRAM_WB slots the read is dispatched asynchronously and zram_read_page() returns 0 while the bio is still in flight. The caller then runs memcpy_from_bvec(), zram_write_page() and __free_page() on the buffer, leaving the async read to write into a freed page. zram_bvec_read_partial() was switched to NULL in commit 4e3c87b9421d ("zram: fix synchronous reads") for the same reason; the write_partial counterpart was missed. Link: https://lore.kernel.org/20260528-zram-v3-1-cab86eef8764@gmail.com Fixes: 8e654f8fbff5 ("zram: read page from backing device") Reviewed-by: Christoph Hellwig Reviewed-by: Sergey Senozhatsky Signed-off-by: Cunlong Li Cc: Jens Axboe Cc: Minchan Kim Cc: Yisheng Xie Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/block/zram/zram_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1915,7 +1915,7 @@ static int zram_bvec_write_partial(struc if (!page) return -ENOMEM; - ret = zram_read_page(zram, page, index, bio); + ret = zram_read_page(zram, page, index, NULL); if (!ret) { memcpy_from_bvec(page_address(page) + offset, bvec); ret = zram_write_page(zram, page, index);