From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752002AbcEKJo0 (ORCPT ); Wed, 11 May 2016 05:44:26 -0400 Received: from terminus.zytor.com ([198.137.202.10]:38642 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751320AbcEKJoX (ORCPT ); Wed, 11 May 2016 05:44:23 -0400 Date: Wed, 11 May 2016 02:43:04 -0700 From: tip-bot for Mathias Krause Message-ID: Cc: minipli@googlemail.com, torvalds@linux-foundation.org, luto@amacapital.net, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, bp@alien8.de, ard.biesheuvel@linaro.org, peterz@infradead.org, luto@kernel.org, brgerst@gmail.com, tglx@linutronix.de, bp@suse.de, mingo@kernel.org, dvlasenk@redhat.com, tony.luck@intel.com, hpa@zytor.com Reply-To: minipli@googlemail.com, luto@amacapital.net, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, bp@alien8.de, ard.biesheuvel@linaro.org, tglx@linutronix.de, peterz@infradead.org, brgerst@gmail.com, luto@kernel.org, bp@suse.de, mingo@kernel.org, tony.luck@intel.com, dvlasenk@redhat.com, hpa@zytor.com In-Reply-To: <1462914422-2911-1-git-send-email-minipli@googlemail.com> References: <1462914422-2911-1-git-send-email-minipli@googlemail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/mm] x86/extable: Ensure entries are swapped completely when sorting Git-Commit-ID: 67d7a982bab6702d84415ea889996fae72a7d3b2 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: 67d7a982bab6702d84415ea889996fae72a7d3b2 Gitweb: http://git.kernel.org/tip/67d7a982bab6702d84415ea889996fae72a7d3b2 Author: Mathias Krause AuthorDate: Tue, 10 May 2016 23:07:02 +0200 Committer: Ingo Molnar CommitDate: Wed, 11 May 2016 11:14:06 +0200 x86/extable: Ensure entries are swapped completely when sorting The x86 exception table sorting was changed in this recent commit: 29934b0fb8ff ("x86/extable: use generic search and sort routines") ... to use the arch independent code in lib/extable.c. However, the patch was mangled somehow on its way into the kernel from the last version posted at: https://lkml.org/lkml/2016/1/27/232 The committed version kind of attempted to incorporate the changes of contemporary commit done in the x86 tree: 548acf19234d ("x86/mm: Expand the exception table logic to allow new handling options") ... as in _completely_ _ignoring_ the x86 specific 'handler' member of struct exception_table_entry. This effectively broke the sorting as entries will only be partly swapped now. Fortunately, the x86 Kconfig selects BUILDTIME_EXTABLE_SORT, so the exception table doesn't need to be sorted at runtime. However, in case that ever changes, we better not break the exception table sorting just because of that. Fix this by providing a swap_ex_entry_fixup() macro that takes care of the 'handler' member. Signed-off-by: Mathias Krause Reviewed-by: Ard Biesheuvel Cc: Andrew Morton Cc: Andy Lutomirski Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Tony Luck Link: http://lkml.kernel.org/r/1462914422-2911-1-git-send-email-minipli@googlemail.com Signed-off-by: Ingo Molnar --- arch/x86/include/asm/uaccess.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index 8b3fb76..86c48f3 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -108,6 +108,14 @@ struct exception_table_entry { #define ARCH_HAS_RELATIVE_EXTABLE +#define swap_ex_entry_fixup(a, b, tmp, delta) \ + do { \ + (a)->fixup = (b)->fixup + (delta); \ + (b)->fixup = (tmp).fixup - (delta); \ + (a)->handler = (b)->handler + (delta); \ + (b)->handler = (tmp).handler - (delta); \ + } while (0) + extern int fixup_exception(struct pt_regs *regs, int trapnr); extern bool ex_has_fault_handler(unsigned long ip); extern int early_fixup_exception(unsigned long *ip);