Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp994721imm; Fri, 27 Jul 2018 09:26:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpewvzer9guSmwZhXy+TOb2KhQTmHKTQlsyjoTGFHtehoYSoCsZzOXe4FLTyMdUlsxV1xMk/ X-Received: by 2002:a62:c98e:: with SMTP id l14-v6mr7323964pfk.10.1532708782717; Fri, 27 Jul 2018 09:26:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532708782; cv=none; d=google.com; s=arc-20160816; b=QndmnUqL3TgRugA9EwS7tO+kIh+MvauGs8VlaV63qpPWQVRTSLBU4pFSc/IujVCAxP 0M2lj5h1cgg0/wdZASBYIvWGsZmIiE1HPCN2FqlZBdsYggMMFqFBuLI9nMyzFQOx5oRS KhZ1mOaHZ+7wYMSoPwM2bNEwnpiBCrxGglRBKXVKybw/Z6FwDJaDLbGxFOLdmVl9a3HO 0fUys8Em8xc7rp2CD+N3Srq9HolOU4ZCBiP6EdVGVP+VdVUnu/g+/gMHx9FxPIh6Il3x kfaREig4s/oI810zdZMT3elMAkXar0Gjx9XguTopAD6Kd3LzAzvz6BA3F7+sqXB4lWaB lRkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=cr6pNW+fjS1yKdZySX4mrSYdRIKPWpKsxQDEMcRYIAI=; b=JUpnh6g2iio8M/ExiljealD5eQ/EmV7MQnM6KX3muhrLFUZD1K+7bq/ymOGr1k9hUG +g17O8M/shtN94IfGvviFCUu04/D/PG6bflVB7PcL/1hASURCGr7QHjcVas+JIosDwBJ ep5oOfRNcIK5FlLiGuatZAUco50qVM+/TOGONZRVDAu7FUIxbWDUL0CfTRHvf9VrVSPf XZvXoYu/IG+HGxMBbW7LMsm4L3g46RxRJPvjKyXI/EjcbudSGDb28tJBcVwS1Rg4mMlL WgQvg15o3UEXt/bZHgqQh3vTiVHgi2vKnCdg1Y0l13qaHXIJDNfjCGWe/5uQczXWJLab Ku6w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m10-v6si3667674pgv.374.2018.07.27.09.26.08; Fri, 27 Jul 2018 09:26:22 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388708AbeG0Rrx (ORCPT + 99 others); Fri, 27 Jul 2018 13:47:53 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:37322 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730771AbeG0Rrw (ORCPT ); Fri, 27 Jul 2018 13:47:52 -0400 Received: by mail-qk0-f196.google.com with SMTP id t79-v6so3644992qke.4 for ; Fri, 27 Jul 2018 09:25:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cr6pNW+fjS1yKdZySX4mrSYdRIKPWpKsxQDEMcRYIAI=; b=Ghb9PEUpMVpcQAfQ/HMlXb6ncuLoBOAwVHQo+D6Bz6AnZRMJudPjyJAspXRfnylHSX 88wgTFsCIzR/Sy0xiDuiOBzHNJkAed8AajY7ZO7kWKP6i/SpA8GnrDsJ4Q2w0yDo3Yqw gMYfV+KmqJcUunbXsVb0RxgL1d6vlKDJEIyaCb+DLkyjBp6tvnjW7O/eRP1XkjjINFFM pgi/HKldTHDvqedIIAMytf9dyyRfCXCovKvZ5P8+FYZK8fe/hKvVNJ1LerYegsVyinFM rqS4DtmRwQCTh4m4Bmqjlj1+dnTv35IYip+oAxCPIjQq2f7WWsaJlMYoalUcjCxxXZNR iHlQ== X-Gm-Message-State: AOUpUlFOy5r/W1QMPhbn872Ml7q9bQMGF+4/qtGbexQHZnbHwRmjFMKC UbGeC0dC4/n+h6Eup1h76TWG/A== X-Received: by 2002:ae9:e118:: with SMTP id g24-v6mr6392752qkm.306.1532708714744; Fri, 27 Jul 2018 09:25:14 -0700 (PDT) Received: from builder.jcline.org.com ([2605:a601:80ce:4700:77a5:8983:ea8b:82ec]) by smtp.gmail.com with ESMTPSA id s73-v6sm3137342qkl.65.2018.07.27.09.25.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Jul 2018 09:25:14 -0700 (PDT) From: Jeremy Cline To: Theodore Ts'o , Andreas Dilger Cc: Josh Poimboeuf , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, Jeremy Cline , stable@vger.kernel.org Subject: [PATCH 1/3] ext4: super: Fix spectre gadget in ext4_quota_on Date: Fri, 27 Jul 2018 16:23:55 +0000 Message-Id: <20180727162357.30801-2-jcline@redhat.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180727162357.30801-1-jcline@redhat.com> References: <20180727162357.30801-1-jcline@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'type' is a user-controlled value used to index into 's_qf_names', which can be used in a Spectre v1 attack. Clamp 'type' to the size of the array to avoid a speculative out-of-bounds read. Cc: Josh Poimboeuf Cc: stable@vger.kernel.org Signed-off-by: Jeremy Cline --- fs/ext4/super.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 6480e763080f..c04a09b51742 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -5559,6 +5560,7 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id, if (path->dentry->d_sb != sb) return -EXDEV; /* Journaling quota? */ + type = array_index_nospec(type, EXT4_MAXQUOTAS); if (EXT4_SB(sb)->s_qf_names[type]) { /* Quotafile not in fs root? */ if (path->dentry->d_parent != sb->s_root) -- 2.17.1