Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10690506ybi; Thu, 25 Jul 2019 03:43:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxxlhJwo87daNu8BaYZkKLHmfPTtoWcEpgDnHq2CbVkjcvSVM9myc4q4jx3hK/Etf/pjex X-Received: by 2002:aa7:9e9a:: with SMTP id p26mr16365195pfq.25.1564051390530; Thu, 25 Jul 2019 03:43:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564051390; cv=none; d=google.com; s=arc-20160816; b=Dt3BbdrYPIcN24DwilMuUS2PB0u9YRI1v0KIAiHAHSA3WLKztR16nLwFgfcgawpRTl zQcx/pCkw+dYvDLvylufysJKA6unTmra7IgWMdtE/W40J0lW4FPxoVqKdqh2F3mP1XrV XmYHPw8Wt3eDgoMB8eeOP/TOCR8oXKTbJiEJ9u9iFgvqO2a6tUTodeUF7hcMi/uH7oyr cHQDWbFaw0HrNZsyqHn9pGIUYnynyw2rn+LHtRPtE4lNksraRD6LoOvu4Ud1+nRi0+lW 3N/SEY7wTfbou0zTy2tWOvAJibN7OTLFKuyXXgSCBYx6QbTnrqa5EU+e8yqDDQK18ITD wR4A== 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=XkWRDR2MCYM/S8kD9Uvniq2vntq9mn5pfex61xvMdz4=; b=oABOPoWHqyhdytOmLiIxCUwr/vaOyd56KuLMj4jGm+sqU9OliO0hr4vQV91m6+oP1F re1sUntcCVs9TJgfc54OWJoW2ThqWhHjgX/EQOpmk7b1o14yLqMmXnT95ETcYEXPDJ8Y 1pwiz7a7PmI2HL/zI6Dit+C8/KHrX270yOZ0G0cD7PfYhtZSuuEmv5puIHHCfq3V5qes ZbHtjrcezEeATEsVaJJp6NLoM1qEIWb4g0wEgg9qVLl4gte0hK64vuizMRMs0HzwMCim 3N/KoM16qc/CjfFB/zDtfW2fqgbW745PhwL+A1usAmW5yhJnikEb9BZeYmQabhxGRPWu gecA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B0SM0Rbw; 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 44si16686102plb.366.2019.07.25.03.42.48; Thu, 25 Jul 2019 03:43:10 -0700 (PDT) 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=B0SM0Rbw; 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 S2388058AbfGYAnU (ORCPT + 99 others); Wed, 24 Jul 2019 20:43:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:50620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387913AbfGYAnU (ORCPT ); Wed, 24 Jul 2019 20:43:20 -0400 Received: from devnote2 (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 4AC4521901; Thu, 25 Jul 2019 00:43:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564015399; bh=K8suSIkZbvT0UfyneKMgJFCJCtS7yG8oOJLvoqvjUxU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=B0SM0Rbw5qI6IKvksMncpNpSmkg3vyt+kn7m4AS5hdVepz+V0YFkVrB+PgbWS9Zaq 3gEPAo/wJz3KPL+NYSKAwbXPKlco7lXaaHydtVfFBTEwUZAp/dBiyZIgyUpM8YXNUp EOv2wk5AcbNxxqvFi4kgXZqWK0DmsfcvAcCVi2mY= Date: Thu, 25 Jul 2019 09:43:16 +0900 From: Masami Hiramatsu To: Masami Hiramatsu Cc: Joe Lawrence , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: kprobes, livepatch and FTRACE_OPS_FL_IPMODIFY Message-Id: <20190725094316.c6bf2524e4e925d9cc5937d1@kernel.org> In-Reply-To: <20190725093208.343db9d54f6a0f5abc99af7b@kernel.org> References: <20190724151942.GA7205@redhat.com> <20190725093208.343db9d54f6a0f5abc99af7b@kernel.org> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-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 Hi Joe, On Thu, 25 Jul 2019 09:32:08 +0900 Masami Hiramatsu wrote: > NO, that flag has been shared among all ftrace-based kprobes, and checked > when registering. So what we need is to introduce a new kprobe flag which > states that this kprobe doesn't modify regs->ip. And kprobe prepare 2 ftrace_ops > 1 is for IPMODIFY and 1 is for !IPMODIFY. Ah, OK. We don't even need the new flag. ----- The jump optimization changes the kprobe's pre_handler behavior. Without optimization, the pre_handler can change the kernel's execution path by changing regs->ip and returning 1. However, when the probe is optimized, that modification is ignored. Thus, if you want to tweak the kernel's execution path, you need to suppress optimization, using one of the following techniques: - Specify an empty function for the kprobe's post_handler. or - Execute 'sysctl -w debug.kprobes_optimization=n' ----- So if we remove latter one, all kprobes which change regs->ip must set a dummy post_handler. Thank you, -- Masami Hiramatsu