Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3677898imu; Mon, 24 Dec 2018 06:41:33 -0800 (PST) X-Google-Smtp-Source: ALg8bN78vvb6bE5talGKTrslxbfoshhDEEsVOfKgsRzU8Ut0u1symbpNU/bQT6cF0JjN96ozzd3c X-Received: by 2002:a17:902:bd92:: with SMTP id q18mr13250952pls.167.1545662493154; Mon, 24 Dec 2018 06:41:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545662493; cv=none; d=google.com; s=arc-20160816; b=hh/jX2OD0icBEgGZ7NhIdr95OwbC71uGJb5SohEqnT/pufWwuG1O5ZB1X9xqTEzBcR d25nZvcqiTrdwnCRaC97Pf2JXcM0TJcOxBJeRD4vl5SDpNI4UaSsNlp/kowGmXU/txr2 LKnMak59CTV/8D1BHS2RUNccw+WifcU+uy6VfVOzmoteqvV4SDpAuBrwTXKPWtNG3YJ9 c7sCrHRhIkE6uihwtCRJFHbegdzqM+m4gs9RRqZnvUY735W4Q4C5HGSqF8YvZKJ29m8y lAb0/by2kne1j9vBe3HnA+ylhRoTnlZDbpCUQC2Ngmkq7Ij9pCrpDanoK2yYkx0Nx2pP 0KOQ== 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; bh=v4OHpWESPR164irYocQK6fY/AYz7cBTOjf+M/A7kqfc=; b=Z2TSs345Uv0aPm2ysYY6RI08q/gZynQEPombxpgrCr0dRkHDyJfMF56PtxD1LN567L /yi1JyDHwyQg+YXE1ATh+FtU26v+HeaxMyvctVWLY6Vq08wbFyalYYyUC7slslMETMIR 2hJYLZD5q0sgTf1+eAIcfX2xOFpH6wyaocFDiLwZahVp1yfmto788qWgAzcunO9BDs8Q qQ9HQ4jZrDP+ovFiCZ87rpoXs7w6gkw+nuOnoCOTGohqbk5LAKWKz68sI15L2PyT1e08 hoMHa81tVcQeSnyhe3QuMkFL0IcvKceEaaMMQktSe/PrrGiOQDs5yVVFDdabQsAL+g7E WRSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=jh8+OdWx; 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 r1si8953501plb.330.2018.12.24.06.41.17; Mon, 24 Dec 2018 06:41:33 -0800 (PST) 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=jh8+OdWx; 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 S1726009AbeLXOk1 (ORCPT + 99 others); Mon, 24 Dec 2018 09:40:27 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:43554 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725554AbeLXOk1 (ORCPT ); Mon, 24 Dec 2018 09:40:27 -0500 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=v4OHpWESPR164irYocQK6fY/AYz7cBTOjf+M/A7kqfc=; b=jh8+OdWxWoTS5QRW0xdl2L1JT EjNZTLznDrjhazbcwdHKVp2nZF6ZwHbbqS7Ck0oThTVNfsN76DqEhjpwo0APYfyawq8RxHnO6gi22 mQMwwfAiHao/E0R8XaOJtA6AacgrOgGhf29EMKo1HcYNrd+FxWSqzvyffQuJHjiGcv9CcMIhk4D4o 9tr5/dciDRC/NmPejykl5SCat1mo14oGj0bqEIcK+1h2fM9j/Fseiu69JPj3KcQtGoBpjekcNIL05 WdOX29KX/sIxqtYPXGR2cMLZjhhbtXDODCT/bjERMIhtSfisr6uo9dVy9+TTmMmlQ4uGL1CsLyAus ExvLaQF+A==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gbRP4-0004vp-3m; Mon, 24 Dec 2018 14:40:22 +0000 Date: Mon, 24 Dec 2018 06:40:21 -0800 From: Matthew Wilcox To: Greg Hackmann Cc: Alexander Viro , Omer Tripp , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, stable@vger.kernel.org Subject: Re: [PATCH v2] fs: fix possible Spectre V1 indexing in __close_fd() Message-ID: <20181224144021.GN10600@bombadil.infradead.org> References: <20181224142642.7385-1-ghackmann@android.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181224142642.7385-1-ghackmann@android.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 24, 2018 at 06:26:42AM -0800, Greg Hackmann wrote: > +++ b/fs/file.c > @@ -18,6 +18,7 @@ > #include > #include > #include > +#include > > unsigned int sysctl_nr_open __read_mostly = 1024*1024; > unsigned int sysctl_nr_open_min = BITS_PER_LONG; > @@ -626,6 +627,7 @@ int __close_fd(struct files_struct *files, unsigned fd) > fdt = files_fdtable(files); > if (fd >= fdt->max_fds) > goto out_unlock; > + fd = array_index_nospec(fd, fdt->max_fds); > file = fdt->fd[fd]; > if (!file) > goto out_unlock; This is insufficient. do_dup2() has a similar problem.