Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3433407imu; Mon, 17 Dec 2018 20:52:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/Un2Exkm9NvAmNb1GsBD5ztyJYmcZrz+8u+F1PmbBfsSPodHMyt5viE2JyWQ/DNsf9ix21E X-Received: by 2002:a17:902:7e44:: with SMTP id a4mr15266079pln.338.1545108742433; Mon, 17 Dec 2018 20:52:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545108742; cv=none; d=google.com; s=arc-20160816; b=je1JZrCcz5nNFe2ngJaIwgYV2rb+JoTSmVWoPap61cDFE99Y+NBfBXG0AbbPiHZrQz uNAjv6Jl1IOA9qXYrFdyN7wcAWzaUxfK+lbgeeIqENPtpg0mhWFkICR22pCyt5Eu3sYr TMz8G9dBn/SAalm29jLvwnEgBi9VaN1S9ot2HIx1Y/g5o2qd/5WFGUlCRPjAJfQ2e3wb u+RdDoeVGxT8o/SNdb0LQB+g/GOBIIruPt/trQrDeHvnYds2xSJHwWDKSVX4B197s3Rv dhOiaQBpU01qYky/ZKJI8dgaNdgbGL1p+j9+Y7Lk+cTBx83pZhDKdGdrwi/H644iKRHx Q+0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=ZH6H3CgaEHumsIcuxOT9c3hfyV16sWOEOeEB05UyowY=; b=dzQBuvf5/8Ic8cVE8D4sUsfNWziwwAuBzYjrFvz2gM2YCeQpS5kMMFkU7mKPVzTZDu 4EA3Z/DvJOak1X965R5pX+SbeqqE2SatXZkCBZiQ/pWdLqie7C1OtogKwDIhhS8gkL0s xhz0hviSgQXrEmRmxllUJodHOjuQ7A3OuRYHlO8bIY3aJ3oAisEfGs06oYun1nV7kTDk qWnXIxfmbdEgwLh1vFttHwAda1wtcvBgKuX7+bJ3y+uQwFAQONrzhr9ARgEDaO25DMZO AQlqdXhKP24FlDdCBp7qoStLKf9VfcSy6XSGlzODWa3nHoDoQBl47+jl+8AwVYKKOX0V Xtbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lTE+5yh+; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q70si12675362pgq.526.2018.12.17.20.51.52; Mon, 17 Dec 2018 20:52:22 -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=@kernel.org header.s=default header.b=lTE+5yh+; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726594AbeLREub (ORCPT + 99 others); Mon, 17 Dec 2018 23:50:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:38754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726534AbeLREub (ORCPT ); Mon, 17 Dec 2018 23:50:31 -0500 Received: from devbox (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 85375217D8; Tue, 18 Dec 2018 04:50:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545108630; bh=rDFEyGlRfP6Fj4eQLVLTifDbKb/gwUIX4WgoTW4zPKE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=lTE+5yh+7elOqxhR+1snjAxbvKakqE7OtQuXW8APua0/IDUI+ReEi90dCRip5hlbb pLjPuQYbDZBsN4u0Txf9YJ2IphZUvZEXQYtI32NuKCn7BdU5FOfYC5b1d7uOSxEmiU MSRgF44uWuJaC9x8867kOuzLRcgO6FIuP+zt9kvY= Date: Tue, 18 Dec 2018 13:50:26 +0900 From: Masami Hiramatsu To: Andrea Righi Cc: Ingo Molnar , "Naveen N . Rao" , Anil S Keshavamurthy , "David S . Miller" , Yonghong Song , Andy Lutomirski , Thomas Gleixner , Borislav Petkov , "H . Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 0/3] x86: kprobes: Show correct blaclkist in debugfs Message-Id: <20181218135026.6f96a89247e9b70fa45afbe9@kernel.org> In-Reply-To: <20181217154713.GA1308@Dell> References: <154503482486.26176.6224515860220847638.stgit@devbox> <20181217154713.GA1308@Dell> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 17 Dec 2018 16:47:13 +0100 Andrea Righi wrote: > On Mon, Dec 17, 2018 at 05:20:25PM +0900, Masami Hiramatsu wrote: > > This is v2 series for showing correct kprobe blacklist in > > debugfs. > > > > v1 is here: > > > > https://lkml.org/lkml/2018/12/7/517 > > > > I splitted the RFC v1 patch into x86 and generic parts, > > also added a patch to remove unneeded arch-specific > > blacklist check function (because those have been added > > to the generic blacklist.) > > > > If this style is good, I will make another series for the > > archs which have own arch_within_kprobe_blacklist(), and > > eventually replace that with arch_populate_kprobe_blacklist() > > so that user can get the correct kprobe blacklist in debugfs. > > > > Thank you, > > Looks good to me. Thanks! > > Tested-by: Andrea Righi Thank you for testing! > > Side question: there are certain symbols in arch/x86/xen that should be > blacklisted explicitly, because they're non-attachable. > > More exactly, all functions defined in arch/x86/xen/spinlock.c, > arch/x86/xen/time.c and arch/x86/xen/irq.c. > > The reason is that these files are compiled without -pg to allow the > usage of ftrace within a Xen domain apparently (from > arch/x86/xen/Makefile): > > ifdef CONFIG_FUNCTION_TRACER > # Do not profile debug and lowlevel utilities > CFLAGS_REMOVE_spinlock.o = -pg > CFLAGS_REMOVE_time.o = -pg > CFLAGS_REMOVE_irq.o = -pg > endif Actually, the reason why you can not probe those functions via tracing/kprobe_events is just a side effect. You can probe it if you write a kprobe module. Since the kprobe_events depends on some ftrace tracing functions, it sometimes cause a recursive call problem. To avoid this issue, I have introduced a CONFIG_KPROBE_EVENTS_ON_NOTRACE, see commit 45408c4f9250 ("tracing: kprobes: Prohibit probing on notrace function"). If you set CONFIG_KPROBE_EVENTS_ON_NOTRACE=n, you can continue putting probes on Xen spinlock functions too. > Do you see a nice and clean way to blacklist all these functions > (something like arch_populate_kprobe_blacklist()), or should we just > flag all of them explicitly with NOKPROBE_SYMBOL()? As I pointed, you can probe it via your own kprobe module. Like systemtap, you still can probe it. The blacklist is for "kprobes", not for "kprobe_events". (Those are used to same, but since the above commit, those are different now) I think the most sane solution is, identifying which (combination of) functions in ftrace (kernel/trace/*) causes a problem, marking those NOKPROBE_SYMBOL() and removing CONFIG_KPROBE_EVENTS_ON_NOTRACE. Thank you, -- Masami Hiramatsu