From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932364AbcEXWtF (ORCPT ); Tue, 24 May 2016 18:49:05 -0400 Received: from mail.kernel.org ([198.145.29.136]:36684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932319AbcEXWtB (ORCPT ); Tue, 24 May 2016 18:49:01 -0400 From: Andy Lutomirski To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Borislav Petkov , Kees Cook , Brian Gerst , Andy Lutomirski Subject: [PATCH 5/7] x86/uaccess: Warn on uaccess faults other than #PF Date: Tue, 24 May 2016 15:48:42 -0700 Message-Id: <5bcff14f574b1a9852d1334a9fa8886c70c928c4.1464129798.git.luto@kernel.org> X-Mailer: git-send-email 2.5.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If a uaccess instruction fails due to an8 error other than #PF, warn. If the fault is #GP, it most likely indicates access to a non-canonical address, which means that an access_ok check is missing, and that's bad. If the fault is something else (#UD?), then something is very wrong and we should diagnose it rather than ignoring it. Signed-off-by: Andy Lutomirski --- arch/x86/mm/extable.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c index 658292fdee5e..c1933471fce7 100644 --- a/arch/x86/mm/extable.c +++ b/arch/x86/mm/extable.c @@ -29,6 +29,19 @@ EXPORT_SYMBOL(ex_handler_default); static bool uaccess_fault_okay(int trapnr, unsigned long error_code, unsigned long extra) { + /* + * For uaccess, only page faults should be fixed up. I can't see + * any exploit mitigation value in OOPSing on other types of faults, + * so just warn and continue if that happens. This means that + * uaccess faults to non-canonical addresses will warn. That's okay + * -- this will only happen if an access_ok is missing, and we want to + * detect that error if it happens. + */ + if (WARN_ONCE(trapnr != X86_TRAP_PF, + "unexpected uaccess trap %d (may indicate a missing access_ok on a non-canonical address)\n", + trapnr)) + return true; /* no good reason to OOPS. */ + return true; } -- 2.5.5