Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4391419rwi; Mon, 17 Oct 2022 05:48:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4VgdJuNFhxG+QLJxxLaLs+6sVl8AowY6nsMJZaBgC5wAntjy5I/PX/HZfm6PRXhTsGnSFW X-Received: by 2002:a17:906:7945:b0:73b:e605:f31 with SMTP id l5-20020a170906794500b0073be6050f31mr8611303ejo.129.1666010892528; Mon, 17 Oct 2022 05:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666010892; cv=none; d=google.com; s=arc-20160816; b=MCW2pB7bdcUrpNj3zh9h+lqvk3+wOfVTXgYDqzjs66OKZumFl/SFdC1dgwG2weQxH6 ykDIphy8m6CxKfV7xop+oxhknHO6yRIKahGscA/5PJJq8hl3QlAv9Aqcl4s8piiI7qzp AYveWUS0q2yG3opeL3dQ07C6sMjJcV5GwCUZ9HjmZPH3CEIlTGArRg6P+x1X1B4TvFEx NIci5GlV8G0aJ7gqGR0wzWLoPZEWAa/0ACsThN3OdZO9Olz5oHLGoXOrh33zhKOL+Tf0 uJafCUb+HIO35ibmeZpr2SvpNRsMDZkPY3q5muklEiZvUuHwyr0125U3LSLIAvXZtgIz rpKA== 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=+Oxeb8UCfzjuNEnaMhEJFdLbzN16OMVcI7by7StU43g=; b=yDCoXJ0rkXy98HVmSmsLQRGiJUW/iaGEonaBI733uDe+gf3Ovk/UXDrrhU2sedeLZV kr7MpiZ1GFmpf8AlasZkvVykbL8j2FoOHtMUOl4XlkZr1KWEYFi/rMneggNai7IcDg2G n+VWg2WMgqCDtYlLffWJqP6kGH9MzNnaSs8Nx0uK7cMNApwCqh5lOzWtDbt2BNO2MTm1 +lg+6+yDSYxEQVjtfAp6zR6JnEujp+GMFYqTkvOMULn3xKov53skColK1RgXA1XVaJ4r OcUjMxZ9cDLUoyxxEWdIk5ZNsFwAhgWQG7Fh1KAezu4X3VzlVev1bOQhTSVDgqQjDnye G45Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=jWLlaJXm; 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 ho40-20020a1709070ea800b0078df1c345dasi9493534ejc.534.2022.10.17.05.47.36; Mon, 17 Oct 2022 05:48:12 -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=jWLlaJXm; 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 S229765AbiJQMqT (ORCPT + 99 others); Mon, 17 Oct 2022 08:46:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229943AbiJQMqS (ORCPT ); Mon, 17 Oct 2022 08:46:18 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35F6854C96; Mon, 17 Oct 2022 05:46:17 -0700 (PDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29HCflLU026992; Mon, 17 Oct 2022 12:46:07 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=+Oxeb8UCfzjuNEnaMhEJFdLbzN16OMVcI7by7StU43g=; b=jWLlaJXmb5vLAlovyq8CIXKQ+trgrA4BhHFbQtVIdFts3K+6VXHEoQNcbUGyoo6u3o4b vZh8nUwdtBUBRVKPiRWZtxU75ajUAEZdR/o6srnXcB6I8ZI2Ql2s2q4gfQY/aX0mpiSe EW5mjJFhW1BMJrOm4XsmrVFeqgzhPCPsM524+pJmrrSOp+2YZl0R5qUmMTpYf61DbYcp XyZlfchdkyCdQPA1Z7tC9PChZr0F7nWuWWM+99iWw513dvcf5MQuA3h3vrYOtFwFIBLE yfvsSSfZgkosEMHGAAZrOrBIskuMkeunHvI3ASsEp09gvXiOQ4qsQ9+iGtbWMD0g5xMy +w== Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3k86sjs8e4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Oct 2022 12:46:07 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 29HCa9tO028076; Mon, 17 Oct 2022 12:46:04 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma02fra.de.ibm.com with ESMTP id 3k7mg92954-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Oct 2022 12:46:04 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29HCk1174981284 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Oct 2022 12:46:01 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7D49B11C050; Mon, 17 Oct 2022 12:46:01 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 03D3311C04C; Mon, 17 Oct 2022 12:46:01 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 17 Oct 2022 12:46:00 +0000 (GMT) From: Niklas Schnelle To: iommu@lists.linux.dev, Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe Cc: Matthew Rosato , Gerd Bayer , Pierre Morel , 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, linux-kernel@vger.kernel.org Subject: [PATCH v7 4/6] iommu/s390: Fix incorrect aperture check Date: Mon, 17 Oct 2022 14:45:56 +0200 Message-Id: <20221017124558.1386337-5-schnelle@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221017124558.1386337-1-schnelle@linux.ibm.com> References: <20221017124558.1386337-1-schnelle@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 7wq5gA-XyXjMWuBa76emWmQ1L2cg_xe8 X-Proofpoint-GUID: 7wq5gA-XyXjMWuBa76emWmQ1L2cg_xe8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-17_09,2022-10-17_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 priorityscore=1501 phishscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 spamscore=0 clxscore=1015 suspectscore=0 mlxlogscore=848 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210170072 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 check robust 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 c4203a37faa4..fa8cb97bfc88 100644 --- a/drivers/iommu/s390-iommu.c +++ b/drivers/iommu/s390-iommu.c @@ -213,7 +213,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