Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1885802pxk; Tue, 1 Sep 2020 10:02:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzV/Oqspz/HNcMbKXsb7MOqcjaIzoic87vv5y2eroZ55+jfla1hNZn4ix85EtpDXndjKeWp X-Received: by 2002:a17:906:69c1:: with SMTP id g1mr2297769ejs.285.1598979726295; Tue, 01 Sep 2020 10:02:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598979726; cv=none; d=google.com; s=arc-20160816; b=mIamPsfvoqY0RD/V9Kb2jRhLql/19KP39Y4m1hF4665itRBAIMzjuZ0IeAtFw95N2L 4iW1ichyrzjsObFvN8fn9+n+xcfvVScNdCunaeCymUDLdg9P39OewnKA2fo7M2ulTklg 6iBXbQEZC80plP30DZoVWCw4qFI58fkTcueYbZwXe2GmrcEEpVFc7WMuU8MCUSOnVZV8 ZaK+1fAzXxnvyvW9wHqShnflQFSgHx2y0V36pkVXkIRIwYSQElN7uP+MNxygg77v6Cyg s14VAkeXFIu8XMYatJ7MLAtBck2Vz/2mJXCTUtMoxopayPsAqxo98W5WKEI/Xh/Uqfhh xpuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Rfx3YgJQyQgCESNlrqaclgUNgPEEOD2bXQ06viiruvg=; b=lUsJkuRG7H3TwvVDNyc7nc4e37bTH8lIPgXbGscnzp9w+ddwLldDIQVheCBC/tY29p JSE+kNKM6bhgy/bTOnixryWjDXDaaj7bZdWpEIUXgLq8oeahTBzUa1bUooCuZ17PjKyo 2IAqFv1qc6zYLkCBqEmgwksmH9fUQGe3LJ+LVc8o2ry25u8gK4ZpwctKydtMHmnON8J1 XVlnXBcgaQxbLtm7gwYCE8vMV7nNfOkXzNRAk3vtOJCmx7cKZFWQEvzD2k98bwMLorJ5 O88EYw+Dw7AEYy68mxESqA219v86scEsudiqlI5Cd07k3M1dm5+vc0QitqTr91fo1ewz 1D8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1R5Oq569; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w16si985693eje.414.2020.09.01.10.01.42; Tue, 01 Sep 2020 10:02:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1R5Oq569; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732481AbgIAQ72 (ORCPT + 99 others); Tue, 1 Sep 2020 12:59:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:42890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729449AbgIAPVu (ORCPT ); Tue, 1 Sep 2020 11:21:50 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BBE0B207D3; Tue, 1 Sep 2020 15:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598973710; bh=QWOGaXnMi9tVxvefm+GLsgAaLy1fnmwknssikhptLsE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1R5Oq569hsvTnM98oPQbH9GO01wqHIvjQJTfKLAEf6EHagzD6pa7jrHMS1J+EAK7B c5LctVMqBotM4xgHxhXoziMHJAkL8bVFohvH3GZuo5zOO2928kLsCNKW++8diOQwUu PhbtO4KShU26/rIiBFdTwhC5N5nUB3kgd/l6h3HM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jia-Ju Bai , Sean Young , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.19 016/125] media: pci: ttpci: av7110: fix possible buffer overflow caused by bad DMA value in debiirq() Date: Tue, 1 Sep 2020 17:09:31 +0200 Message-Id: <20200901150935.368387062@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150934.576210879@linuxfoundation.org> References: <20200901150934.576210879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jia-Ju Bai [ Upstream commit 6499a0db9b0f1e903d52f8244eacc1d4be00eea2 ] The value av7110->debi_virt is stored in DMA memory, and it is assigned to data, and thus data[0] can be modified at any time by malicious hardware. In this case, "if (data[0] < 2)" can be passed, but then data[0] can be changed into a large number, which may cause buffer overflow when the code "av7110->ci_slot[data[0]]" is used. To fix this possible bug, data[0] is assigned to a local variable, which replaces the use of data[0]. Signed-off-by: Jia-Ju Bai Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/pci/ttpci/av7110.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/ttpci/av7110.c b/drivers/media/pci/ttpci/av7110.c index d6816effb8786..d02b5fd940c12 100644 --- a/drivers/media/pci/ttpci/av7110.c +++ b/drivers/media/pci/ttpci/av7110.c @@ -424,14 +424,15 @@ static void debiirq(unsigned long cookie) case DATA_CI_GET: { u8 *data = av7110->debi_virt; + u8 data_0 = data[0]; - if ((data[0] < 2) && data[2] == 0xff) { + if (data_0 < 2 && data[2] == 0xff) { int flags = 0; if (data[5] > 0) flags |= CA_CI_MODULE_PRESENT; if (data[5] > 5) flags |= CA_CI_MODULE_READY; - av7110->ci_slot[data[0]].flags = flags; + av7110->ci_slot[data_0].flags = flags; } else ci_get_data(&av7110->ci_rbuffer, av7110->debi_virt, -- 2.25.1