Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1863275pxk; Tue, 1 Sep 2020 09:29:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJkvYly3R8MKewriiH8xidBfNHOCW+aW+1R/8EljX9xJEaPx4CNsQpK6FY7qxLjaNqbxbL X-Received: by 2002:aa7:de91:: with SMTP id j17mr2467593edv.85.1598977795552; Tue, 01 Sep 2020 09:29:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598977795; cv=none; d=google.com; s=arc-20160816; b=RHHdO0w3yA0Uu8e3AU06QIbxNF2TMKovgMUfeyxYxx78+VSpF8TXYxqNPtpGXQ4dL4 q9gg0anMS17PMTfhKu1tpuVy0+LDOU4ojg0j1XjzLkgEu3fWm2Wu/DKsnPozFrKmAVt7 OPIBVxr9LaRJDwp6k+QHEiIJ/p3P7kKCs8iIFeI3jsGL5qMiuZt7aJoidkMqo+g9mn/I SiRSs0+np+q773r4radtrqKJPloNhGWOc75elH6tKnohLdM/QjuOUkeLhpdcVhAOrizX mxohUV5SDQtutQzrv0I4oYXyZrcSFC/988qWw+26IjwjP1Qxmh4xBj5N0rqSM0xZK30p btEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=7HM08IrlAt/dsFNbjVpVm1TmNlTrvS/R6w1AYM0PS4I=; b=VHE7MCwshH26sFTT8qXkAt66bKMgseqzs3ocb6DfRzxIFbfhbdRdfG43PBCERkbRsI 63IiILF0SmXE7EjrFkUCV3ffdfjOtEFylOuET9CfsuAdf67zDjPcbZcGzyDUovrKKgc6 Tdv0sxk2i2QrxoWmd5M6mOP3QgD/3TamLJ4SYMpS3HeMdEwO2Aw8A2M1z35qfu+rgtM3 UVy3cSnNNJSMCkZ3PhzB69+8HVp716AynvuCh5K5tTf7EXm/d9F9bFYw7D8JNN3acCMT Y2Suau3Vy+r2s1urhAMr2stoTov1fSAWtgteW3zqjJfYQSmx2ZWVrvHEStiibFDmD59F 0o6A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c4si832983edw.41.2020.09.01.09.29.31; Tue, 01 Sep 2020 09:29:55 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730911AbgIAQZS (ORCPT + 99 others); Tue, 1 Sep 2020 12:25:18 -0400 Received: from gofer.mess.org ([88.97.38.141]:36619 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730027AbgIAQZO (ORCPT ); Tue, 1 Sep 2020 12:25:14 -0400 Received: by gofer.mess.org (Postfix, from userid 1000) id 7D41DC63F2; Tue, 1 Sep 2020 17:25:12 +0100 (BST) Date: Tue, 1 Sep 2020 17:25:12 +0100 From: Sean Young To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Jia-Ju Bai , Mauro Carvalho Chehab , Sasha Levin Subject: Re: [PATCH 4.19 016/125] media: pci: ttpci: av7110: fix possible buffer overflow caused by bad DMA value in debiirq() Message-ID: <20200901162512.GA30837@gofer.mess.org> References: <20200901150934.576210879@linuxfoundation.org> <20200901150935.368387062@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200901150935.368387062@linuxfoundation.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Greg, On Tue, Sep 01, 2020 at 05:09:31PM +0200, Greg Kroah-Hartman wrote: > 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]. See the discussion here: https://lkml.org/lkml/2020/8/31/479 It does not seem worthwhile merging to the stable trees. Thanks Sean > > 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 > >