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 9B98E3EAC82; Wed, 20 May 2026 18:38:10 +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=1779302291; cv=none; b=s8gnYLTzRURRrKkVTg8LFq8WqWPCsrq33fL3B6WibGFRKliWje4KVzQyWhzuz7/a5OinqTmR1CKsQ4+p3mYWW263v6HJnu/nxM8Dj6n1PHeHLSws8XVVbZ/vG4xlFb1+98K9zviFcavQL+ZyMTe5/Iuab/W0k//j1rZ8ttOu45k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779302291; c=relaxed/simple; bh=ppHzCBZgux5alLI5EpZejDkf1CoSZDH6QiORKTzXv9U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jvbRWlS0T5lENrAyuDUUEZI4ZyBUit8C48xorJtCECqDms+PrOy25U6w+Gf4RJ3osP4jHEoGEQasopMvkkYk8JAT7kpY4YNeXuxDMdpGMIlHfqInU+ikchs5VCAVWktcuSwjKGHhhtEsUwdXCxQD7GvX65aIHwZWEvHdMR3FQgI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=w8MPQl7x; 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="w8MPQl7x" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CC471F000E9; Wed, 20 May 2026 18:38:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779302290; bh=W6l3a6hnRRFWgbx6qU8z3//6XrojrW0p/TIkN5pDPqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=w8MPQl7x6SMJFcFpqye2MYrDo0BxM2sjPHkSFLyLw9/aV96HbQuzoRRy2bxmx72sI z8uceBB2mMlMgTLaa+GVXF1PmW+1PFICzFwWYG6tH9I/zzCge5+ByxvunWUCuZJV/5 6MHEe/zqCRGqnMi1ythk8w40sOCkDt0S4HK96tdM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Ming-Hung Tsai , Mikulas Patocka , Sasha Levin Subject: [PATCH 6.6 170/508] dm cache: fix missing return in invalidate_committeds error path Date: Wed, 20 May 2026 18:19:53 +0200 Message-ID: <20260520162102.321573518@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162058.573354582@linuxfoundation.org> References: <20260520162058.573354582@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ming-Hung Tsai [ Upstream commit 8c0ee19db81f0fa1ff25fd75b22b17c0cc2acde3 ] In passthrough mode, dm-cache defers write submission until after metadata commit completes via the invalidate_committed() continuation. On commit error, invalidate_committed() calls invalidate_complete() to end the bio and free the migration struct, after which it should return immediately. The patch 4ca8b8bd952d ("dm cache: fix write hang in passthrough mode") omitted this early return, causing execution to fall through into the success path on error. This results in use-after-free on the migration struct in the subsequent calls. Fix by adding the missing return after the invalidate_complete() call. Fixes: 4ca8b8bd952d ("dm cache: fix write hang in passthrough mode") Reported-by: Dan Carpenter Closes: https://lore.kernel.org/dm-devel/adjMq6T5RRjv_uxM@stanley.mountain/ Signed-off-by: Ming-Hung Tsai Signed-off-by: Mikulas Patocka Signed-off-by: Sasha Levin --- drivers/md/dm-cache-target.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c index 8db906ea3bef0..5522f8e9443f2 100644 --- a/drivers/md/dm-cache-target.c +++ b/drivers/md/dm-cache-target.c @@ -1523,8 +1523,10 @@ static void invalidate_committed(struct work_struct *ws) struct bio *bio = mg->overwrite_bio; struct per_bio_data *pb = get_per_bio_data(bio); - if (mg->k.input) + if (mg->k.input) { invalidate_complete(mg, false); + return; + } init_continuation(&mg->k, invalidate_completed); remap_to_origin_clear_discard(cache, bio, mg->invalidate_oblock); -- 2.53.0