Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3273910pxb; Mon, 1 Mar 2021 06:11:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJw55IDUqxE6RkydhytQDKoBP6+jj/KEGOaOYfemjKYiQc88VftqpAVG8B4m9LdioiASCyQ8 X-Received: by 2002:a17:907:9863:: with SMTP id ko3mr5992634ejc.543.1614607914705; Mon, 01 Mar 2021 06:11:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614607914; cv=none; d=google.com; s=arc-20160816; b=Pv0pWElilbMbVORKsjC+9eggiLOdEI0cw12rr1tqzwJD7GC1QhnkRFYB/hJ0SdcWV/ k53CtofrQzSyIhrGEh0lMz8/8SWa0byK0WXPMeSxRa0AtZWi5O+cNdxMWXhsrK51P3Eu Gm2Zz+TomyfogUzobFrR20IRVxY2x9hWSHd+k4tepZO2bgesI1PgF3mAqmnOlKGs1OMh gqnD5KTUwUNDkDGHPW+7WLYltujfAAV4VNOOTXD2mFbWkHjwxdaJuoiSe1AJFEV9MVin AhI9D8dqLF5wm153+btyOTUpcqZNdqJyvIo2kI1bm5YSq4bHxxAyMFNMetyoYNs+t6Kq FHtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YAwtq3h7ped0PKC6xh22mnA91nBclkmh33a0DI8uhbo=; b=x3ofUY8CwRP6P0VER1NC1Qz/14kKKimbEzoEEzcOEeclqQaSNLXgTWUWvShf+9lPvp y83bp05Ft5cFXme1bQK9clVlVdN0wez3C3/KL4BoBYahQwgFkkOEkqwFqOR7w0jM/32Q 5x8KyJdjpV3kMA1f+UBcSwzBvsz4zvvnycP7Gb4wx3iv7mNL2X6y0zQ8hLwgHsAMSwK/ axcWg50PQ7puitluDBKjrbSKQ9BpVg7OxPh4dt93Imxcqva89yzZvCVTmw//uB4gPbUo Q76nG9wOys+4YlqURxsf32w9+LiwF5X4ab1ilA4vpbLb0iLLUQEz2UL4raTQNWzjfhwj Sqcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TJbGI7+f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id qu25si6963196ejb.665.2021.03.01.06.11.28; Mon, 01 Mar 2021 06:11:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TJbGI7+f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S236093AbhCAOJe (ORCPT + 99 others); Mon, 1 Mar 2021 09:09:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:49314 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236083AbhCAOIu (ORCPT ); Mon, 1 Mar 2021 09:08:50 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 904DE64D99; Mon, 1 Mar 2021 14:08:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614607690; bh=B+oJtXP8jLA9R46vUJpzXxKoLBwvsxZUYVYrGcBwKP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TJbGI7+fOQV7mZjof50fylYGa2840aU9ILTgVz/YvHjF5tp8USpyricwB1xoAIWVS YI7/54ye/wpGckVq8U8eM130zCtuyW4BEMwa2/7jTiGt2aocX5WHU7AgAnTkIQqK6p SU5Motzc8yl5zvNEP5JGWkVn6o0l0bEmOwtN1Xh6OcOCiAKXt96D1YyYIJJxp0U7Bo E7Mp4CfukGm2X0bEAegKNkFFXwVUpbZR/KOE6Ol2YpZpX/ioJsyivErp8+pN2e5afo fP0VySnMoRsRQYE9mKNMjHuj5YrnXJOsVokPJIy//f9CkFOk82RwzdgDYtIzFbruth v4S3MTXqNwWhA== From: Masami Hiramatsu To: Andy Lutomirski , Ingo Molnar Cc: Oleg Nesterov , Masami Hiramatsu , Peter Zijlstra , LKML , Anil S Keshavamurthy , "David S . Miller" , X86 ML , Andrew Cooper , Steven Rostedt Subject: [RFC PATCH 0/1] x86/kprobes: Remoev single-step trap from x86 kprobes Date: Mon, 1 Mar 2021 23:08:04 +0900 Message-Id: <161460768474.430263.18425867006584111900.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210225112245.607c70ec13cf8d279390e89e@kernel.org> References: <20210225112245.607c70ec13cf8d279390e89e@kernel.org> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, Here is the patch to remove the single-step debug trap from the x86 kprobe. This uses int3 as you suggested instead of the debug trap, for removing the iret which returns to kernel. Some instructions must be emulated and some instructions becomes not able to be probed, but as far as I can see those are not rare case. TODOs/discussions - extend kprobe debugfs interface to show the arch-dependent flags, like [BOOST], [EMULATE]. - Consider this emulation code split into a file and share it with uprobe (uprobe already has its own emulator) and alternatives (it has int3_emulate_*) but it can be overengineering. - Add testcases for emulator. Current kprobe smoke test is not arch specific. Maybe better to probe an assembly target code so that it can test "boosted", "emulated" or "int3-single-stepped" cases. Thank you, --- Masami Hiramatsu (1): x86/kprobes: Use int3 instead of debug trap for single-step arch/x86/include/asm/kprobes.h | 21 +- arch/x86/kernel/kprobes/core.c | 515 ++++++++++++++++++++++++++-------------- arch/x86/kernel/traps.c | 3 3 files changed, 351 insertions(+), 188 deletions(-) -- Masami Hiramatsu (Linaro)