Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3725279pxb; Mon, 21 Feb 2022 04:38:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJyT7jyBthPZx+UzJssygGBHpkdRpk0HTw284qSgDMgDI/k+OzEvy2FyHXOwWNWrjRXUKjbV X-Received: by 2002:a17:90a:2d6:b0:1b8:cd70:697d with SMTP id d22-20020a17090a02d600b001b8cd70697dmr25567262pjd.78.1645447109107; Mon, 21 Feb 2022 04:38:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645447109; cv=none; d=google.com; s=arc-20160816; b=T/dPqofT2aEAwTci+FWEPNqF6gnDte6CQQISD6jGHh9gp0HLfNnaeOC/6o1b7T6gmx Bc5yfH/xPYAUM7rmr8uqsR/YgWg40w6d79EeDLThT0VJEMGmmIln9WDTR9sVKUFBDUHU l1kOvnd7RwGk/JkisR+thTnnAZQRiRBHZgBHTWJ25F/CT6+s8t6w6X/4E0QH6cHf0Pqp L7K69ZmOUaaUWw42DTB0DDpebgxGzgm4eDc98dU/uoLpi8/rkcyUMb1mOwn1HEFtJULC ZmeCL9d+iPaY/A+RsPfbmRni3qgTryhMdWoBDgRjXAp9fqGJgOnwrgJ0ZCnfhOOVpcnV Y4bQ== 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=Znzce/pP3JuLCoBUhK48w6IemXFvgpkuopeWm0c/mtQ=; b=MIPnLH+pu/3j1Pabw0Wa3zr28lSX9gLT7n7oKH5M23soMKi4xNXA9iVX5wAsocH8LC fQfDa7wKUcPQfW+PAJPFpRQQt3RpmaafbDS88vpkOc0/BEXTaJeTeXfSkPmIAvderzr2 macw5I14wKcDvRpt/gNJcltQrAVEhP4vBu0IomLQzAfqGpWN/0iPlquym67cTC4sPFHV AKUhop43AYuK07KNC4eNvzkEL+yhVEyI7GUNqtsENpX62i1ycxiD/pmJWVK3uV+jlQ7/ lQlj1Yx2FDfOnEK4/+rx86vojkTJ/deKM2EmP+xucMqDkDAVIneym/hAQJiAm1k7ep8c LMqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="MVJGgM1/"; 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 c5si2195900pgw.121.2022.02.21.04.38.15; Mon, 21 Feb 2022 04:38:29 -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="MVJGgM1/"; 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 S245452AbiBUJG7 (ORCPT + 99 others); Mon, 21 Feb 2022 04:06:59 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:59592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348422AbiBUJCt (ORCPT ); Mon, 21 Feb 2022 04:02:49 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ADA42C64C; Mon, 21 Feb 2022 00:58:05 -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 18B7CB80EB6; Mon, 21 Feb 2022 08:58:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CD4FC340F1; Mon, 21 Feb 2022 08:58:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645433881; bh=B3V/EFHY9+d/uJRBcFrB7LlPclALnd89vW1EiTlJXt4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MVJGgM1/TqRqNajntrmNviImMIf8mQ5+XL+PpZaPZHBQQTNEAoUYAVUvyU9w7kmnD 2WSSIYTXZVUyuqgi1VsTaMXtt+/UZvTTzLr4OQTpwJ1YalljWk88E/IibXGbifPe65 dYZNOIKkcTqd8wKKoKY29L82NkzDqpEeRvYkecqw= 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 5.4 07/80] parisc: Fix sglist access in ccio-dma.c Date: Mon, 21 Feb 2022 09:48:47 +0100 Message-Id: <20220221084915.835383796@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220221084915.554151737@linuxfoundation.org> References: <20220221084915.554151737@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=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 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 @@ -1003,7 +1003,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; @@ -1011,6 +1011,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);