Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3935569imm; Mon, 15 Oct 2018 06:37:49 -0700 (PDT) X-Google-Smtp-Source: ACcGV63gzp0ueh07Dxn0Fb/6/G0MMrA9X+l76SPRQluJImwhaH8VsVrcbkJHRDTpvSqvJmf/jhHy X-Received: by 2002:a62:52cc:: with SMTP id g195-v6mr18029088pfb.241.1539610669460; Mon, 15 Oct 2018 06:37:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539610669; cv=none; d=google.com; s=arc-20160816; b=mbHazgTg6Kwx/2JpgKxtLlPSfbgEFpnMSHtfAzaIbA3TamY78aUsVDdUGjp3itCh/O bV6grMhQpq4DB/le7mEcmnolDegD69nRLV4WaGcCRQYqi8cB7H/lHdqjh4xeQJbQy00c tQ7aWIBjqASYpQiKOEQI5wQVBB29dju2QBg67H3+GWUHL8GOKfNQcjetx5Ag7IMr2zfj b27vNHDp73NALf4ntGcG3EJpreKcIEX4KN6TRa28017w6YNQMxb9nvvpXTv/Pr+/PduQ g8bCGhF7yIfmX42AYC2t3WeGZyvgKvH9OxbED0b35J9gygScDYJasdRrukXFczPdEmHO eHYA== 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=h7rKGdaCD0M8ML/6S7mkkeXD23xXmpn1zesNEw+edDI=; b=bxvDUNBJesLzlAqLDGJqh88HWPTWA1FvLs/MEf0sZiff1qLQSHLI0fdWwijmpz9jEN vAde250XhkvrxVPhJy09rlZDHeKbiufskZhOyk65hpaXM7aDr7mazLdLIOQrdGhPzYww v/nUv6SzjphnWipcZlbjowFxSBYnxf/ZWGSgwdLq+DaNsWBjJOD2dyFb1voX3yuzep/D Fyfa9rAq0IQynoUX69Kox//zkoRlQ875V68J0MCoCaFm64SzdBiOIp+i/ht6n6UCWp9K GonJf4YaP7jOcGaad51qhi9QZsoZpP5UxmJVt0e9GAKtyENBs1MBjEBKk6NGMjUNl9aB A2dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pgZ0567u; 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 p21-v6si10592385pgi.199.2018.10.15.06.37.33; Mon, 15 Oct 2018 06:37:49 -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=pass header.i=@kernel.org header.s=default header.b=pgZ0567u; 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 S1726597AbeJOVWb (ORCPT + 99 others); Mon, 15 Oct 2018 17:22:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:49172 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726400AbeJOVWb (ORCPT ); Mon, 15 Oct 2018 17:22:31 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 61DC12083C; Mon, 15 Oct 2018 13:37:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539610630; bh=luBqaKrH8bOkY9gwtjpvF27Qqm4pHYhvI+wow+2/M5E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pgZ0567ueo+qDcbFoqKG+41TvB9l82Qq20wnn5HzDd7GyP2gdvZw9YtoT9se8NvjI owB9ai8MMeLxB+L9l5eSENT/smCERmu47FumPHjU4F0FTJHvCdgWeby+V6EM9y1lj7 dVgW67JT3ajVdUN6Ya9hQ01SUxX/j1fAHdJJIMxo= Date: Mon, 15 Oct 2018 15:37:08 +0200 From: Greg KH To: Greg Hackmann Cc: Alexander Viro , Omer Tripp , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Hackmann , stable@vger.kernel.org Subject: Re: [PATCH] fs: fix possible Spectre V1 indexing in __close_fd() Message-ID: <20181015133708.GB10221@kroah.com> References: <20180924181500.125257-1-ghackmann@google.com> <20180924183911.GB9122@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180924183911.GB9122@kroah.com> 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 Mon, Sep 24, 2018 at 08:39:11PM +0200, Greg KH wrote: > On Mon, Sep 24, 2018 at 11:15:00AM -0700, Greg Hackmann wrote: > > __close_fd() is reachable via the close() syscall with a > > userspace-controlled fd. Ensure that it can't be used to speculatively > > access past the end of current->fdt. > > > > Reported-by: Omer Tripp > > Cc: stable@vger.kernel.org > > Signed-off-by: Greg Hackmann > > --- > > fs/file.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/fs/file.c b/fs/file.c > > index 7ffd6e9d103d..a80cf82be96b 100644 > > --- a/fs/file.c > > +++ 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]; > > Don't you need 2 "halfs" of a gadget in order to make it work? This is > one half, where is the second half? > > Or am I reading this code wrong here somehow? > > We don't want to play whack-a-mole with only 1/2 spectre gadgets, > otherwise the 700+ patches that Red Hat added to their kernel would have > been merged already. > > Which reminds me, did the Red Hat tooling catch this one as well? If > not, someone need to go fix it :) Ping?