Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp245794pxk; Sun, 30 Aug 2020 01:35:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbMStg+yZlpeMwa7NJyNnS8iCSP5TDO2sLsRZ9YBs2Z28LWiI1xw7R1gdnmXhfwMr/HCBu X-Received: by 2002:aa7:d284:: with SMTP id w4mr6788939edq.258.1598776518621; Sun, 30 Aug 2020 01:35:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598776518; cv=none; d=google.com; s=arc-20160816; b=y46HTo4pwUvsntqVmRYUbH/wZMRgvzpG4TdDF/TG+UzN8htkLVoaLBezcC04pJ4PMN iFMxpgAe8brycPgMaNHHUYSg0pJmZ9/lnzmvRyHygoFqfAJcworjEK+ZBL7Dz9RDU7WJ +vsKCkl+oqvo61nt26RdlWi2HZY3kRwbW4kuvsMPmDMQEQoF+VW009KmHpycyqWNA/cB u1SDw02LiJpkdBQ8hhzhrY8ywfczeIDRy1zkT2h3XhjkTh8W6SgYXJe9gLfvz6ETSS1y 7t+KEfAHnwsGW/dvCgbKEEk/w7YVHAWd8wyjgaCeglYYO+mvQimsu8H6eVEC2x8nkhXA IUKg== 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=mlHp3Rhkq6oUxRG0a6OcCm4AjlEZ9Q/kRDwXiKc9sZg=; b=dVC6/2pi0E2o/8qdpoCbVCn15QMnhcVZ9DFaI6zsXJXRcoIOWEQwzj415GfTY3LJuE ucD/dtqho5Fq+kk5qXxoGM/f7uLBTeMbysMRRYS/xeY9zENsHHnLkqbtNEytKc1oHlOd g9OzURA4anRD58QK1VqbYeiYB6Wdy1kYK/V6Ku+cOmGT70XOm5qQUWCYU+0SWYfwf97T aZpLyPwe4SftctRx+RPP7s2q9r+e5FVJBTyLp6EJv2lsgYb5Ip22HvKbPPxo1z0wThor 3SiD/uJb+uALsRR8Ar5FT8qhkyPJ8WOveL+Z5iwwTZKSvnZF5YuR4qK6+IzEu5pQYdYJ r+3g== 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 w2si3327573ejz.34.2020.08.30.01.34.41; Sun, 30 Aug 2020 01:35:18 -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 S1726479AbgH3Iam (ORCPT + 99 others); Sun, 30 Aug 2020 04:30:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbgH3Ial (ORCPT ); Sun, 30 Aug 2020 04:30:41 -0400 Received: from gofer.mess.org (gofer.mess.org [IPv6:2a02:8011:d000:212::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BCA6C061573; Sun, 30 Aug 2020 01:30:41 -0700 (PDT) Received: by gofer.mess.org (Postfix, from userid 1000) id DFD70C63F6; Sun, 30 Aug 2020 09:30:36 +0100 (BST) Date: Sun, 30 Aug 2020 09:30:36 +0100 From: Sean Young To: Jia-Ju Bai Cc: mchehab@kernel.org, pavel@ucw.cz, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] media: pci: ttpci: av7110: avoid compiler optimization of reading data[0] in debiirq() Message-ID: <20200830083036.GA17715@gofer.mess.org> References: <20200830082042.17462-1-baijiaju@tsinghua.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200830082042.17462-1-baijiaju@tsinghua.edu.cn> 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 On Sun, Aug 30, 2020 at 04:20:42PM +0800, Jia-Ju Bai wrote: > In debiirq(), data_0 stores the value of data[0], but it can be dropped > by compiler optimization. Thus, data[0] is read through READ_ONCE(). > > Fixes: 6499a0db9b0f ("media: pci: ttpci: av7110: fix possible buffer overflow caused by bad DMA value in debiirq()") > Reported-by: Pavel Machek Pavel reported that your patch was garbage, if you are trying to defend against a malicious pci device. READ_ONCE() will not help here. Sean > Signed-off-by: Jia-Ju Bai > --- > drivers/media/pci/ttpci/av7110.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/media/pci/ttpci/av7110.c b/drivers/media/pci/ttpci/av7110.c > index bf36b1e22b63..f7d098d5b198 100644 > --- a/drivers/media/pci/ttpci/av7110.c > +++ b/drivers/media/pci/ttpci/av7110.c > @@ -406,7 +406,7 @@ static void debiirq(unsigned long cookie) > case DATA_CI_GET: > { > u8 *data = av7110->debi_virt; > - u8 data_0 = data[0]; > + u8 data_0 = READ_ONCE(data[0]); > > if (data_0 < 2 && data[2] == 0xff) { > int flags = 0; > -- > 2.17.1