Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp242064pxk; Sun, 30 Aug 2020 01:24:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcn7a1Rd0rD4TeiXWJowTg8rUZ5XKURwzeLPXH4acCJdDixRw6eJ3+v3c0fI/GJWvE6LOy X-Received: by 2002:a05:6402:10d3:: with SMTP id p19mr6623921edu.380.1598775844827; Sun, 30 Aug 2020 01:24:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598775844; cv=none; d=google.com; s=arc-20160816; b=pHc++tZ/4CvIcxQLrL04FJqTuVE4mYDmJ8opwAd9yOhM2/WGDx59TMf61lywlSXa69 fmEIw+JLcWPc0gyaq64C6L6xjs9ufU6qC784BMn3DwTb1o0fiS5hyHxmgowMHsFXeG/D mw0/TikTKox2e6f+N5Kgqe3k7Qkt02aa/Bmrq3qq9WZdxOvmQDnPoK6Woz//zCs/R0Ng ix5Ks6y/h4bsIPSy7PXOJsIQaKwxJnFN7K6Pi0HERGVdRHjyFJhtsIuQ0pGrxEL1WWcf sB6MwE75rmxO/vavFHSVgZW53TYLuzO4s13THolz9784H4KDqifh0mIkHqC6Xian5wlX T1Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=ZKH4Vv4l93+dyxwjYzOMxKaI0eazclK6qAUdMbecn1k=; b=t3T/6GqNh+AKbG8j0xLkIYSSGJ4xJQArJZFCQQxWM0JwKO5y1RbjPdwOtHdm8xE0Mm JWaeZZE3a08qmbwtmiOJr6zW/6PsYue6TYuRdAC3g8u8M3RhUYbiRKj8BPc3RHLrOe5U QPtuPZZl/7JV64djL38UuObx9UIR+B0ct9tSfzWY0FyWR0O+CiuHjugTOpkYxlACdfzi Y3vEVhycChOuqrMpLtkNehuH3y1SWH05Hc/iT/ElO5jE0hepSOw7byu4hRYl0CDE5uhn AtB8PGA3FiZMr8Ft1yLfsykq+L+H2dleD4rJEAWhjMRRclOq3ykP6TNhUuUa9VQWCCkk Zdtg== 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 b13si3080505edq.338.2020.08.30.01.23.41; Sun, 30 Aug 2020 01:24:04 -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 S1726406AbgH3IU4 (ORCPT + 99 others); Sun, 30 Aug 2020 04:20:56 -0400 Received: from zg8tmja5ljk3lje4mi4ymjia.icoremail.net ([209.97.182.222]:40780 "HELO zg8tmja5ljk3lje4mi4ymjia.icoremail.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1725869AbgH3IU4 (ORCPT ); Sun, 30 Aug 2020 04:20:56 -0400 Received: from oslab.tsinghua.edu.cn (unknown [166.111.139.112]) by app-1 (Coremail) with SMTP id DwQGZQBnSSNbYUtfs2HPAA--.4425S2; Sun, 30 Aug 2020 16:20:46 +0800 (CST) From: Jia-Ju Bai To: mchehab@kernel.org, sean@mess.org, pavel@ucw.cz Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] media: pci: ttpci: av7110: avoid compiler optimization of reading data[0] in debiirq() Date: Sun, 30 Aug 2020 16:20:42 +0800 Message-Id: <20200830082042.17462-1-baijiaju@tsinghua.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: DwQGZQBnSSNbYUtfs2HPAA--.4425S2 X-Coremail-Antispam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el-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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