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 050A637C90E; Thu, 20 Aug 2026 15:06:56 +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=1787238417; cv=none; b=Wi4ryMpLZGt6X+QTQD8FAV923GOje1UH2Ks0ftcMbp/JMVnKj+cfhbYqreUqCX44lXP3z8pBF5Q9IiKv+7Otqv814uJae1NxT2Jza1VjOwASWvg56fWN5pnDj5AC+q7eKQsuTHwJz/PBUHfFQf2LA219DuyuvxFK17y8v6pNffA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787238417; c=relaxed/simple; bh=oxe4DDtBRWKUSepAktMZCSOr64UA9Cvr4B+MC7OVB0E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jbnxNyiGNNmx2AfBhUHFdbp6HseqZVGJKQO/WTH05M3e95owLmeJ2t8lAbyHVFOfQcwPgV2TqA8AuhLomS43jlHUUxByqoNJPIX2+3NTLr8+NeW8nuYE2WeurU+ZLFxKuCHUGYKiywvMAxEGuvxZhabnJxDh0Nyz9sm8o8j9CEk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qLd2GRjh; 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="qLd2GRjh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5ED4E1F000E9; Thu, 20 Aug 2026 15:06:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787238415; bh=FAwXKgaB5+WuGPdIsg2QnqR11egM2Ot17/7vNySH1ts=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=qLd2GRjhyG6ouk51kFjXetm+MTcyXb/kN80eWqjHD5PxmHZYeM2YTWlABu8RzjD06 Cy+twIP2/yZDZLCiw3CxTJ7nqjNS9h5gdutJJCNIszWJCYES0FvQGzN+bLptmVaWtN KLdBJaHndT2Dia7t2WXEMV1XDDWUqa4TOXMFB1ko= 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 7.1 103/228] s390/vfio_ccw: Calculate idal length based on idaw type Date: Thu, 20 Aug 2026 16:54:05 +0200 Message-ID: <20260820145247.777848242@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145244.450574346@linuxfoundation.org> References: <20260820145244.450574346@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 7.1-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;