Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4002048imj; Tue, 12 Feb 2019 08:11:56 -0800 (PST) X-Google-Smtp-Source: AHgI3IYyRYMpqJO5U2lXv+64/Yxk/KJm66Vwrk2EwOL5HkbgcQ+X3TA5DNOPXqOmp/YP0l+bQi27 X-Received: by 2002:a17:902:29c9:: with SMTP id h67mr4768314plb.111.1549987915928; Tue, 12 Feb 2019 08:11:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549987915; cv=none; d=google.com; s=arc-20160816; b=VPYhhfCRhD14GrtzU7EDgrBHfjFsNb40QSv6V8ILHcq2HSlhFjwQgWR7Hp2su8jXAS 4aB8CE0zWFgzMo2N/JqmyQYSZCRuaAxF0hz2NtRPXDYPYmko4JJrdoPnuSqC7Dqqk8A5 CCxB4te3SqnGRRmIVxUh5O/MKtwrdYwAtO4lZLlha1S+CZHEHQd+bcfSLxBi/M+joYqT 5gzR9vMiIpRAnNy/vxh6G1kthFTT2GF2F7AApokbgYH9TSv5hPJkgzdyCflFY8zZaeH2 1lsP1f3fUi1iMCWk8Q2FE2NiiVEIhcvMTwUXyQDYktxdZ5ItuoOmgD2APehnkNekLuAF s1jg== 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 :user-agent:message-id:date:subject:cc:to:from:dkim-signature; bh=f0Vhd6rlu30txlhorMwX1xOUu1WXrUL0+0OM5wOnAF4=; b=ZDBozBISQCGk8K+DktEfPTgs9ZBLcZUCJKN64RM2FNzt9B09Fn3qUr7vKH8WHg/xoX BnSLB9laMQPV0tiEEjU33GRnglwjKi+VOAChbtNF56ax4JHHh85wGwCgPb9F4Mqk47E0 Qj5rPFw0RlBPyS850Oj47dwbtBx+vDgR9Nrt33eti6jA+nHiACNWSBSdF2KKS6ZrI5O0 eZgSvSmiJVWJqR0Jo8/YzhqmvogyeujE1kT4yBHsXELw6sdXbJhtAPLQtIIOs91cYoTR ZpZd9yzc/BU17eVSin6bF25yhI0cbAi6tKLP8w5b+UrAyKb1pcUFXA91+YKg+s1DRV8x pFpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X3CQVhTC; 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 ck6si2978572plb.298.2019.02.12.08.11.38; Tue, 12 Feb 2019 08:11:55 -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=X3CQVhTC; 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 S1730917AbfBLQLP (ORCPT + 99 others); Tue, 12 Feb 2019 11:11:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:40886 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730461AbfBLQLO (ORCPT ); Tue, 12 Feb 2019 11:11:14 -0500 Received: from localhost.localdomain (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 9B349217D9; Tue, 12 Feb 2019 16:11:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549987873; bh=Hse9D6TRu4tRlMtiyVJ25CZGZL9zcOq2bE44q7kAaRs=; h=From:To:Cc:Subject:Date:From; b=X3CQVhTCxfhpW4+JZ1Z3wg/aLug0vA8z8wUfAeizaTLBbJ9OXgTU9no4IG/nskf13 2rAmb6nd9CYVSOuheXZlWXsxCoHkXO4WKFO1z77Z5chC20dEKn00Xbn8r47VXPy64U dNYlOE7ZjRxC6UdLqbeVsJNe1ubXJvybkXjJvseQ= From: Masami Hiramatsu To: Ingo Molnar Cc: Masami Hiramatsu , peterz@infradead.org, Mathieu Desnoyers , linux-kernel , Andrea Righi , Steven Rostedt Subject: [PATCH -tip v3 00/10] kprobes: Fix and improve blacklist symbols Date: Wed, 13 Feb 2019 01:10:50 +0900 Message-Id: <154998785011.31052.1475728497912659748.stgit@devbox> X-Mailer: git-send-email 2.13.6 User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Here is the v3 series of kprobes blacklist bugfix and improvements mainly on x86 (since I started testing on qemu-x86). This version is just rebased on top of -tip master branch and add bsearch nokprobe patch by Andrea (Thanks!) This has been started from discussion about KPROBE_ENENTS_ON_NOTRACE configuration. I tried to find notrace functions which can cause kernel crash with kprobes using following script. ==== #!/bin/sh i=0; cat notrace_functions | while read f ; do if echo p:event$i $f >> /sys/kernel/debug/tracing/kprobe_events; then echo "Probing on $f" echo 1 > /sys/kernel/debug/tracing/events/kprobes/event$i/enable fi i=$((i+1)) done ==== And I found several functions which must be blacklisted. - optprobe template code, which is just a template code and never be executed. Moreover, since it can be copied and reused, if we probe it, it modifies the template code and can cause a crash. ([1/10][2/10]) - functions which is called before kprobe_int3_handler() handles kprobes. This can cause a breakpoint recursion. ([3/10]) - IRQ entry text, which should not be probed since register/pagetable status has not been stable at that point. ([4/10]) - Suffixed symbols, like .constprop, .part etc. Those suffixed symbols never be blacklisted even if the non-suffixed version has been blacklisted. ([5/10]) - hardirq tracer also works before int3 handling. ([6/10]) - preempt_check debug function also is involved in int3 handling. ([7/10]) - RCU debug routine is also called before kprobe_int3_handler(). ([8/10]) - Some lockdep functions are also involved in int3 handling. ([9/10]) - bsearch() is involved in int3 handling because of ftrace is using it. ([10/10]) Of course there still may be some functions which can be called by configuration change, I'll continue to test it. Thank you, --- Andrea Righi (1): kprobes: Prohibit probing on bsearch() Masami Hiramatsu (9): x86/kprobes: Prohibit probing on optprobe template code x86/kprobes: Move trampoline code into RODATA x86/kprobes: Prohibit probing on functions before kprobe_int3_handler() x86/kprobes: Prohibit probing on IRQ handlers directly kprobes: Search non-suffixed symbol in blacklist kprobes: Prohibit probing on hardirq tracers kprobes: Prohibit probing on preempt_check debug functions kprobes: Prohibit probing on RCU debug routine kprobes: Prohibit probing on lockdep functions arch/x86/kernel/alternative.c | 3 ++- arch/x86/kernel/ftrace.c | 3 ++- arch/x86/kernel/kprobes/core.c | 7 +++++++ arch/x86/kernel/kprobes/opt.c | 4 ++-- arch/x86/kernel/traps.c | 1 + kernel/kprobes.c | 21 ++++++++++++++++++++- kernel/locking/lockdep.c | 7 ++++++- kernel/rcu/tree.c | 2 ++ kernel/rcu/update.c | 2 ++ kernel/trace/trace_irqsoff.c | 9 +++++++-- kernel/trace/trace_preemptirq.c | 5 +++++ lib/bsearch.c | 2 ++ lib/smp_processor_id.c | 7 +++++-- 13 files changed, 63 insertions(+), 10 deletions(-) -- Masami Hiramatsu (Linaro)