From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965775AbdIZIpO (ORCPT ); Tue, 26 Sep 2017 04:45:14 -0400 Received: from terminus.zytor.com ([65.50.211.136]:42197 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935351AbdIZIpK (ORCPT ); Tue, 26 Sep 2017 04:45:10 -0400 Date: Tue, 26 Sep 2017 01:36:20 -0700 From: tip-bot for Eric Biggers Message-ID: Cc: tglx@linutronix.de, oleg@redhat.com, ebiggers3@gmail.com, keescook@chromium.org, luto@kernel.org, yu-cheng.yu@intel.com, hpa@zytor.com, dave.hansen@linux.intel.com, haokexin@gmail.com, peterz@infradead.org, akpm@linux-foundation.org, mhalcrow@google.com, ebiggers@google.com, fenghua.yu@intel.com, torvalds@linux-foundation.org, wanpeng.li@hotmail.com, luto@amacapital.net, dvyukov@google.com, mingo@kernel.org, linux-kernel@vger.kernel.org, bp@alien8.de, riel@redhat.com Reply-To: haokexin@gmail.com, dave.hansen@linux.intel.com, hpa@zytor.com, yu-cheng.yu@intel.com, keescook@chromium.org, luto@kernel.org, ebiggers3@gmail.com, oleg@redhat.com, tglx@linutronix.de, riel@redhat.com, bp@alien8.de, linux-kernel@vger.kernel.org, mingo@kernel.org, dvyukov@google.com, luto@amacapital.net, wanpeng.li@hotmail.com, fenghua.yu@intel.com, ebiggers@google.com, torvalds@linux-foundation.org, mhalcrow@google.com, akpm@linux-foundation.org, peterz@infradead.org In-Reply-To: <20170924105913.9157-7-mingo@kernel.org> References: <20170924105913.9157-7-mingo@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/fpu] x86/fpu: Use validate_xstate_header() to validate the xstate_header in copy_kernel_to_xstate() Git-Commit-ID: af95774b3ca080b0e1e651c0fc7680f3444ddda7 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: af95774b3ca080b0e1e651c0fc7680f3444ddda7 Gitweb: http://git.kernel.org/tip/af95774b3ca080b0e1e651c0fc7680f3444ddda7 Author: Eric Biggers AuthorDate: Sun, 24 Sep 2017 12:59:09 +0200 Committer: Ingo Molnar CommitDate: Tue, 26 Sep 2017 09:43:47 +0200 x86/fpu: Use validate_xstate_header() to validate the xstate_header in copy_kernel_to_xstate() Tighten the checks in copy_kernel_to_xstate(). Signed-off-by: Eric Biggers Cc: Andrew Morton Cc: Andy Lutomirski Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Dave Hansen Cc: Dmitry Vyukov Cc: Eric Biggers Cc: Fenghua Yu Cc: Kees Cook Cc: Kevin Hao Cc: Linus Torvalds Cc: Michael Halcrow Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Rik van Riel Cc: Thomas Gleixner Cc: Wanpeng Li Cc: Yu-cheng Yu Cc: kernel-hardening@lists.openwall.com Link: http://lkml.kernel.org/r/20170924105913.9157-7-mingo@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/kernel/fpu/xstate.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index c97c4a9..325db78 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -1138,15 +1138,12 @@ int copy_xstate_to_user(void __user *ubuf, struct xregs_state *xsave, unsigned i /* * Convert from a ptrace standard-format kernel buffer to kernel XSAVES format - * and copy to the target thread. This is called from xstateregs_set() and - * there we check the CPU has XSAVES and a whole standard-sized buffer - * exists. + * and copy to the target thread. This is called from xstateregs_set(). */ int copy_kernel_to_xstate(struct xregs_state *xsave, const void *kbuf) { unsigned int offset, size; int i; - u64 allowed_features; struct xstate_header hdr; offset = offsetof(struct xregs_state, header); @@ -1154,12 +1151,7 @@ int copy_kernel_to_xstate(struct xregs_state *xsave, const void *kbuf) memcpy(&hdr, kbuf + offset, size); - /* - * Reject if the user sets any disabled or supervisor features: - */ - allowed_features = xfeatures_mask & ~XFEATURE_MASK_SUPERVISOR; - - if (hdr.xfeatures & ~allowed_features) + if (validate_xstate_header(&hdr)) return -EINVAL; for (i = 0; i < XFEATURE_MAX; i++) {