linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Dan Williams <dan.j.williams@intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-arch@vger.kernel.org, kernel-hardening@lists.openwall.com,
	Al Viro <viro@zeniv.linux.org.uk>,
	torvalds@linux-foundation.org, alan@linux.intel.com,
	David Woodhouse <dwmw@amazon.co.uk>
Subject: [PATCH 4.9 65/92] vfs, fdtable: Prevent bounds-check bypass via speculative execution
Date: Fri,  9 Feb 2018 14:39:34 +0100	[thread overview]
Message-ID: <20180209133935.948520836@linuxfoundation.org> (raw)
In-Reply-To: <20180209133931.211869118@linuxfoundation.org>

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Dan Williams <dan.j.williams@intel.com>


(cherry picked from commit 56c30ba7b348b90484969054d561f711ba196507)

'fd' is a user controlled value that is used as a data dependency to
read from the 'fdt->fd' array.  In order to avoid potential leaks of
kernel memory values, block speculative execution of the instruction
stream that could issue reads based on an invalid 'file *' returned from
__fcheck_files.

Co-developed-by: Elena Reshetova <elena.reshetova@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-arch@vger.kernel.org
Cc: kernel-hardening@lists.openwall.com
Cc: gregkh@linuxfoundation.org
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: torvalds@linux-foundation.org
Cc: alan@linux.intel.com
Link: https://lkml.kernel.org/r/151727418500.33451.17392199002892248656.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 include/linux/fdtable.h |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/include/linux/fdtable.h
+++ b/include/linux/fdtable.h
@@ -9,6 +9,7 @@
 #include <linux/compiler.h>
 #include <linux/spinlock.h>
 #include <linux/rcupdate.h>
+#include <linux/nospec.h>
 #include <linux/types.h>
 #include <linux/init.h>
 #include <linux/fs.h>
@@ -81,8 +82,10 @@ static inline struct file *__fcheck_file
 {
 	struct fdtable *fdt = rcu_dereference_raw(files->fdt);
 
-	if (fd < fdt->max_fds)
+	if (fd < fdt->max_fds) {
+		fd = array_index_nospec(fd, fdt->max_fds);
 		return rcu_dereference_raw(fdt->fd[fd]);
+	}
 	return NULL;
 }
 

  parent reply	other threads:[~2018-02-09 13:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20180209133931.211869118@linuxfoundation.org>
2018-02-09 13:39 ` [PATCH 4.9 56/92] Documentation: Document array_index_nospec Greg Kroah-Hartman
2018-02-09 13:39   ` Greg Kroah-Hartman
2018-02-09 13:39 ` [PATCH 4.9 57/92] array_index_nospec: Sanitize speculative array de-references Greg Kroah-Hartman
2018-02-09 13:39   ` Greg Kroah-Hartman
2018-02-09 13:39 ` [PATCH 4.9 58/92] x86: Implement array_index_mask_nospec Greg Kroah-Hartman
2018-02-09 13:39   ` Greg Kroah-Hartman
2018-02-09 13:39 ` [PATCH 4.9 59/92] x86: Introduce barrier_nospec Greg Kroah-Hartman
2018-02-09 13:39   ` Greg Kroah-Hartman
2018-02-09 13:39 ` [PATCH 4.9 60/92] x86: Introduce __uaccess_begin_nospec() and uaccess_try_nospec Greg Kroah-Hartman
2018-02-09 13:39   ` Greg Kroah-Hartman
2018-02-09 13:39 ` [PATCH 4.9 61/92] x86/usercopy: Replace open coded stac/clac with __uaccess_{begin, end} Greg Kroah-Hartman
2018-02-09 13:39   ` Greg Kroah-Hartman
2018-02-09 13:39 ` [PATCH 4.9 62/92] x86/uaccess: Use __uaccess_begin_nospec() and uaccess_try_nospec Greg Kroah-Hartman
2018-02-09 13:39   ` Greg Kroah-Hartman
2018-02-09 13:39 ` [PATCH 4.9 63/92] x86/get_user: Use pointer masking to limit speculation Greg Kroah-Hartman
2018-02-09 13:39   ` Greg Kroah-Hartman
2018-02-09 13:39 ` [PATCH 4.9 64/92] x86/syscall: Sanitize syscall table de-references under speculation Greg Kroah-Hartman
2018-02-09 13:39 ` Greg Kroah-Hartman [this message]
2018-02-09 13:39   ` [PATCH 4.9 65/92] vfs, fdtable: Prevent bounds-check bypass via speculative execution Greg Kroah-Hartman
2018-02-09 13:39 ` [PATCH 4.9 66/92] nl80211: Sanitize array index in parse_txq_params Greg Kroah-Hartman
2018-02-09 13:39   ` Greg Kroah-Hartman
2018-02-09 13:39 ` [PATCH 4.9 67/92] x86/spectre: Report get_user mitigation for spectre_v1 Greg Kroah-Hartman
2018-02-09 13:39   ` Greg Kroah-Hartman

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=20180209133935.948520836@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=alan@linux.intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dwmw@amazon.co.uk \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --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).