Received: by 10.223.176.5 with SMTP id f5csp715969wra; Fri, 9 Feb 2018 06:08:29 -0800 (PST) X-Google-Smtp-Source: AH8x224eWepYEsiSZsn6OZrCbdbGmpME5nsqV8YJKtS8h5kqVMS8JN5xDJq7HA0NVeDQyp8fFW0T X-Received: by 10.99.177.4 with SMTP id r4mr2472884pgf.245.1518185308955; Fri, 09 Feb 2018 06:08:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518185308; cv=none; d=google.com; s=arc-20160816; b=0/1GXN4SRfFQXVdNrfUtnIioMpVYOEEIgpy48UeEHgO4J0y4zp8GHC0IPxe9nmGx/X tT7juCHwFMBp45Low0tIum7S++TGCpdmKw3g4k+hdX5x9UQJSQJ9w2Viy6bmX5msHEVh FDtMw9QwJvhfrCf/AFoCsg4mK0ONrJDqMcRdjDGTEpuAsx2MR4qqB6Egb6Yap04OsL5h 04+6IGuNTH96gvLfZloqM0Yrc+TiU30f9+i7C71YwJONE39CF2GuKc7uYjejS71TUXUb /b5AF27R0QQ0heLxQIFs5PN0e4szFlmjOvkuoDByuqmS84xGvZW6BlqGuyp7536dUdP9 cvRg== 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=ph60OCZ3mNiy1CjEvXcVax7T5/iKIyAlhvE5FetkF3s=; b=btlss/ULkWYOhyacTHPztWHfFVnyNyZZtlJ0qpf/9VKqYTzkeVjh4XQ2yf/mKll0XF NQqj4WCkPEXePZnd3zJ4d0GbEpqb9sMv/nLWsSDJthymbSVjftzey9RgheFgi54GGwWs rMxV4DCdeIuUltJa4A9z9ot3rM+ynoSAYmp2raP0gZj7+7oaIKSaPWXU9gNbagFYpMc1 lxkAXV9RahV3SoUSMFRcM/zEzRL87QUiq7eI/xSMqkQD0xGrOd/H8zZ2oaqYQGc6V33f k2rggT/VnihlodIeIKKLx+ym6LLVwsQen6kP6q0YxBYZaJrbKn/C/KExzNMO3ogiexDs P0KA== 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 y2si1413729pgv.493.2018.02.09.06.08.10; Fri, 09 Feb 2018 06:08:28 -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 S1753238AbeBINnf (ORCPT + 99 others); Fri, 9 Feb 2018 08:43:35 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:50836 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752184AbeBINnd (ORCPT ); Fri, 9 Feb 2018 08:43:33 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 6B3831056; Fri, 9 Feb 2018 13:43:12 +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, David Woodhouse Subject: [PATCH 4.9 65/92] vfs, fdtable: Prevent bounds-check bypass via speculative execution Date: Fri, 9 Feb 2018 14:39:34 +0100 Message-Id: <20180209133935.948520836@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180209133931.211869118@linuxfoundation.org> References: <20180209133931.211869118@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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Williams (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 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: David Woodhouse 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 @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -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; }