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 78A8637CD28; Thu, 20 Aug 2026 15:17:00 +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=1787239021; cv=none; b=GRN45evv9oX0HkteRx9NN8RNLzpxgatdpUb5wD5q3TEvf9j0+ZrTRGzBvbyk3SkSYNtUfZ+b9lHXThYofV8t6XFlOKyrCYiCpcafA4UwCArGO1MAVWXws0I43Ne3JqVXfj70mMW6nNvFFU+zgLWLMFvw4IkT4oHlTLjseF6a7sk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787239021; c=relaxed/simple; bh=zD8IPANzlqC9zDgwH7Izp9PvUkw2aLUQP7BRHdT6lgg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pS8lZTxQDr3p4kTTyqC8xvLAmrZ5IN3RpT9AcRotBg7Qzl2dXmbazccQ8DIqyzknMLsemSjW8UWubQD4+rU5yIDsjTyeCTzikRrfnSl8qHGTEd6gwFStKcFmswLuilcYN+R7qCT6tF20PPx3K1ni8rntk9DBJtCX1c27QPU7LpA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NBrK5MFJ; 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="NBrK5MFJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1F091F000E9; Thu, 20 Aug 2026 15:16:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787239020; bh=ciqliur0PlwLFB2lJvNvKs5o2YM8V/crG+nghqyL75c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NBrK5MFJ7Ya3ZdqC2WKf98nLygCXd5ei1O9HxdDE5EafZGWS4nqzDo6EMEokMatDv taJP8by1Nf3g6tKPnohfiChwpPyHYTIhl7zluebZie2U9hljgEc9cy2Zx7oBwm5ObJ 7QNDlZTkojgFm2zvWFFzzjZpoqILnfiOFrn0jKSU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Matthew Rosato , Eric Farman , Christian Borntraeger Subject: [PATCH 6.18 083/217] s390/vfio_ccw: Ensure first IDAW remains constant Date: Thu, 20 Aug 2026 16:54:11 +0200 Message-ID: <20260820145240.129061926@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145237.531699751@linuxfoundation.org> References: <20260820145237.531699751@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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Farman commit 565bef268d75bf7df665bce6923a88cd0eb74592 upstream. The first IDAW in a list does not need to be on a 2K/4K boundary like all others, and so is read separately to accurately calculate the size of the buffer needed to read the full IDAL. Verify that the address found in the first IDAW is unchanged between reads, to ensure a consistent set of IDAWs being worked with. Fixes: 01aa26c672c0 ("s390/cio: Combine direct and indirect CCW paths") Cc: stable@vger.kernel.org Reviewed-by: Matthew Rosato Signed-off-by: Eric Farman Signed-off-by: Christian Borntraeger Signed-off-by: Greg Kroah-Hartman --- drivers/s390/cio/vfio_ccw_cp.c | 16 ++++++++++++++++ drivers/s390/cio/vfio_ccw_cp.h | 2 ++ 2 files changed, 18 insertions(+) --- a/drivers/s390/cio/vfio_ccw_cp.c +++ b/drivers/s390/cio/vfio_ccw_cp.c @@ -530,6 +530,7 @@ static dma64_t *get_guest_idal(struct cc &container_of(cp, struct vfio_ccw_private, cp)->vdev; dma64_t *idaws; dma32_t *idaws_f1; + u64 first_idaw; int idal_len = idaw_nr * sizeof(*idaws); int idaw_size = idal_is_2k(cp) ? PAGE_SIZE / 2 : PAGE_SIZE; int idaw_mask = ~(idaw_size - 1); @@ -546,6 +547,18 @@ static dma64_t *get_guest_idal(struct cc kfree(idaws); return ERR_PTR(ret); } + + idaws_f1 = (dma32_t *)idaws; + if (cp->orb.cmd.c64) + first_idaw = dma64_to_u64(idaws[0]); + else + first_idaw = dma32_to_u32(idaws_f1[0]); + + /* Unexpected mismatch from earlier read */ + if (first_idaw != cp->guest_iova) { + kfree(idaws); + return ERR_PTR(-EINVAL); + } } else { /* Fabricate an IDAL based off CCW data address */ if (cp->orb.cmd.c64) { @@ -611,6 +624,9 @@ static int ccw_count_idaws(struct ccw1 * iova = dma32_to_u32(ccw->cda); } + /* Save the read address for later */ + cp->guest_iova = iova; + /* Format-1 IDAWs operate on 2K each */ if (!cp->orb.cmd.c64) return idal_2k_nr_words((void *)iova, bytes); --- a/drivers/s390/cio/vfio_ccw_cp.h +++ b/drivers/s390/cio/vfio_ccw_cp.h @@ -35,6 +35,7 @@ * @initialized: whether this instance is actually initialized * @guest_cp: copy of guest channel program * @ccwchain_count: number of channel program segments (linked by TIC) + * @guest_iova: first data address of a guest channel program * * @ccwchain_list is the head of a ccwchain list, that contents the * translated result of the guest channel program that pointed out by @@ -46,6 +47,7 @@ struct channel_program { bool initialized; struct ccw1 *guest_cp; unsigned int ccwchain_count; + u64 guest_iova; }; int cp_init(struct channel_program *cp, union orb *orb);