Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1210199ybl; Wed, 18 Dec 2019 14:36:06 -0800 (PST) X-Google-Smtp-Source: APXvYqx/fd5tDIL7MCTmC7eovKySpRbrMoPKqWspwXNyQZEygeGQhxNwf1NX+RoVJjPyXxr49ooU X-Received: by 2002:a05:6830:1615:: with SMTP id g21mr5315936otr.49.1576708566583; Wed, 18 Dec 2019 14:36:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576708566; cv=none; d=google.com; s=arc-20160816; b=SLC0k3DrhVS1+TK8ODVDI71Ic1DqUSCvFLckpIiyAGvBlGOFpCr3iQ2RlP9NikZewP 6JMcJhRDzIcBKSjjpbYX0DZD+0zxpakkhbk0VZoQRom6ckr7nvZ8r4eQrT1295MMJr7B ezX8vRj3TK9ddu1uRnXCMlJ+IotFenpRvMgs9xG+ZsCkkvYnael0pV6tvgu/VCXlH8vI KABnlP/lGrfFGIf/I5ermLzmHF+m5ClWVR5t6g82VIyDB6FiPCaw80/YqqiSaWtuDCvi vj/BTsp4pMdmCVzfoNtfapxAnhsZOu9pg2c4aehn+rLKTLXNtHrCs/bqrAiq6BZGbE5B 98iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=q0o+3IFWqjXrZk2VGX8AZpqrFD1hgC3oeYUhyHktLWk=; b=Oz/Bz6ANbPVdD1oZ4GBnE9uZmMNM5BltrJctMpCz6CvBSwElCE55x8ayj6th+qDPid eUSCBSWCWt4n5jVEfxvRM7QZlapBOFB8psk1k5FEblLI8SFySz+jK5GcNpM2VnJHG1Ac vfV81a/UValasgrklQAXXvcVP2vb0pOOPgauGw/nspnnDrbplP9g+TR4+A4HHgKKRc9Y Exmsyjle1i7YecahczA3akN/1jZiZjd9ZhZoFeyMuToPd9WRkE4g+aLZIk37X0bxgeiK tUl7FRi5im6gG6qCAOCNmD7XolOgzBcPqmagpIHWUobewwW1+e+KB2qEnxmINvHdqEd2 DFDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OvOglgIp; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j70si2112698oib.219.2019.12.18.14.35.55; Wed, 18 Dec 2019 14:36:06 -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=@google.com header.s=20161025 header.b=OvOglgIp; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726648AbfLRWeV (ORCPT + 99 others); Wed, 18 Dec 2019 17:34:21 -0500 Received: from mail-ot1-f67.google.com ([209.85.210.67]:38420 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726512AbfLRWeV (ORCPT ); Wed, 18 Dec 2019 17:34:21 -0500 Received: by mail-ot1-f67.google.com with SMTP id d7so30604otf.5 for ; Wed, 18 Dec 2019 14:34:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=q0o+3IFWqjXrZk2VGX8AZpqrFD1hgC3oeYUhyHktLWk=; b=OvOglgIpCOvAU0KUmMs8x4iozSWSqM+yDOyefrFtCr2OVCpfsjJ7pnWEnXeEBMD0A7 dcjpSo5tP1TdSit6XHXofae91ynxxjN33wttHo9/PkuR1cQpHtnXOEt8YZMQDifUZQ2L inAlja5nVFJgaMkKbocgiGlM7eskKOyL5cDOlyJEDEaPFrmvYPf6XGLW7jL0jKVa/Lfy +xOtBtwKlaja0TfAcQJ0VYwDDhkPQFIDjW/oLwrRSpinQV6s2k4O0GaSwy1uoMBPtmq8 9NyURifh80gzG9Po7lDjW9xXjm5HU2xWTmRiQdzfPOlKbbD1ThuVVX2hP7JZaTtLGX+x vibg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=q0o+3IFWqjXrZk2VGX8AZpqrFD1hgC3oeYUhyHktLWk=; b=NXNtDQzQAhzR/cLR7aEc/S9HgVTFKZdt/C9r3H1sX833+XykOsTyKrSeXhrC6yg8Vk 3MqpRBiG+qEykuycwuJJGhDHCbHVkbOG4VAK86hO+4NWgYJSyNltu44pwhjGSodoiZsF zazjGXySQRqnM5vwuC7Yafk3i4axWYgSZF/GWwdFWiWUNd6kqGC2NQNRGLYgmNnk7Vai LK/sH5zKhOxkbmJVPjaiLIhXOhsDryJKih68hhtHFSnEV+icxqJYrP6AZVxQFRRChXYb u98L0S+XsB6MtJ8NXN8eqEylgJQqAawWmELigy+/IwVpiULF4TtVW4DJgdXQ/axsw/iN 0lEw== X-Gm-Message-State: APjAAAWCpsdvCsPnuFkFJJCB7Xy1xD4FL/p1aRbH8PzaTBGnXqBFsPOz CwNJo3lRSxPuD+rFGJZwLcty20WHpXh1lVsIq6ZJ2nJXqIg= X-Received: by 2002:a05:6830:2057:: with SMTP id f23mr659352otp.110.1576708460339; Wed, 18 Dec 2019 14:34:20 -0800 (PST) MIME-Version: 1.0 References: <20191209143120.60100-1-jannh@google.com> <20191209143120.60100-4-jannh@google.com> <20191211173711.GF14821@zn.tnic> In-Reply-To: <20191211173711.GF14821@zn.tnic> From: Jann Horn Date: Wed, 18 Dec 2019 23:33:54 +0100 Message-ID: Subject: Re: [PATCH v6 4/4] x86/kasan: Print original address on #GP To: Borislav Petkov Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "the arch/x86 maintainers" , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , kasan-dev , kernel list , Andrey Konovalov , Andy Lutomirski , Sean Christopherson Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 11, 2019 at 6:37 PM Borislav Petkov wrote: > 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. Right, I got a Reviewed-by from Dmitry for v2, but cleared that when I made changes to the patch later - I'll ask Dmitry for a fresh ack on the v7 patch. [...] > > - 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); Okay, so I'll make __die_header() and __die_body() static, introduce and hook up die_addr() in patch 3/4, and then in patch 4/4 insert the call to the KASAN hook. > 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. I'll add an explicit check for nonzero address before calling kasan_non_canonical_hook() so that the semantics are a bit more cleanly split.