Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1892745pxk; Tue, 1 Sep 2020 10:10:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMBYXgWFDtfvjoWR9OoSVhr7k6KZllLiySLWb0XW/hOhgGjVneaM0zXkeLZQEhQHcexLcB X-Received: by 2002:a17:906:6888:: with SMTP id n8mr2572322ejr.412.1598980215333; Tue, 01 Sep 2020 10:10:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598980215; cv=none; d=google.com; s=arc-20160816; b=SLStCyUyAOGQZAU7ZZ8PvwdsSLQGeG9GdW9Cmhb3JZ7biDJXmkhdE4XSF0BpwzClid 4v04xN6TjIAqyVE1fJjS2ppDi/aZ5ec+52iehNuZsBwcjCMoMyMCOpB57U96p2xEAqis mZlhReOSLeioOJwIMDADlcx7fAJgvJCBA7l1t3Jefcf4bueu4RMxCshCP/ru/mxjMgX7 EMe08//kEHRerZ7l8yf/izTQi5VkYvcdDC5WAzmZya8t949lEHcPkgbJ9mtJHWnwo2ZK m30vCg7z1AB0c5oXjpBqDdmc106rMn/pjoY2XFo0EvV4dv3EiUaIIyBeuDojlI+ZzuD5 BXSA== 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=QU6i/BgYsAla2i10S99wlpH3c+CX0fe3V+dy+56T4s8=; b=x+DK/2bwFzGpRjWfpMwWb/y9dxr3StGarimLiK93RlhsglRQ+aEcl1ClRTAwIaYbla J42GxR7PS4S5c0AkH+4Zqip2KDuuwUrTQWBJBZj4LOKlRHK0ZhrZNlLhbHwYa+8M8mfs EVUdwoBY9CErFLFJjcBKt7QiRrFr69pSPygCnXuJG1TRcIzMKrl2GbuJ9iwr8eoE99tt s+jb45EA13hW2OD8mvFmqya3zXWg8KNXy8SJunDB4iezuNY3fGKNGCPfeBpWJXau5xVc 9aT2nEhFcgsB3riOhr3V71cSiTO0NNlUv4Zn+85KKu8mYvAe2251S1g65vdovv/5PQOC g0pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UmBETSq3; 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 i6si909597edq.131.2020.09.01.10.09.52; Tue, 01 Sep 2020 10:10:15 -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=UmBETSq3; 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 S1732505AbgIARJH (ORCPT + 99 others); Tue, 1 Sep 2020 13:09:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:35428 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728670AbgIAPRs (ORCPT ); Tue, 1 Sep 2020 11:17:48 -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 1068820767; Tue, 1 Sep 2020 15:17:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598973467; bh=VaX1+Ny6L+YXxWnugwcXEPKB6ewm/BTnTiDqgAWIiVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UmBETSq3N0Rp9hw/xnVM61HhZSUje3V4oafbVsg0d53MopgSul3oyJ4DohESrGqAC l1/Oac/F5Z3A+ba0MIb9k+xq+aAkRV696wq/zh+AFt44mdGLostZ3fmCo/iIj+RIP6 cdvCkahGFmTJMcisvquCZqMCEAFBtPvqu5CqO4jc= 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.14 11/91] media: pci: ttpci: av7110: fix possible buffer overflow caused by bad DMA value in debiirq() Date: Tue, 1 Sep 2020 17:09:45 +0200 Message-Id: <20200901150928.666814366@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150928.096174795@linuxfoundation.org> References: <20200901150928.096174795@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 f46947d8adf8f..fcc053d95ae49 100644 --- a/drivers/media/pci/ttpci/av7110.c +++ b/drivers/media/pci/ttpci/av7110.c @@ -423,14 +423,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