Received: by 10.213.65.16 with SMTP id m16csp275473imf; Mon, 12 Mar 2018 03:29:14 -0700 (PDT) X-Google-Smtp-Source: AG47ELvwSv24E20t7O89o2mZds04bDHZMnxXB1//gYODYTVrINQ+gKZ598Ke3B4X340iWoUe4LC8 X-Received: by 2002:a17:902:9307:: with SMTP id bc7-v6mr7652827plb.29.1520850554388; Mon, 12 Mar 2018 03:29:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520850554; cv=none; d=google.com; s=arc-20160816; b=g3jp7gyi8YGtl7jzAu3wmaG+PBrI0EbG7WRpmRFAfG6FBf2nrZf3FMqu9rVOJ5ugmx C5yiQFxWXIm/bOXwsqgYZyW9D793AYn/Flj1u3my66fHbtSeflm1Mw8UgUn+24pwjOlz lNNg4lOfehNs/d6Tnm0IU0RMRhYhhjwwhZSHnIIZ/kPcV8vhKFGjDefzXN74PfOdmmJr zvdAbUrjJQbYNyByx6nOsLX2xuj4WSG9/FyZY2SxqRL+I5dlGOclyMh96KFMYbTrIMin jdycFibufFFIwT3woESI8mEUPprlr0bfqqYbKsVmDWdslr36a83A52Q+vjD0Ar02Aaqt iLjg== 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 :dmarc-filter:arc-authentication-results; bh=16umVps84pgjSa/or5cdTvgYsjKTUmtwheCnvxp2iiM=; b=s1pIDENJMbJTiGFQmpGUTppK7DRPRk8MkhT4tBbNs5QHatb2fEhwIy2OA78qLDPd0t aLV0kwZocE4ONZPhhDODBzn/e+elZuDvZ7BxWYNj/b4SOmhfSoKwCkA3wr0d/MEb56w0 /oAet9VLuyFhKwClgnjrTs5biLdwVTNJBoLaZo+leTZ1URdGNNhjDV2h98uruUpSi/WO XVo6LEgMSqv5a9V+CNI5Yn0j8qeM1qKC5mj6i66f4lUdVsZMNbPavKjiN/a8uLOZdyhU CXXgvPNjKT3Tfim9KZz0bu8R48xrNGbHqAttt0XkNMKvDd3lX1LkPKpk0zaTx5aEd2pl mX7Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w1si4780289pgq.135.2018.03.12.03.28.59; Mon, 12 Mar 2018 03:29:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752636AbeCLK1o (ORCPT + 99 others); Mon, 12 Mar 2018 06:27:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:53918 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751303AbeCLK1n (ORCPT ); Mon, 12 Mar 2018 06:27:43 -0400 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 5B930208FE; Mon, 12 Mar 2018 10:27:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B930208FE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=mhiramat@kernel.org Date: Mon, 12 Mar 2018 19:27:38 +0900 From: Masami Hiramatsu To: Masami Hiramatsu Cc: Alexei Starovoitov , Josef Bacik , rostedt@goodmis.org, mingo@redhat.com, davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ast@kernel.org, kernel-team@fb.com, daniel@iogearbox.net, linux-btrfs@vger.kernel.org, darrick.wong@oracle.com, Josef Bacik , Akinobu Mita Subject: Re: [BUGFIX PATCH bpf-next] error-injection: Fix to prohibit jump optimization Message-Id: <20180312192738.77061ec53f9437d960b437d9@kernel.org> In-Reply-To: <152084884886.1536.4464134247603910765.stgit@devbox> References: <152084884886.1536.4464134247603910765.stgit@devbox> 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, 12 Mar 2018 19:00:49 +0900 Masami Hiramatsu wrote: > Since the kprobe which was optimized by jump can not change > the execution path, the kprobe for error-injection must not > be optimized. To prohibit it, set a dummy post-handler as > officially stated in Documentation/kprobes.txt. Note that trace-probe based BPF is not affected, because it ensures the trace-probe is based on ftrace, which is not jump optimized. Thanks, > > Fixes: 4b1a29a7f542 ("error-injection: Support fault injection framework") > Signed-off-by: Masami Hiramatsu > --- > kernel/fail_function.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/kernel/fail_function.c b/kernel/fail_function.c > index 21b0122cb39c..1d5632d8bbcc 100644 > --- a/kernel/fail_function.c > +++ b/kernel/fail_function.c > @@ -14,6 +14,15 @@ > > static int fei_kprobe_handler(struct kprobe *kp, struct pt_regs *regs); > > +static void fei_post_handler(struct kprobe *kp, struct pt_regs *regs, > + unsigned long flags) > +{ > + /* > + * A dummy post handler is required to prohibit optimizing, because > + * jump optimization does not support execution path overriding. > + */ > +} > + > struct fei_attr { > struct list_head list; > struct kprobe kp; > @@ -56,6 +65,7 @@ static struct fei_attr *fei_attr_new(const char *sym, unsigned long addr) > return NULL; > } > attr->kp.pre_handler = fei_kprobe_handler; > + attr->kp.post_handler = fei_post_handler; > attr->retval = adjust_error_retval(addr, 0); > INIT_LIST_HEAD(&attr->list); > } > -- Masami Hiramatsu