Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4262668pxb; Mon, 21 Feb 2022 16:18:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsdNY+YF7iKIunhElJiseYLh4bW4kCJGHca5wtJm1STTslsH2dzlKeLVCKChE+O3iDXraS X-Received: by 2002:a17:90b:120d:b0:1b8:98f3:53f1 with SMTP id gl13-20020a17090b120d00b001b898f353f1mr1416884pjb.36.1645489134951; Mon, 21 Feb 2022 16:18:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645489134; cv=none; d=google.com; s=arc-20160816; b=WPgqNe/rCP/pQJbmfwOIHjWttDD/xliEDAhrt+PX/inrRQhHSxfQ0xjZEmi8TPh0wd yUAWDqVynNB5eOQIyHBtG7jSVIWErx514ildQP+MwDretxJHBni8Np/oNJhkmuFCc5zJ DGZT9h8eU+uLCQk3Rx1zr8xCqwPf9zfcmD4urszAPqXQNjTLzwPq/m7kL4N479WgEHXe JUcA6DiVI1zGx5EtEjZfvIVuYroLdjF5DTElBd0i8+bRHCgsI59YGyR3yZMJc1ks4tPj 0qKj+v1nAKWs2I9oHYAh8yr0l3tbm5cB4Q3r4eRJgzIrZsWY3NeSFMC4D9eA0E5DjYqd aYHg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yxyiHh+3Fu1Y9uLGSQuXqS+Wt+YTcrSCJN4Xw47nDT8=; b=O0c1Md9v6+IqBrr1lUshZyMy8+xAdFCAVNSpzxj0TQrdgIrs48K8SkMLjMj0WecrlO sGi90LsvmIy0/AfUAAdH67TTzsbibXQcSrr2xpDandil8M96rwxqY4fDwbdzbS1+jRS9 JYMHq4ARslXoxUz/piMRyCJPgQN3SDUm54f7pJ9WbuT+Ej3qmVAsnR5qUlDxu+18AJjg N/e2VR4rrCta8ozwfLQ79IOnxZoLBWlTdd+mZoImP/T90FgTV//efiH2Wj+Z+ep/yWTN Dwe6pCe3lILWYREvTcvUXbuDYRi6lVt87MoVmL5hUvg5RnkxxxnN1CbOFyPM8wgxNhAo 1K6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Befte3Vu; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bc2si30893894plb.349.2022.02.21.16.18.39; Mon, 21 Feb 2022 16:18:54 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=Befte3Vu; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347134AbiBUJDq (ORCPT + 99 others); Mon, 21 Feb 2022 04:03:46 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347139AbiBUJAx (ORCPT ); Mon, 21 Feb 2022 04:00:53 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF13E275F0; Mon, 21 Feb 2022 00:55:55 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 704A7B80EB5; Mon, 21 Feb 2022 08:55:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C906C340F1; Mon, 21 Feb 2022 08:55:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645433724; bh=jq0IZZMNLqbynoTr7qWYEP7/cjlKhs6FfrgJYs/FnmA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Befte3VuEloqeDmDtlKa8BWLwnTJBCib8Qs7jKMOdYOQT7oxrmr/ynJwfQrmiOJnM 1f2PezvC+w4FzJx9M0HOvGFW+iUuqEn5XpRrzGehfZnoUpxKeg2R+ebkhQ+BtGLIAQ DEJjhTlOYXyY4m5XRAZgcDy/qbElDOIKLF4UFBA8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John David Anglin , Helge Deller Subject: [PATCH 4.19 05/58] parisc: Fix sglist access in ccio-dma.c Date: Mon, 21 Feb 2022 09:48:58 +0100 Message-Id: <20220221084912.062549850@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220221084911.895146879@linuxfoundation.org> References: <20220221084911.895146879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: John David Anglin commit d7da660cab47183cded65e11b64497d0f56c6edf upstream. This patch implements the same bug fix to ccio-dma.c as to sba_iommu.c. It ensures that only the allocated entries of the sglist are accessed. Signed-off-by: John David Anglin Cc: stable@vger.kernel.org Signed-off-by: Helge Deller Signed-off-by: Greg Kroah-Hartman --- drivers/parisc/ccio-dma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/parisc/ccio-dma.c +++ b/drivers/parisc/ccio-dma.c @@ -1010,7 +1010,7 @@ ccio_unmap_sg(struct device *dev, struct ioc->usg_calls++; #endif - while(sg_dma_len(sglist) && nents--) { + while (nents && sg_dma_len(sglist)) { #ifdef CCIO_COLLECT_STATS ioc->usg_pages += sg_dma_len(sglist) >> PAGE_SHIFT; @@ -1018,6 +1018,7 @@ ccio_unmap_sg(struct device *dev, struct ccio_unmap_page(dev, sg_dma_address(sglist), sg_dma_len(sglist), direction, 0); ++sglist; + nents--; } DBG_RUN_SG("%s() DONE (nents %d)\n", __func__, nents);