Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp565741imu; Thu, 20 Dec 2018 01:28:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/WbqTcXgpWIT+GWifSJlyZjmZX9C2UQbZ1i1yxSQpviVooQ+11rx4IPJ1wf7ORnzfcDYo7t X-Received: by 2002:a63:b30f:: with SMTP id i15mr22453298pgf.240.1545298108885; Thu, 20 Dec 2018 01:28:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545298108; cv=none; d=google.com; s=arc-20160816; b=JkctDEBD17K7eHCdvubOVkvZmCIKKZb0u286xTuSGRgp7k7PiS2n9+d0s5Std7tgiN oDvUM6tN3IZEMtgaVRp3Yxdz4wA1htVsM2BYN6t2zlb41WRgct/nUqzNavogaqsarNLh 3jMnjtcEIitK1owXPwb0BFwSmE/o9ZogZQS4cTd6n8Y29l7IeH6PYsk82uuT/GPnzWX4 ZYuM28IW3o1fsauXjXv5aP01MAl4mhgpiHBY5s9CgTxTgsm2mi2qANlVuF0tKlDYl2Zc l2nXhWbHremSPeR+jWRrxrtya6sUm/xuaYPlTaDpfkS+q5r3SU1/sD7vtWGMd9YmXgOO BgBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e8byLLM3gMuT4XZ5/PHxNHB1ByIurs2x1XqH4YlBaYo=; b=wUq4J0IzXqGnEvr8UD/YKkWuWnytV9hJf9Tdf6Bb996j64HctIGyefcEHiWxUW74oC 1TIL4mHtfF86Linvybx6ygpnveVxO8r+hQA5i/5Sh4l8jLwP06f2Dbs9w68dUarv8oGj kCOrbbZYS0LXF3CCb9xX+XGjw0dPwLq81UeGopTjEOWV6H7uEJd/5DQnuEcmQzDFX99a EL7XiGn8u7tw9oxxuCJNr+GmdU9Pt4TH9oytp7AO6FSpEgXfHwsfG4onC0XPnvlorxjy eBFgt8jLMUrmPoaVfNYccQzKsVckglj2duEjHzILhD+C8IdvEMyl1mjd1EVwbI0OsL4E eYoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lMcXrFRP; 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 l185si1400520pgd.253.2018.12.20.01.28.13; Thu, 20 Dec 2018 01:28: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; dkim=pass header.i=@kernel.org header.s=default header.b=lMcXrFRP; 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 S1732098AbeLTJ0Y (ORCPT + 99 others); Thu, 20 Dec 2018 04:26:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:53758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727975AbeLTJ0U (ORCPT ); Thu, 20 Dec 2018 04:26:20 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7CD94217D7; Thu, 20 Dec 2018 09:26:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545297980; bh=Mxsrg5jxB1Y5EARs5rs7k6yTbcurh4dlZH+CTqckDAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lMcXrFRPV9oTanA+rnMsdjCMqYDIfyoY/gGrDl2lfuO8Y/mk1PG5vo71Jd2SjBHro ifS6bk/kuGBq4RXMW7m7pZI3Uz3sW1mguhWQINSv1cnhy/hBXnshRrrfxn3TH0lipx MOFSOyYc+K3tpbrdYbHwfuxGCxlPZRYurQpT1HJo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthew Wilcox , Dan Carpenter , Jeff Moyer , Jens Axboe Subject: [PATCH 4.14 03/72] aio: fix spectre gadget in lookup_ioctx Date: Thu, 20 Dec 2018 10:18:02 +0100 Message-Id: <20181220085922.464426676@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20181220085922.332225035@linuxfoundation.org> References: <20181220085922.332225035@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Jeff Moyer commit a538e3ff9dabcdf6c3f477a373c629213d1c3066 upstream. Matthew pointed out that the ioctx_table is susceptible to spectre v1, because the index can be controlled by an attacker. The below patch should mitigate the attack for all of the aio system calls. Cc: stable@vger.kernel.org Reported-by: Matthew Wilcox Reported-by: Dan Carpenter Signed-off-by: Jeff Moyer Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/aio.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/aio.c +++ b/fs/aio.c @@ -43,6 +43,7 @@ #include #include +#include #include "internal.h" @@ -1084,6 +1085,7 @@ static struct kioctx *lookup_ioctx(unsig if (!table || id >= table->nr) goto out; + id = array_index_nospec(id, table->nr); ctx = rcu_dereference(table->table[id]); if (ctx && ctx->user_id == ctx_id) { if (percpu_ref_tryget_live(&ctx->users))