Received: by 10.223.176.5 with SMTP id f5csp2858314wra; Mon, 5 Feb 2018 11:04:12 -0800 (PST) X-Google-Smtp-Source: AH8x224BuDNjv8G/wT70FEq/X1vn+oQbZD+0xlKZMbhleJWM5399u+nydIFlpvU8rIgqz80ShfJE X-Received: by 2002:a17:902:15a8:: with SMTP id m37-v6mr20766690pla.186.1517857452836; Mon, 05 Feb 2018 11:04:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517857452; cv=none; d=google.com; s=arc-20160816; b=bRnlrcIWfFSmpbuy4CeXKowXeXjm1cZYucWO7kdbZehfep92WuFb0JQRfRCQnYwTt5 cESzLW0RNDhYvqklhID1f70Xs3bGrND/r0ZOZ5obpXFps7oEkOzjszPweWYjC3QJEz4J 0GYvcyJGqYGXcCtWVqyE5kA/itR2ie+iZ4gP9MiRdYUn5uum9Z7XrF+3yjG9S9da473l 4MbmsNYdT3zaIFSirkzjTI0FRlvYwptnXre7M8rk0lHh1vqhg/svoMzw9WfokOcJkeX8 mU8nxzhzMuX/yzODHAdDD/M4ZvmVb2gUVk72pJkR8Lyzrhc+n2kyVfNM4YKY9Y5isYcK 42mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=kKhKOSRAGTEduYDqevxQ6blkPRq46uEfRph7UuT/UHs=; b=L1/G6DJg1Y+WoaOa9v2WPua4Bc1jApMatzscj1s6L6alHSUyF+NqUnO82WJ6vPQQf4 K4jqcfiev7HBGxrbXurQI6W8mEV/I3bbhdc43uvYR0gFzxmgIboRA+xJQBk/7mUrkIaN +21Lw6RqZ2OuKCJN+UxKH078e4LQV0U093Ofu1r/a2bzJqsXWgJXbwoJoSYwnlHZeCtJ OKlg7fYsQubpMgjTWmrBw2XTgan4WyXQ7QKOmj3TUA5tFr9oDu91RdeQ3tRub1w/eiMw kc2uGJf5MIvPbPK8nHWOSy2i/HfGEmoZ8twhremhZ76g4pQOzAaGXKqLHZ80fkDiRVBW /HWw== ARC-Authentication-Results: i=1; mx.google.com; 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 p78si184260pfk.233.2018.02.05.11.03.58; Mon, 05 Feb 2018 11:04:12 -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; 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 S1753893AbeBETDn (ORCPT + 99 others); Mon, 5 Feb 2018 14:03:43 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:51448 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753518AbeBESYR (ORCPT ); Mon, 5 Feb 2018 13:24:17 -0500 Received: from localhost (unknown [104.132.1.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 2F95D1010; Mon, 5 Feb 2018 18:24:13 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Williams , Thomas Gleixner , linux-arch@vger.kernel.org, kernel-hardening@lists.openwall.com, Al Viro , torvalds@linux-foundation.org, alan@linux.intel.com Subject: [PATCH 4.14 45/64] vfs, fdtable: Prevent bounds-check bypass via speculative execution Date: Mon, 5 Feb 2018 10:23:04 -0800 Message-Id: <20180205182140.422732097@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180205182138.571333346@linuxfoundation.org> References: <20180205182138.571333346@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Williams dan.j.williams@intel.com 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 Signed-off-by: Dan Williams Signed-off-by: Thomas Gleixner Cc: linux-arch@vger.kernel.org Cc: kernel-hardening@lists.openwall.com Cc: gregkh@linuxfoundation.org Cc: Al Viro 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: Greg Kroah-Hartman --- include/linux/fdtable.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/include/linux/fdtable.h +++ b/include/linux/fdtable.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -82,8 +83,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; }