From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753875AbbCQMi3 (ORCPT ); Tue, 17 Mar 2015 08:38:29 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:35702 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752348AbbCQMiZ (ORCPT ); Tue, 17 Mar 2015 08:38:25 -0400 From: Quentin Casasnovas To: lkml Cc: Oleg Nesterov , Borislav Petkov , Linus Torvalds Subject: [PATCH 0/7] Detect future mis-uses of __ex_table section. Date: Tue, 17 Mar 2015 13:39:55 +0100 Message-Id: <1426596002-26128-1-git-send-email-quentin.casasnovas@oracle.com> X-Mailer: git-send-email 2.0.5 X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, This patch-set adds some sanity checks on the __ex_table section so that it makes it much harder to introduce wrong entries in there. It works by checking every relocation in __ex_table and making sure it points to an executable section and does not point to a list of black-listed sections, like .altinstr_replacement. Patch 6 adds a new script, check_extable.sh, so it can be used to get more human readable diagnostics on where the wrong ex_table entry was added in the code. Here's a truncated example output from v4.0-rc2: Error: found a reference to .altinstr_replacement in __ex_table: xrstor_state at /home/quentin/linux-2.6/./arch/x86/include/asm/xsave.h:179 (inlined by) fpu_xrstor_checking at /home/quentin/linux-2.6/./arch/x86/include/asm/xsave.h:207 (inlined by) fpu_restore_checking at /home/quentin/linux-2.6/./arch/x86/include/asm/fpu-internal.h:284 (inlined by) kvm_load_guest_fpu at /home/quentin/linux-2.6/arch/x86/kvm/x86.c:6986 This is to prevent future misuses of the __ex_table entry like there was for xsaves/xrstors for example, see upstream commit 06e5801b ("x86/fpu/xsaves: Fix improper uses of __ex_table"). This will potentially break the build for other architectures (tested on x86-64 and sparc), since there might be exotic sections in there that I don't know about. Quentin