Received: by 10.192.165.148 with SMTP id m20csp4995925imm; Tue, 24 Apr 2018 11:50:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx497Kv4aBu4Pl1q9jo6Y4WhVKl17DCxjwsVmutmjZ7LxMj6YVFPQt3HkLr92lFJkTVgCF/Zg X-Received: by 10.98.58.28 with SMTP id h28mr18205943pfa.209.1524595853341; Tue, 24 Apr 2018 11:50:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524595853; cv=none; d=google.com; s=arc-20160816; b=Hnu4DVJSZYApd+21JvEXRoJqqa68uEwr8dbTtFg1wdBMdaCSQc3+jmR1o/WEF2UTlU +E6eJnj4ggikn93ZE8icLIZ2DfPt6mUeOOxiTLqLxC3Wf7kUVYB3LuV7OUNIXazlH3jv 5jVwC4j5uCQCH7mZ3R01e1WTpBU5+xgMOp53uibGve+4c8/WTjsBdolJcxkjR2l30wgp XvARdQUwG1xKpRd+fWVNc8I3pKx06Zqyfjee4vb8WF269rULRm3BUZ/AaJ96/4SZwpWY 75CALUeWcZoDR6REDdWA6uRKd3e116VacVFsDh6Hwv9L9g9skWP5xy23Ge3Nj2Gv1ZVy IQiw== 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:dkim-signature:arc-authentication-results; bh=UtQhB9XChSoYb+Kny3Gw0tBTjo8a8se8TYGQeQbwZbQ=; b=ndwj970j0Hp9QkCZ/9S2sdRnpy7xA9vYVRnT0c+1X/5SrNZK7kV+hy5JB7PL2fKsNi Xs2Rq0O3AfpE45AVi+KLnYK35pFEVxBxLKvo/f6l64OsVicGaCMna3qM9DAREdcbUy4L A4nAwhYs/eqKU3if0l045HOtEA8kKHrwtEJ2FZ2lgEq/bJ1wtOHogwJiusvxJRhLG5Vm CBSIAGHjSmdQTE2gBrp0R96FttGQgsJXEtT0bcCSZF7icNMU2wGaGtblI7HzFy6rRCT9 PsOTv7SV1oIyVdK6tPTwWOCOCM2QUoYkYYNp0ibP6KVf14/6SQOOsoFf7wR4B8Y9+U0+ 4E1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=VsGbOzp6; 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 x1-v6si14248556plb.8.2018.04.24.11.50.39; Tue, 24 Apr 2018 11:50:53 -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=VsGbOzp6; 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 S1752313AbeDXSsy (ORCPT + 99 others); Tue, 24 Apr 2018 14:48:54 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:50128 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751938AbeDXSst (ORCPT ); Tue, 24 Apr 2018 14:48:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding: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=UtQhB9XChSoYb+Kny3Gw0tBTjo8a8se8TYGQeQbwZbQ=; b=VsGbOzp606D1l63dSx2C+lS9W fTZsauNiyDO1zNa7KDYOA8v3/JcWZesE0/GRcjgMAzGqXcGBTrAo1wVrOcWWd4jFSYrTSTlbS+jqH oVMwMHU9AmsavDGl0M+IJJpzmfGX+z9AUYCmWJBYA3ga/As0rhBYKXic3+RrvU8SygZDpAgYCJ1x3 Ag/4G2dngncmfu9cvT7oXPoV6X7ur+6m9O66WmceIf5WRJGX64NqOQHLkEsoHMu+M1dI+6DqwBIYb yaRbekhsXRxl9hGBUUJAKFVPuUBkeAuPTG0n0+Jq88Pld4R1DzMOekcf54H7hwSAPg99/HY+X5HtF wIM3cVcgw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fB2zc-00079E-OV; Tue, 24 Apr 2018 18:48:44 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 1A76D203BF9C7; Tue, 24 Apr 2018 20:48:43 +0200 (CEST) Date: Tue, 24 Apr 2018 20:48:43 +0200 From: Peter Zijlstra To: Mauro Carvalho Chehab Cc: Dan Carpenter , "Gustavo A. R. Silva" , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 01/11] media: tm6000: fix potential Spectre variant 1 Message-ID: <20180424184843.GX4043@hirez.programming.kicks-ass.net> References: <3d4973141e218fb516422d3d831742d55aaa5c04.1524499368.git.gustavo@embeddedor.com> <20180423152455.363d285c@vento.lan> <20180424093500.xvpcm3ibcu7adke2@mwanda> <20180424103609.GD4064@hirez.programming.kicks-ass.net> <20180424144755.1c2e2478@vento.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180424144755.1c2e2478@vento.lan> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 24, 2018 at 02:47:55PM -0300, Mauro Carvalho Chehab wrote: > So, I'm wondering if are there any way to mitigate it inside the > core itself, instead of doing it on every driver, e. g. changing > v4l_enum_fmt() implementation at v4l2-ioctl. > > Ok, a "poor man" approach would be to pass the array directly to > the core and let the implementation there to implement the array > fetch logic, calling array_index_nospec() there, but I wonder if > are there any other way that won't require too much code churn. Sadly no; the whole crux is the array bound check itself. You could maybe pass around the array size to the core code and then do something like: if (f->index >= f->array_size) return -EINVAL; f->index = nospec_array_index(f->index, f->array_size); in generic code, and have all the drivers use f->index as usual, but even that would be quite a bit of code churn I guess.