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 7C934362120; Sat, 12 Sep 2026 10:27:43 +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=1789208865; cv=none; b=rK90He21v76e6E00w2BoQ4j67LIdKtapRlZADOuuedkX9wz5wDR/wJ/WPSxaOnygJldjzrpT1fNZXuwkj253kyZNbDmwPReQCD1H1HMyUoWwS1PnM/S/MP8WVnBnIuOXzBK9o+5OIGEFP8m75mjMFh7pIa3Vgg7dF5svhLtlArc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789208865; c=relaxed/simple; bh=tjq/3ysm3e3O3x48BzCUUPYgs0KYa6WNTMKmDpIDMbM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NYgGxvNYwFAQJAKDzZfo9hTVXMcSBf5r0pEpjbjCgp/acH/TvyjelLULdhb1V6YWdXhepKS8WUUdQ4f6LoCYdCphlg79VsASfiPQ4PIiUfzWQeWY7A1NG/dh6UHTtOSUDdPI0XLk7rFyu2E2IiPCf+fRL+QVg4Z2yTXo5wgRcyg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NBvkn0Iw; 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="NBvkn0Iw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B214A1F00893; Sat, 12 Sep 2026 10:27:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789208862; bh=6hWsxynUZytqYRGiE+nVRIVjiK88Bu9mBxWnlrMZI5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NBvkn0IwU7R7JMGXYJP9fLoYrlxEJEUPeGBwUw7K4sgvS94VMrHHwrRs+a//LcJ0L L7MQh/RtbhczsEz919mRQLwz4SJTsDD1oW1jZKOgLEV48DPg+GLSo9NZdqUZgndVm8 XUqhfP/c+k2UmMrftkXkr8o+XWHIRs18eCB/9L9Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Stanislav Kinsburskii , Jason Gunthorpe , Leon Romanovsky , Ralph Campbell , Andrew Morton , Sasha Levin Subject: [PATCH 6.18 0705/1518] lib/test_hmm: fail dmirror_fault() when the mirrored mm is gone Date: Sat, 12 Sep 2026 08:47:54 +0200 Message-ID: <20260912065639.382375092@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065623.398859879@linuxfoundation.org> References: <20260912065623.398859879@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: Stanislav Kinsburskii [ Upstream commit 6a8024511ddf4877435c34fb3d6028aa8e590649 ] dmirror_fault() is called from the dmirror_read() and dmirror_write() retry loops after dmirror_do_read() or dmirror_do_write() finds a missing device page table entry. If the mirrored mm has already exited, mmget_not_zero() fails. The current code returns 0 in that case, which tells the caller that faulting succeeded even though no page was faulted and no device page table entry was installed. The caller then retries the same address, hits -ENOENT again, and can loop forever without making progress. Return -EFAULT instead, so the ioctl fails when the mirrored mm is no longer faultable. Link: https://lore.kernel.org/178294308408.327222.3319445682023999403.stgit@skinsburskii Fixes: b2ef9f5a5cb37 ("mm/hmm/test: add selftest driver for HMM") Signed-off-by: Stanislav Kinsburskii Cc: Jason Gunthorpe Cc: Leon Romanovsky Cc: Ralph Campbell Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin --- lib/test_hmm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/test_hmm.c b/lib/test_hmm.c index 00d34a6c6276b..ec1df4cd84807 100644 --- a/lib/test_hmm.c +++ b/lib/test_hmm.c @@ -392,7 +392,7 @@ static int dmirror_fault(struct dmirror *dmirror, unsigned long start, /* Since the mm is for the mirrored process, get a reference first. */ if (!mmget_not_zero(mm)) - return 0; + return -EFAULT; for (addr = start; addr < end; addr = range.end) { range.start = addr; -- 2.53.0