From: Dan Williams <dan.j.williams@intel.com>
To: linux-kernel@vger.kernel.org
Cc: linux-arch@vger.kernel.org, kernel-hardening@lists.openwall.com,
gregkh@linuxfoundation.org, Al Viro <viro@zeniv.linux.org.uk>,
tglx@linutronix.de, torvalds@linux-foundation.org,
akpm@linux-foundation.org, alan@linux.intel.com
Subject: [PATCH v3 9/9] vfs, fdtable: prevent bounds-check bypass via speculative execution
Date: Sat, 13 Jan 2018 10:18:16 -0800 [thread overview]
Message-ID: <151586749581.5820.10884753209923259828.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <151586744180.5820.13215059696964205856.stgit@dwillia2-desk3.amr.corp.intel.com>
Expectedly, static analysis reports that '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.
Cc: Al Viro <viro@zeniv.linux.org.uk>
Co-developed-by: Elena Reshetova <elena.reshetova@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
include/linux/fdtable.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
index 1c65817673db..9731f1a255db 100644
--- a/include/linux/fdtable.h
+++ b/include/linux/fdtable.h
@@ -10,6 +10,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,9 +82,11 @@ struct dentry;
static inline struct file *__fcheck_files(struct files_struct *files, unsigned int fd)
{
struct fdtable *fdt = rcu_dereference_raw(files->fdt);
+ struct file __rcu **fdp;
- if (fd < fdt->max_fds)
- return rcu_dereference_raw(fdt->fd[fd]);
+ fdp = array_ptr(fdt->fd, fd, fdt->max_fds);
+ if (fdp)
+ return rcu_dereference_raw(*fdp);
return NULL;
}
prev parent reply other threads:[~2018-01-13 18:26 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-13 18:17 [PATCH v3 0/9] core, x86: prevent bounds-check bypass via speculative execution Dan Williams
2018-01-13 18:17 ` [PATCH v3 1/9] Documentation: document array_ptr Dan Williams
2018-01-13 18:17 ` [PATCH v3 2/9] arm64: implement ifence_array_ptr() Dan Williams
2018-01-13 18:17 ` [PATCH v3 3/9] arm: " Dan Williams
2018-01-13 18:17 ` [PATCH v3 4/9] x86: implement ifence() Dan Williams
2018-01-13 18:17 ` [PATCH v3 5/9] x86: implement ifence_array_ptr() and array_ptr_mask() Dan Williams
2018-01-13 18:17 ` [PATCH v3 6/9] asm/nospec: mask speculative execution flows Dan Williams
2018-01-13 18:18 ` [PATCH v3 7/9] x86: introduce __uaccess_begin_nospec and ASM_IFENCE Dan Williams
2018-01-13 18:18 ` [PATCH v3 8/9] x86: use __uaccess_begin_nospec and ASM_IFENCE in get_user paths Dan Williams
2018-01-13 19:05 ` Linus Torvalds
2018-01-13 19:33 ` Linus Torvalds
2018-01-13 20:22 ` Eric W. Biederman
2018-01-16 22:23 ` Dan Williams
[not found] ` <CA+55aFxAFG5czVmCyhYMyHmXLNJ7pcXxWzusjZvLRh_qTGHj6Q@mail.gmail.com>
2018-01-16 22:41 ` Linus Torvalds
2018-01-17 14:17 ` Alan Cox
2018-01-17 18:52 ` Al Viro
2018-01-17 19:54 ` Dan Williams
2018-01-17 20:05 ` Al Viro
2018-01-17 20:14 ` Dan Williams
2018-01-18 3:06 ` [RFC][PATCH] get rid of the use of set_fs() (by way of kernel_recvmsg()) in sunrpc Al Viro
2018-01-18 3:16 ` Linus Torvalds
2018-01-18 4:43 ` Al Viro
2018-01-18 16:29 ` Christoph Hellwig
2018-01-18 17:10 ` Al Viro
2018-01-18 19:31 ` Al Viro
2018-01-18 19:37 ` [PATCH 01/10] net: separate SIOCGIFCONF handling from dev_ioctl() Al Viro
2018-01-18 19:37 ` [PATCH 02/10] devinet_ioctl(): take copyin/copyout to caller Al Viro
2018-01-22 16:40 ` Christoph Hellwig
2018-01-18 19:37 ` [PATCH 03/10] ip_rt_ioctl(): take copyin " Al Viro
2018-01-22 16:43 ` Christoph Hellwig
2018-01-18 19:37 ` [PATCH 04/10] kill dev_ifsioc() Al Viro
2018-01-22 16:47 ` Christoph Hellwig
2018-01-18 19:37 ` [PATCH 05/10] kill bond_ioctl() Al Viro
2018-01-22 16:48 ` Christoph Hellwig
2018-01-18 19:37 ` [PATCH 06/10] kill dev_ifname32() Al Viro
2018-01-18 19:37 ` [PATCH 07/10] lift handling of SIOCIW... out of dev_ioctl() Al Viro
2018-01-18 19:37 ` [PATCH 08/10] ipconfig: use dev_set_mtu() Al Viro
2018-01-18 19:37 ` [PATCH 09/10] dev_ioctl(): move copyin/copyout to callers Al Viro
2018-01-18 19:37 ` [PATCH 10/10] kill kernel_sock_ioctl() Al Viro
2018-01-22 16:49 ` Christoph Hellwig
2018-01-24 20:52 ` David Miller
2018-01-25 0:01 ` Al Viro
2018-01-25 0:21 ` Al Viro
2018-01-25 4:11 ` David Miller
2018-01-22 16:40 ` [PATCH 01/10] net: separate SIOCGIFCONF handling from dev_ioctl() Christoph Hellwig
2018-01-18 20:33 ` [RFC][PATCH] get rid of the use of set_fs() (by way of kernel_recvmsg()) in sunrpc Al Viro
2018-01-19 3:27 ` Al Viro
2018-01-17 19:26 ` [PATCH v3 8/9] x86: use __uaccess_begin_nospec and ASM_IFENCE in get_user paths Linus Torvalds
2018-01-17 20:01 ` Eric Dumazet
2018-01-18 16:38 ` Christoph Hellwig
2018-01-18 16:49 ` Linus Torvalds
2018-01-18 18:12 ` Al Viro
2018-01-17 4:30 ` Dan Williams
2018-01-17 6:28 ` Al Viro
2018-01-17 6:50 ` Dan Williams
2018-01-17 10:07 ` David Laight
2018-01-17 18:12 ` Dan Williams
2018-01-17 19:16 ` Linus Torvalds
2018-01-13 18:18 ` Dan Williams [this message]
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=151586749581.5820.10884753209923259828.stgit@dwillia2-desk3.amr.corp.intel.com \
--to=dan.j.williams@intel.com \
--cc=akpm@linux-foundation.org \
--cc=alan@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@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).