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 1933A25B0AA; Thu, 20 Aug 2026 15:25:22 +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=1787239523; cv=none; b=Pb90g9VdlCzaGQwUoryUv+LoMgz2ySlx6+DHQQ4br7lsWFNXybPFOeqT5ERQ9xLEVLEM1q+YwUzCgHTSJRUug2nN7J32NKjZ5l79LfwGkmzXeFT5C99sY5ZPn2bc7IEbtKeJABPkzUy6or1kQ/G+OCrrcvUasLO2cxZIocqwXPc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787239523; c=relaxed/simple; bh=wAgqbKfnGiM8Xz3DbuDN10Qo5QhdAghUaWTKP3SSMFE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cH0d2cbbF37VzzlVzQLIpQF4VAuZGE901VBK9Bg0eoGpsTnkPtR6Ihjp+LfAgoHF59FLZ/OrcOki08FNVTu2JW47W3LdxiQDkSsnVXvn2KXibclPB/jnACjC9Mw09rzW89a6GwkgHkdfg/CMy0lw4kyH4mdjtnl05JWlTyVbMI8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=DxMc35IK; 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="DxMc35IK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72DB31F000E9; Thu, 20 Aug 2026 15:25:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787239522; bh=WijH4UlQRdW2S6X1bPZiAqucLGqbfM/8/gDGuRKfl2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DxMc35IKfwO5JOHrUeFLcwLBd7m4JZIvLGq1iqvOYGcWah61DtZI6GikcfUWeQs6P 7LN8sVOsrKMclg5qff+NDn+fJelCeR7W1ojjuM4vd9IKTvPdL3EvIiNlkLZTXP3Aae /DHBcbkmdV73iUxaHdaFizzi92k8GtpAO2YvBkyc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, sashiko-bot , Matthew Rosato , Eric Farman , Christian Borntraeger Subject: [PATCH 6.12 078/220] s390/vfio_ccw: Calculate idal length based on idaw type Date: Thu, 20 Aug 2026 16:54:28 +0200 Message-ID: <20260820145225.834232470@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145223.480031205@linuxfoundation.org> References: <20260820145223.480031205@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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Farman commit 4f6fdc6e1a7fbfa36b945af33c65a417948feac0 upstream. Sashiko pointed out that get_guest_idal() unconditionally calculates the length of the IDAL presuming everything is a Format-2 IDAW. The output of vfio-ccw is always Format-2, but the input can be either Format-1 (31-bit addresses) or Format-2 (64-bit addresses). As a result, the size of the guest IDAL may be incorrect and should be trimmed down. Reported-by: sashiko-bot Link: https://lore.kernel.org/r/20260720203400.7328E1F000E9@smtp.kernel.org/ Fixes: 1b676fe3d9d3 ("vfio/ccw: handle a guest Format-1 IDAL") 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/s390/cio/vfio_ccw_cp.c +++ b/drivers/s390/cio/vfio_ccw_cp.c @@ -233,6 +233,7 @@ static void convert_ccw0_to_ccw1(struct } #define idal_is_2k(_cp) (!(_cp)->orb.cmd.c64 || (_cp)->orb.cmd.i2k) +#define get_idaw_size(_cp) ((_cp)->orb.cmd.c64 ? sizeof(u64) : sizeof(u32)) /* * Helpers to operate ccwchain. @@ -524,7 +525,7 @@ static dma64_t *get_guest_idal(struct cc dma64_t *idaws; dma32_t *idaws_f1; u64 first_idaw; - int idal_len = idaw_nr * sizeof(*idaws); + int idal_len = idaw_nr * get_idaw_size(cp); int idaw_size = idal_is_2k(cp) ? PAGE_SIZE / 2 : PAGE_SIZE; int idaw_mask = ~(idaw_size - 1); int i, ret; @@ -593,7 +594,7 @@ static int ccw_count_idaws(struct ccw1 * struct vfio_device *vdev = &container_of(cp, struct vfio_ccw_private, cp)->vdev; u64 iova; - int size = cp->orb.cmd.c64 ? sizeof(u64) : sizeof(u32); + int size = get_idaw_size(cp); int ret; int bytes = 1;