linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Greg Hackmann <ghackmann@android.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	Omer Tripp <trippo@google.com>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Greg Hackmann <ghackmann@google.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] fs: fix possible Spectre V1 indexing in __close_fd()
Date: Mon, 24 Sep 2018 20:39:11 +0200	[thread overview]
Message-ID: <20180924183911.GB9122@kroah.com> (raw)
In-Reply-To: <20180924181500.125257-1-ghackmann@google.com>

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 <trippo@google.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Greg Hackmann <ghackmann@google.com>
> ---
>  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 <linux/bitops.h>
>  #include <linux/spinlock.h>
>  #include <linux/rcupdate.h>
> +#include <linux/nospec.h>
>  
>  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 :)

thanks,

greg k-h

  reply	other threads:[~2018-09-25  0:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-24 18:15 [PATCH] fs: fix possible Spectre V1 indexing in __close_fd() Greg Hackmann
2018-09-24 18:39 ` Greg KH [this message]
2018-10-15 13:37   ` Greg KH
     [not found]     ` <CALTzUognuG-N4M5w9xugxF7KZjUxF_9O32fKoUt2v7st70ppmw@mail.gmail.com>
2018-12-19  7:11       ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180924183911.GB9122@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=ghackmann@android.com \
    --cc=ghackmann@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=trippo@google.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).