Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp926915ybl; Wed, 11 Dec 2019 09:38:04 -0800 (PST) X-Google-Smtp-Source: APXvYqzB6BLIoqfNpa5+mCutIoQQ704rdKH3spBwkbBxazV/KTSOFrF0oeV+8uTGJVAbyEowRCNF X-Received: by 2002:a05:6830:15d9:: with SMTP id j25mr2953622otr.279.1576085883959; Wed, 11 Dec 2019 09:38:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576085883; cv=none; d=google.com; s=arc-20160816; b=tqJpy0T3YiKeS2CvXelMZ1bE1AvtxVP5Hcryw2Fw6yT2XQfZSaHyqA9xZM6kj46FCU R8lcUU6D5uiSgLcJzhXcmN9FHHxxwyKP1aeRa5UK/K/LOAQh2pTB6DPsyafyYW8+u89Q 5kgsbBN5b2zelf/1hbht8x/d4Eg5ft4Khk4k/wLnQEaVLHkVV/Bn6AVawYozlPmokAgF EMH8aEqamRLAdpFB9rI413JXNx2REtcwv9bFBqEP8LPywa4XGKjEJbzPxpkvjsV+dqP5 nTxGQ5xwsinRogOL9qykohJ6727NdVPq3uMk7Xzd89UAkyuWSPdFdXNyJRP+i1kfg/7g wtzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/fQSVH4e2kOh1ufr5QULeFyUccGwjWVFvNcXOqos5bc=; b=cXKmbBt0rH39baZM8aAY+o06lXxi16cNZfgEOQni7BUivImdSl0VPcQQKI3nlhNESU 6937LCimJl3ROD4YjJwKqLm4IEp0PcdYSHrxr0lXKR8VMUx/dB6E9vPJixcjY5AYH908 tUbDNGuZ7R6aJUSybMH0IURwmcWFHfMYkXBX/g7g4pb4dPqZ/uML+Sebl45WCDrxZv15 BEYNzUQJLbd5K75q6WbdfM4x3sTI89HwZCviWdOBYCZ90klLWHKkpBhSN1yfMlgSqZeG zNMukxYV6UjpNF/haqZfBhX5Cg9Knmva5T4VKtyUM4E9YyyMy7ccMeWq2Me4zbiVgJWn TOHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=j3MRlnLT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s26si1463051otr.38.2019.12.11.09.37.50; Wed, 11 Dec 2019 09:38:03 -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=@alien8.de header.s=dkim header.b=j3MRlnLT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729616AbfLKRhO (ORCPT + 99 others); Wed, 11 Dec 2019 12:37:14 -0500 Received: from mail.skyhub.de ([5.9.137.197]:56382 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727334AbfLKRhO (ORCPT ); Wed, 11 Dec 2019 12:37:14 -0500 Received: from zn.tnic (p200300EC2F094900329C23FFFEA6A903.dip0.t-ipconnect.de [IPv6:2003:ec:2f09:4900:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 17A371EC0591; Wed, 11 Dec 2019 18:37:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1576085833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=/fQSVH4e2kOh1ufr5QULeFyUccGwjWVFvNcXOqos5bc=; b=j3MRlnLTHkMRuZ7QpudWgF6/T2UqokFtYoPNG1Yr0vcl1cqrwaFFEOLLDsNTjKXHlPyDjl /jMUop/434oLwmjhI+9f8A5KEov4WxhHidW2RpmlC1NnHXoHJ+iN8wMXGjCRkXFIIgHyfG Y80o5U8gGTn+LK4dKb3lkvYKayZF+7E= Date: Wed, 11 Dec 2019 18:37:12 +0100 From: Borislav Petkov To: Jann Horn Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, Andrey Konovalov , Andy Lutomirski , Sean Christopherson Subject: Re: [PATCH v6 4/4] x86/kasan: Print original address on #GP Message-ID: <20191211173711.GF14821@zn.tnic> References: <20191209143120.60100-1-jannh@google.com> <20191209143120.60100-4-jannh@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191209143120.60100-4-jannh@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 09, 2019 at 03:31:20PM +0100, Jann Horn wrote: > arch/x86/kernel/traps.c | 12 ++++++++++- > arch/x86/mm/kasan_init_64.c | 21 ------------------- > include/linux/kasan.h | 6 ++++++ > mm/kasan/report.c | 40 +++++++++++++++++++++++++++++++++++++ > 4 files changed, 57 insertions(+), 22 deletions(-) I need a KASAN person ACK here, I'd guess. > diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c > index c8b4ae6aed5b..7813592b4fb3 100644 > --- a/arch/x86/kernel/traps.c > +++ b/arch/x86/kernel/traps.c > @@ -37,6 +37,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -589,6 +590,8 @@ do_general_protection(struct pt_regs *regs, long error_code) > if (!user_mode(regs)) { > enum kernel_gp_hint hint = GP_NO_HINT; > unsigned long gp_addr; > + unsigned long flags; > + int sig; > > if (fixup_exception(regs, X86_TRAP_GP, error_code, 0)) > return; > @@ -621,7 +624,14 @@ do_general_protection(struct pt_regs *regs, long error_code) > "maybe for address", > gp_addr); > > - die(desc, regs, error_code); > + flags = oops_begin(); > + sig = SIGSEGV; > + __die_header(desc, regs, error_code); > + if (hint == GP_NON_CANONICAL) > + kasan_non_canonical_hook(gp_addr); > + if (__die_body(desc, regs, error_code)) > + sig = 0; > + oops_end(flags, regs, sig); Instead of opencoding it like this, can we add a die_addr(desc, regs, error_code, gp_addr); to arch/x86/kernel/dumpstack.c and call it from here: if (hint != GP_NON_CANONICAL) gp_addr = 0; die_addr(desc, regs, error_code, gp_addr); This way you won't need to pass down to die_addr() the hint too - you code into gp_addr whether it was non-canonical or not. The + if (addr < KASAN_SHADOW_OFFSET) + return; check in kasan_non_canonical_hook() would then catch it when addr == 0. Hmmm? -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette