Received: by 10.213.65.16 with SMTP id m16csp263383imf; Mon, 12 Mar 2018 03:02:31 -0700 (PDT) X-Google-Smtp-Source: AG47ELupkkpIl1yj9pPnOgPBuk0bxu5jwAfs14RV6O//MluxwoofEsbyz3F3du87l5tiJFnokxsJ X-Received: by 10.98.166.85 with SMTP id t82mr7378646pfe.237.1520848951234; Mon, 12 Mar 2018 03:02:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520848951; cv=none; d=google.com; s=arc-20160816; b=JUCer7Sd7mW91XZA+T7zjLiZbw8aYNAIiH+BDQ3CUErYTBjkc8xU0FjDb7C08T5VdN 7IorkYqINm6T3VXIc+5yMT8g+RTvKRNyMSm8RDh1eRRc7YsJ5szMeY9kB68Wq5L+Xjta OUK2RA7GRHzqP0BoUijyyQIfSiy1SALlSnhFVlUgwxbULl8wtpkiU0EL11XDNEOTPKRM vZIgvuAU78B8ETgRyDSZg3PJpGOyV3kdW5ceMHH5E0j0pul1YUSDWGkEN7mt+6MuJCml 9mINgNOER0THpZn4lKaDBen5Uo8TWk3zeYnmfhzik31ISe0GRwp3rNMe9jBbkverUDq2 Qypg== 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:dmarc-filter :arc-authentication-results; bh=vGX5pUJLf9bw8z1mG/TKsgLVVE3vPNwpVLDapXYpjnU=; b=MWotqgsgayvbsmcRlbDCEDCcpFG/o3+gBuqepblmoAK0Fm3CUFhMZaIKmEoERDXhtI c0PUdOGjy8XUgVpNYr8hRixeEds1WfVmJ1uPXvy4WwiodkmNnK1QVhO+F4iq00eV+LG9 RoUMDcZaaetkKoOy3kpicaJWNSq7KQr0asqlcPBCtRuve7RO1jDzX7ZU0xU0EdLXntAB d0r/RUGQ7/yQ4AcUuERagsF22lrlUXTlo1ectmQK+9UvcFkr7nq9quEV0wN4isqD+Gny ejhouvoqK+5J8VXpp1PidyGiXVw7x5HObxS5mdUt78cAtqZxoOo/HOg0OxvNGZiK9Mtd TlaQ== 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 w11si4807982pgo.826.2018.03.12.03.02.16; Mon, 12 Mar 2018 03:02:31 -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 S1752655AbeCLKBT (ORCPT + 99 others); Mon, 12 Mar 2018 06:01:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:51468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751543AbeCLKBP (ORCPT ); Mon, 12 Mar 2018 06:01:15 -0400 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 C8DEE205F4; Mon, 12 Mar 2018 10:01:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C8DEE205F4 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 From: Masami Hiramatsu To: Alexei Starovoitov , Josef Bacik Cc: 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, mhiramat@kernel.org, Josef Bacik , Akinobu Mita Subject: [BUGFIX PATCH bpf-next] error-injection: Fix to prohibit jump optimization Date: Mon, 12 Mar 2018 19:00:49 +0900 Message-Id: <152084884886.1536.4464134247603910765.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 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. 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); }