Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1335613imm; Thu, 23 Aug 2018 01:02:14 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZxiSrGYg4mUNBiR/H4+NTwPUdmwHtE5kEbplmGT5CMgzE6/QTp2hAIaVSL5fvtt0lHpVl5 X-Received: by 2002:a65:5189:: with SMTP id h9-v6mr4760763pgq.13.1535011334169; Thu, 23 Aug 2018 01:02:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535011334; cv=none; d=google.com; s=arc-20160816; b=B8yDolz4iwPq6tDjBej1ba1DLfYamMzyDz7NgGtjmo9Su+0pUHKCoCamqZOiMqUT70 3iyNnD1j6IJu9fXk+Zdi00AgKxecXiyhLx6zEKmKE0OQ8i9ss8km8w5S4d8PnsHlT1Hi JQU2Uv76yXVRqHq40go5w6p+1RdRLDRZgb92c4t0shnHimipsbllvrtG0BkD9r3r87YN DLY4KV1ESfvyF8VbWuKmnbU0tOYF/wbeZgG842qAsdRaGph2F5AutC4u7yKhSAmk1dH9 7I0P1C9VBmBcpW1jnAirsUHDW2l1vh0PI5FT9PJtzVdqLPIvV/S/mAcTIDtM6Sntf+C2 COqQ== 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=U0rxG/bscv1GEQjdV/zkOp2AP7e2SeljSZ7KLExgxPU=; b=gWDlENpJIB7pBDSi64HXfO2yXieoEuZsH7uNUt5FwQjUu7bc6in942eAdkykgrhh6w yuiesnuqFzzG8r5Zizt+s0mC8ZOhFV1V9H4L0bZwsBRTePsRMVgSOSISKAnl1HZggyDO hYti7CGhtVKcpTH2poGNo3NiFlmBrJwxjrDNOYW/jzF9F5aZCoBurPsA1bOc5j/IXY+8 VBMtODwprF95UWwwmtZBvrjHMRdWVAGxd3dAUftN1jcJZ4uSZ0z5R0p5ud6sJ4dEwrRV Yz1hczu/6Pt+G1DmYrZbFTmqPGWZoQe2w9mpRilTb8nmNA8G6/QL1LlM9TkWzWjerpsz qItg== 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 k193-v6si3697378pge.4.2018.08.23.01.01.58; Thu, 23 Aug 2018 01:02:14 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728689AbeHWL2k (ORCPT + 99 others); Thu, 23 Aug 2018 07:28:40 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43228 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728677AbeHWL2j (ORCPT ); Thu, 23 Aug 2018 07:28:39 -0400 Received: from localhost (5355525A.cm-6-6b.dynamic.ziggo.nl [83.85.82.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EFF28ACC; Thu, 23 Aug 2018 08:00:15 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josh Poimboeuf , Jeremy Cline , Theodore Tso Subject: [PATCH 4.4 68/79] ext4: fix spectre gadget in ext4_mb_regular_allocator() Date: Thu, 23 Aug 2018 09:53:44 +0200 Message-Id: <20180823074923.626051480@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180823074918.641878835@linuxfoundation.org> References: <20180823074918.641878835@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jeremy Cline commit 1a5d5e5d51e75a5bca67dadbcea8c841934b7b85 upstream. 'ac->ac_g_ex.fe_len' is a user-controlled value which is used in the derivation of 'ac->ac_2order'. 'ac->ac_2order', in turn, is used to index arrays which makes it a potential spectre gadget. Fix this by sanitizing the value assigned to 'ac->ac2_order'. This covers the following accesses found with the help of smatch: * fs/ext4/mballoc.c:1896 ext4_mb_simple_scan_group() warn: potential spectre issue 'grp->bb_counters' [w] (local cap) * fs/ext4/mballoc.c:445 mb_find_buddy() warn: potential spectre issue 'EXT4_SB(e4b->bd_sb)->s_mb_offsets' [r] (local cap) * fs/ext4/mballoc.c:446 mb_find_buddy() warn: potential spectre issue 'EXT4_SB(e4b->bd_sb)->s_mb_maxs' [r] (local cap) Suggested-by: Josh Poimboeuf Signed-off-by: Jeremy Cline Signed-off-by: Theodore Ts'o Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/mballoc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -2144,7 +2145,8 @@ ext4_mb_regular_allocator(struct ext4_al * This should tell if fe_len is exactly power of 2 */ if ((ac->ac_g_ex.fe_len & (~(1 << (i - 1)))) == 0) - ac->ac_2order = i - 1; + ac->ac_2order = array_index_nospec(i - 1, + sb->s_blocksize_bits + 2); } /* if stream allocation is enabled, use global goal */