Received: by 10.192.165.148 with SMTP id m20csp92979imm; Thu, 26 Apr 2018 16:44:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrgb3cSBQ54IrUlrf1kOIkRPT1QSD5wZGmTP7dhgCRgzn6t/hCSpmesSNg7CbLic7PAA9oV X-Received: by 10.98.155.141 with SMTP id e13mr58062pfk.157.1524786255678; Thu, 26 Apr 2018 16:44:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524786255; cv=none; d=google.com; s=arc-20160816; b=nfTYjiUIm5+sHqMeAipLRhKiB70ap485YbHDW+QSg9m4HQSevUD26wxbXspuK2Mhpa iypfy3W161hvxfuD2wO/jj2yrmMs9/lLUXdvHeActgfN32Tmgq2MdtMS4J6ZMwxKnxZ4 YBPjc2wsVhFHNMoAQRjR0m7USShYDRhSz+/feRyTAwwOwfgKICs98R+IiN5SkwrSjT/8 MwJe9pLFHtqBcXlAlFr5aMAVIfpEt6z/WGEMIex8g8JzzECt+jFkbkNEPg9laZWUIEy6 Zj+JWmnVKf64BSfmsV05f3r4PDsKZx8eBY1nGyx6vfVyewthmm42csEtfHIAfywT7Asz YICw== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=b1vAtMkrCiE+e/63WUwDpd50uhqRaum5c2RfOw31iHw=; b=mVjqlNx96LttgM3z/KealYJvL0BF0XaB5+JjgCp6sh0o3hU9TC1LPdUkIIOeyrjR8W kEK1LFhB3GN2DR2OG9yDqkefPIA538LESv8QEz0mKAfBwyvjVOiL5nUjWJc8cPvD6FHu euzNng/fCI33uxZGoKf4KlANJli5VJyqO6CSUvPvpl12MT0hK2oQHOD97n8y3n4GM5PJ qZjyDR1hECgpORcKFVWeGI9xaREmsnCziibRhNfwap3RUQ0jCC5M4ir7Fv72H/hu7egp LS1wAs1pDhzlFoJnNhzclAOP143TW7Jb8xMJMa9t/+zCca+BW8d9Y4x/T2DO6NuSJjOY vvLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=IM7Bv+kH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 94-v6si7551ple.56.2018.04.26.16.44.01; Thu, 26 Apr 2018 16:44:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=IM7Bv+kH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754888AbeDZXm5 (ORCPT + 99 others); Thu, 26 Apr 2018 19:42:57 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:34644 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751405AbeDZXm4 (ORCPT ); Thu, 26 Apr 2018 19:42:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:To: From:Date:Sender:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=b1vAtMkrCiE+e/63WUwDpd50uhqRaum5c2RfOw31iHw=; b=IM7Bv+kHHFNq+VwM7MidemAY/ T+cgIZ1UbnVTKfupVJUbiKs1jTCL3AIH92jiUkutpkNRmJxI86/qG+pdJUc+kV/8tB/NDEdqBpNwq xAeLzRmYkuEdPj+xawBMyELhPMd9gm62R3L1KyKaTRv67yoJNLDh7f3k0K/O/Oetcf3/6fmXOW9Wf QwSYCJEYSDc6V61MdqGoznTRCZpms7p0sqpfprEFq0GBcgBcSkgBtDH71YcuXplQHusdakgPAiWQJ r2+CuvA9qvRQsJRQj5gwqzg+kBiY7JPwCxUIdzPKXqEQfXaG/a8cLtSSqT3+TWtnFsdmiVZC+t7FI IFt2wL2Iw==; Received: from 179.176.123.138.dynamic.adsl.gvt.net.br ([179.176.123.138] helo=vento.lan) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fBqXH-0006iF-6z; Thu, 26 Apr 2018 23:42:47 +0000 Date: Thu, 26 Apr 2018 20:42:41 -0300 From: Mauro Carvalho Chehab To: "Gustavo A. R. Silva" Cc: Mauro Carvalho Chehab , Dan Carpenter , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 01/11] media: tm6000: fix potential Spectre variant 1 Message-ID: <20180426204241.03a42996@vento.lan> In-Reply-To: <99e158c0-1273-2500-da9e-b5ab31cba889@embeddedor.com> References: <3d4973141e218fb516422d3d831742d55aaa5c04.1524499368.git.gustavo@embeddedor.com> <20180423152455.363d285c@vento.lan> <3ab9c4c9-0656-a08e-740e-394e2e509ae9@embeddedor.com> <20180423161742.66f939ba@vento.lan> <99e158c0-1273-2500-da9e-b5ab31cba889@embeddedor.com> X-Mailer: Claws Mail 3.15.1-dirty (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, 26 Apr 2018 16:41:56 -0500 "Gustavo A. R. Silva" escreveu: > Hi Mauro, > > On 04/23/2018 02:17 PM, Mauro Carvalho Chehab wrote: > > Em Mon, 23 Apr 2018 14:11:02 -0500 > > > > Thanks, I 'll mark this series as rejected at patchwork.linuxtv.org. > > Please feel free to resubmit any patch if they represent a real > > threat, adding a corresponding description about the threat scenario > > at the body of the e-mail. > > > >> Sorry for the noise and thanks for the feedback. > > > > Anytime. > > > > I noticed you changed the status of this series from rejected to new. Yes. > Also, there are other similar issues in media/pci/ Well, the issues will be there everywhere on all media drivers. I marked your patches because I need to study it carefully, after Peter's explanations. My plan is to do it next week. Still not sure if the approach you took is the best one or not. As I said, one possibility is to change the way v4l2-core handles VIDIOC_ENUM_foo ioctls, but that would be make harder to -stable backports. I need a weekend to sleep on it. > > I can write proper patches for all of them if you agree those are not > False Positives: > > diff --git a/drivers/media/pci/cx18/cx18-ioctl.c > b/drivers/media/pci/cx18/cx18-ioctl.c > index 80b902b..63f4388 100644 > --- a/drivers/media/pci/cx18/cx18-ioctl.c > +++ b/drivers/media/pci/cx18/cx18-ioctl.c > @@ -36,6 +36,8 @@ > #include > #include > > +#include > + > u16 cx18_service2vbi(int type) > { > switch (type) { > @@ -488,8 +490,9 @@ static int cx18_enum_fmt_vid_cap(struct file *file, > void *fh, > }, > }; > > - if (fmt->index > ARRAY_SIZE(formats) - 1) > + if (fmt->index >= ARRAY_SIZE(formats)) > return -EINVAL; > + fmt->index = array_index_nospec(fmt->index, ARRAY_SIZE(formats)); > *fmt = formats[fmt->index]; > return 0; > } > diff --git a/drivers/media/pci/saa7134/saa7134-video.c > b/drivers/media/pci/saa7134/saa7134-video.c > index 1a50ec9..d93cf09 100644 > --- a/drivers/media/pci/saa7134/saa7134-video.c > +++ b/drivers/media/pci/saa7134/saa7134-video.c > @@ -30,6 +30,8 @@ > #include > #include > > +#include > + > /* ------------------------------------------------------------------ */ > > unsigned int video_debug; > @@ -1819,6 +1821,8 @@ static int saa7134_enum_fmt_vid_cap(struct file > *file, void *priv, > if (f->index >= FORMATS) > return -EINVAL; > > + f->index = array_index_nospec(f->index, FORMATS); > + > strlcpy(f->description, formats[f->index].name, > sizeof(f->description)); > > diff --git a/drivers/media/pci/tw68/tw68-video.c > b/drivers/media/pci/tw68/tw68-video.c > index 8c1f4a0..a6cfb4b 100644 > --- a/drivers/media/pci/tw68/tw68-video.c > #include > #include > > +#include > + > #include "tw68.h" > #include "tw68-reg.h" > > @@ -789,6 +791,8 @@ static int tw68_enum_fmt_vid_cap(struct file *file, > void *priv, > if (f->index >= FORMATS) > return -EINVAL; > > + f->index = array_index_nospec(f->index, FORMATS); > + > strlcpy(f->description, formats[f->index].name, > sizeof(f->description)); > > diff --git a/drivers/media/pci/tw686x/tw686x-video.c > b/drivers/media/pci/tw686x/tw686x-video.c > index c3fafa9..281d722 100644 > --- a/drivers/media/pci/tw686x/tw686x-video.c > +++ b/drivers/media/pci/tw686x/tw686x-video.c > @@ -25,6 +25,8 @@ > #include "tw686x.h" > #include "tw686x-regs.h" > > +#include > + > #define TW686X_INPUTS_PER_CH 4 > #define TW686X_VIDEO_WIDTH 720 > #define TW686X_VIDEO_HEIGHT(id) ((id & V4L2_STD_525_60) > ? 480 : 576) > @@ -981,6 +983,7 @@ static int tw686x_enum_fmt_vid_cap(struct file > *file, void *priv, > { > if (f->index >= ARRAY_SIZE(formats)) > return -EINVAL; > + f->index = array_index_nospec(f->index, ARRAY_SIZE(formats)); > f->pixelformat = formats[f->index].fourcc; > return 0; > } > > > Thanks > -- > Gustavo Thanks, Mauro