From 75c38bcf64e6960ab1a5a07d6b5c6946d8a751ca Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 17 Nov 2016 12:30:37 -0700 Subject: [PATCH] nbd: fix use-after-free of rq/bio in the xmit path commit 429a787be6793554ee02aacc7e1f11ebcecc4453 upstream. For writes, we can get a completion in while we're still iterating the request and bio chain. If that happens, we're reading freed memory and we can crash. Break out after the last segment and avoid having the iterator read freed memory. Reviewed-by: Josef Bacik Signed-off-by: Jens Axboe [bwh: Backported to 3.2: - bio_for_each_segment() uses iterator of type int - Open-code bio_iter_last() - Adjust context] Signed-off-by: Ben Hutchings --- Reading git-format-patch failed