Received: by 10.223.185.116 with SMTP id b49csp3995321wrg; Tue, 6 Mar 2018 08:12:54 -0800 (PST) X-Google-Smtp-Source: AG47ELvPDufO/HZnRvbM3A2BBhOnpXEEvb6ZHfxGUJbXtGAEau9wqyIKmWGMHAtqcM4EBjvaEkrl X-Received: by 2002:a17:902:8a89:: with SMTP id p9-v6mr17147854plo.379.1520352774082; Tue, 06 Mar 2018 08:12:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520352774; cv=none; d=google.com; s=arc-20160816; b=r299WngSKATTfNLnLRlqgSTojaYl887FwEzpQo6nnz3UzWbgy4wMZk1p31crxrTgUB FIr4qvqRbDooLUiUrJqaxHw5DEqzlYSFTwVf0xk6Z9eu2ETfzlZpOok6otqjQBcpUeVK 2HbsT4lOo0OE3doCmo7DnD1SH8zSOK73/P2j7eypIYroMqsfXDASMmyWRaqCWekl9x6N xshT/47x/N3MybppWMLEP+udXs0EXPkeSI5xRqYbEaEc+gH5vudwhK1QaFTPEo/yIjRd HRfNlpmd7JtkqB0cscgPK6GsAQTrprysJ4HM7UBv0Mbw5yY5csNoh/261rTKwyW9+DPK 2Dew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=jwhuBsSbRHxJ3CJ1o7dgBgi8n4/HAiWh3mxEfx1y04g=; b=G18ZWdilYyCoFYCXZXoDVovyfPa25V2ePmHiu4vK9dxUxIkJMyu0CdpTaftAP5GrQz wTituzOU9ZzXlrgm4pbK8SNy0DKIDD9ZUW/ay9ahiz6/aiRWY3KThBemK/tdq5ENwfsm hBJMH8r+Z7UD5L3mwGCnRjRqiddi1S97o0kl3TKhOw4cEkGNGa7RL4Kq3OdnLm+A8Bhn J8EDxBoq+TVZ5w7pSuUtDAbIo0eiyQG4zNkDzggICH4FqsLYLA3LokbL51ba9aczCn/J NuSm6N0+9fM/FiG03Um2CG2BQQJzVqRaDiWh/IvJ/hsTJ0GWgHDzC2dp2cKAr8APzszn RfiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@profitbricks-com.20150623.gappssmtp.com header.s=20150623 header.b=isf45b16; 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 q4-v6si9743796plr.365.2018.03.06.08.12.38; Tue, 06 Mar 2018 08:12:54 -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=@profitbricks-com.20150623.gappssmtp.com header.s=20150623 header.b=isf45b16; 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 S1753559AbeCFQLo (ORCPT + 99 others); Tue, 6 Mar 2018 11:11:44 -0500 Received: from mail-qk0-f193.google.com ([209.85.220.193]:44451 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752997AbeCFQLl (ORCPT ); Tue, 6 Mar 2018 11:11:41 -0500 Received: by mail-qk0-f193.google.com with SMTP id v124so25441796qkh.11 for ; Tue, 06 Mar 2018 08:11:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profitbricks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=jwhuBsSbRHxJ3CJ1o7dgBgi8n4/HAiWh3mxEfx1y04g=; b=isf45b164PEz1zojOYa4woGNR+nw0BKCV+Dhj2QCP/ZAfWBrDwX9V6sLnHxjms5aAN s8+2JQ2WTq/bo3BmuDW5Ac6/Z9IwAn2xeLHCAuY78O7mfyOQxCDWquHAcYq13/z8YubZ CmtGvd62SiZdXc5eoRtH4ddXzSOs0rVwtv5lPI1LPrprNLhMts4iO7mTZcDliSQNAUrH tJ68U2PQIALpkn79GRkErrYVbWpVvQIPCTcbMPWJ48mKyvJbvsjaZd51A5NaPYHSCmcR ZMhnsOK3oOhtJ4W52KSWUDdpWMSJkkpJ16z3MymK2rtukgkMzcGNZ0DuAKnMXo7DPIQg AlXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=jwhuBsSbRHxJ3CJ1o7dgBgi8n4/HAiWh3mxEfx1y04g=; b=OlhaTgj9ztnx33LAK/rJs73HUu1lMpJLImJG1PKvycZfIIY9FsiJ27qNpnlVYi7Vtw q0F1sDAMIawA1Faz474+1Eo++eW7Q4gW8LMVCTecRFpUrB4c/9p9EHmziP+ZXavV7vo8 tkXvxM/Xym6aUwQBVPFvD9BxRDb7AGpQKFggSO8sd4hYHaA+St7P9tPtSuwuWdDElb32 a9cuYSVQzLDo1QD/CXL+8KbtAjjUt73M2J3PpoUdAOk8EkJirAZmAL7ozWmQ5luVWB0K 9uHnYbyy5TZ677b18bqK812swx/VbxR58B8gNDoobpBt60mN07FDyg6+2gkNXrd7ek51 kx3Q== X-Gm-Message-State: AElRT7FdV57PgUeXTLQP7VK15lymvyqUD6tMCISTL6AEPVP0P9Kaa16H r5yWNyE/0MMFfkxs3WchtfWVQAzLGQh0Oi57N2CNfw== X-Received: by 10.233.223.193 with SMTP id t184mr13225791qkf.109.1520352701151; Tue, 06 Mar 2018 08:11:41 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.38.170 with HTTP; Tue, 6 Mar 2018 08:11:20 -0800 (PST) In-Reply-To: <0a95efad-1a3d-4aab-6d94-58dd583d275a@suse.cz> References: <20180223170325.997716448@linuxfoundation.org> <20180223170354.028619665@linuxfoundation.org> <0a95efad-1a3d-4aab-6d94-58dd583d275a@suse.cz> From: Jinpu Wang Date: Tue, 6 Mar 2018 17:11:20 +0100 Message-ID: Subject: Re: [PATCH 4.4 178/193] x86/syscall: Sanitize syscall table de-references under speculation To: Jiri Slaby Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, stable , Linus Torvalds , Dan Williams , Thomas Gleixner , linux-arch@vger.kernel.org, kernel-hardening@lists.openwall.com, Andy Lutomirski , alan@linux.intel.com, David Woodhouse , Jan Beulich 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 On Tue, Mar 6, 2018 at 3:21 PM, Jiri Slaby wrote: > On 02/23/2018, 07:26 PM, Greg Kroah-Hartman wrote: >> 4.4-stable review patch. If anyone has any objections, please let me know. >> >> ------------------ >> >> From: Dan Williams >> >> (cherry picked from commit 2fbd7af5af8665d18bcefae3e9700be07e22b681) >> >> The syscall table base is a user controlled function pointer in kernel >> space. Use array_index_nospec() to prevent any out of bounds speculation. >> >> While retpoline prevents speculating into a userspace directed target it >> does not stop the pointer de-reference, the concern is leaking memory >> relative to the syscall table base, by observing instruction cache >> behavior. >> >> Reported-by: Linus Torvalds >> 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: Andy Lutomirski >> Cc: alan@linux.intel.com >> Link: https://lkml.kernel.org/r/151727417984.33451.1216731042505722161.stgit@dwillia2-desk3.amr.corp.intel.com >> Signed-off-by: David Woodhouse >> [jwang: port to 4.4, no syscall_64] > > This is not complete IMO, the syscall is indeed there, only written in > assembly in 4.4 yet. > > So this patch looks like it is missing these two hunks (from my > SLE12-SP2 backport): > >> --- a/arch/x86/entry/entry_64.S >> +++ b/arch/x86/entry/entry_64.S >> @@ -184,6 +184,8 @@ entry_SYSCALL_64_fastpath: >> cmpl $__NR_syscall_max, %eax >> #endif >> ja 1f /* return -ENOSYS (already in pt_regs->ax) */ >> + sbb %rcx, %rcx /* array_index_mask_nospec() */ >> + and %rcx, %rax >> movq %r10, %rcx >> #ifdef CONFIG_RETPOLINE >> movq sys_call_table(, %rax, 8), %rax >> @@ -282,6 +284,8 @@ tracesys_phase2: >> cmpl $__NR_syscall_max, %eax >> #endif >> ja 1f /* return -ENOSYS (already in pt_regs->ax) */ >> + sbb %rcx, %rcx /* array_index_mask_nospec() */ >> + and %rcx, %rax >> movq %r10, %rcx /* fixup for C */ >> #ifdef CONFIG_RETPOLINE >> movq sys_call_table(, %rax, 8), %rax > > Discovered by Jan Beulich. > > thanks, > -- > js > suse labs Thanks Jiri, yes, indeed, could you send a formal patch of the fix? Thanks! Jack Wang