Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp364661rwb; Tue, 4 Oct 2022 05:17:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5fpouCtSRZgN6/G9F+JFg3Lg2fB0PnTq3aVJO0AVg+DYqpGq4QgEeDdU1UcVJimlDtaVtt X-Received: by 2002:a17:907:d8e:b0:783:a4f0:1052 with SMTP id go14-20020a1709070d8e00b00783a4f01052mr18960077ejc.41.1664885833456; Tue, 04 Oct 2022 05:17:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664885833; cv=none; d=google.com; s=arc-20160816; b=WNAZ7/9b+C/kHwiigbs9bLBRzvNZMGesVsmNVlSOGJrc8PPuLdO1xmYUS0V+hbE0WT 0twA5jIk+rWYTjek7pQlzJ7BDoOhX1dakt9g8yO1PLh4BsD6DNz21m3EgBAVCkK8sCuT k8+Ynk2HmV/kB7LZ8uXdPbUjigHw7gEvX7Vyk3X9/Ph8hjsjHoLF5J5BeINPlkTUeyqp OI5bu6jexcXrUJ5VRfKM5Oe1L0dM/+uhr1ZWYUbTLlNh1bUN881nRvm9Tua9kPT8/yud rJXltI0IMwQETBeZL9Gl16wRMUt1/VyQGqyXQa77W8tRTlm1bL8EWorsMMMSEY3hhzWU fjKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gjJeUk27NyKv1lbIFV/Hsf9JTFXiSQ9D5upP3GoVtkc=; b=La2c9ZcfZGwmjT/7FybDU3WbA0cGO+iCR/eBAZRqofFd+w9+wZd6v3kb6sltAH22NP 8JDRU9iO5Y4dRoarj+Eav//OcnTv3OEkWJ37oN37EXomYswV1E0bWXOPK3ElJ3yYCAWG 3Gu3bBMtUg7uRqh2UNJEvB9SfXb5Qx+yrpEr+Ksn4oD78/viSW4fiO9GemaRkWg+WAdx FWuqaV/lS7fXDOtrUuEURiyYJiwpid/hChGZYeDzYtQ+cezOA2KNo47a2sxay4iFTYXv BHXPDYbgO2l+zijS6Gro0YNN0A4STsy90B+X6lESbmy9jKKVYkxMyJlTJ49MTU84vVr7 rENA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=nBVXCcjO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f11-20020a056402194b00b0045901fa87a6si5004159edz.449.2022.10.04.05.16.47; Tue, 04 Oct 2022 05:17:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=nBVXCcjO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229436AbiJDMH1 (ORCPT + 99 others); Tue, 4 Oct 2022 08:07:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbiJDMHY (ORCPT ); Tue, 4 Oct 2022 08:07:24 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E3CA5005D; Tue, 4 Oct 2022 05:07:24 -0700 (PDT) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 294A8c7f008580; Tue, 4 Oct 2022 12:07:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=gjJeUk27NyKv1lbIFV/Hsf9JTFXiSQ9D5upP3GoVtkc=; b=nBVXCcjOMKQhX8K3nfcK/8XaqURyc4KEQ2kQg+aDBDn52dgn+e9HZWSZwAncAdHiC3yp GrYbiUDutumnSYD2ycCgsmsUdis9N6B2IO1SlkW/JvLiL60IDJTES8OzP9dEV7/QohA8 ZEkqfyfP5HJdcDvpxC8/Y2GoccuZ/YZp80hDwaCb35Kw4ryYN5Gmzezai9+p+0qNv4Cc JE0/zoRbIv//LYclsKrUS7Mq7ab9yoGHdS1cbEHCbjq8kck5cesiWOFMUI9MyKy/2fmW 0VynU6bO9Xzrgwd6QiCCXd6tjF+cSOwb6IG4CYXCWASvQqBVhYheVO0Q3TPTHOPIlOmf KQ== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3k0gw16k90-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Oct 2022 12:07:14 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 294C62Bt026342; Tue, 4 Oct 2022 12:07:12 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04ams.nl.ibm.com with ESMTP id 3jxd6943qd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Oct 2022 12:07:11 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 294C799t59507174 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 4 Oct 2022 12:07:09 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E64DCA4040; Tue, 4 Oct 2022 12:07:08 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 724BCA4053; Tue, 4 Oct 2022 12:07:08 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 4 Oct 2022 12:07:08 +0000 (GMT) From: Niklas Schnelle To: Matthew Rosato , Pierre Morel , iommu@lists.linux.dev Cc: linux-s390@vger.kernel.org, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, svens@linux.ibm.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, jgg@nvidia.com, linux-kernel@vger.kernel.org Subject: [PATCH v4 4/5] iommu/s390: Fix incorrect aperture check Date: Tue, 4 Oct 2022 14:07:05 +0200 Message-Id: <20221004120706.2957492-5-schnelle@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221004120706.2957492-1-schnelle@linux.ibm.com> References: <20221004120706.2957492-1-schnelle@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: vnDWB1zKrndT8EZxLDv53iZgmKcVPahl X-Proofpoint-GUID: vnDWB1zKrndT8EZxLDv53iZgmKcVPahl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-10-04_04,2022-09-29_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 spamscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210040078 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The domain->geometry.aperture_end specifies the last valid address treat it as such when checking if a DMA address is valid. Reviewed-by: Pierre Morel Reviewed-by: Matthew Rosato Signed-off-by: Niklas Schnelle --- v3 -> v4: - Make aperture check resistant against overflow (Jason) drivers/iommu/s390-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c index 762dc55aea1e..94c444b909bd 100644 --- a/drivers/iommu/s390-iommu.c +++ b/drivers/iommu/s390-iommu.c @@ -200,7 +200,7 @@ static int s390_iommu_update_trans(struct s390_domain *s390_domain, int rc = 0; if (dma_addr < s390_domain->domain.geometry.aperture_start || - dma_addr + size > s390_domain->domain.geometry.aperture_end) + (dma_addr + size - 1) > s390_domain->domain.geometry.aperture_end) return -EINVAL; nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT; -- 2.34.1