Received: by 10.223.164.202 with SMTP id h10csp676722wrb; Wed, 22 Nov 2017 13:32:59 -0800 (PST) X-Google-Smtp-Source: AGs4zMYQaNrTel6iYK1QFV2nFQ2BDJtEDCffBke962Fc+6p3bwWymxIfjSILM5IyWrlQZ+m2mPup X-Received: by 10.99.112.89 with SMTP id a25mr21800162pgn.2.1511386379485; Wed, 22 Nov 2017 13:32:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511386379; cv=none; d=google.com; s=arc-20160816; b=oY5R7x7CH1jpSsilUqOHYs9IpSXGD30Pk978iuK3jLCNkuPLJUZ3DGU1aZbJjSyo8g wHnp074oCjnVrmI0nG6Bfwsb8CZoq0TxhOTK19R80xxL3k4vXLXI7HhLwZOM/Sh2aihp NM5+eld6pgLB3WGQ8cOZldQURkYuf+4RECIYQcOno1UNXZyo6ZPF49nrMN6J5anod3ME 6DlmUXosJHYV1rhVnnZpouoGyzCKDWSMS0B41wgMyPMHmWRiL2484zl4olyXvcs8y+r/ YO7BouEHHiY1F91nOpXfxuc0wNeLYibs2HGWv8pPCufbq8E8VNX8/KOUYPCfGzlWTy1E 3e4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:to:from :dkim-signature:arc-authentication-results; bh=KoB9jxrEKyk2hLZr8AwsxOA1stySJMiw3OhHNERUwqY=; b=YNdh689wisR78zCYUiU5OC6pDTgOJOXxhkzK4ci14gXy6mKmN1nJwwuk6oaGeC2ziL fRFT+gMdNHOQmvoVsQkdmaQiHdtvVNbM27P9IpOOqSU9739s0aZYAiZA3d/DPKpfTFlQ QPOnGscx1P1T04P8Z7slgMHbk7WKcUnREGMimAdivDD89v2YuNSavKbIm4X47Uvfk6wn Y4V3CT5oCnSCcwxkRk5/UJxM0Z+1pWn8hB7oqbb7ENOjrnXCWuRiWBMYZjM4dhPoU9XV WHFQHxkodV1eWF2kQN8fR0gysvoPuEs8R3x0UCXqbXbtu5Tbv6mG9PDZyLr5H5LbjU+D xgFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=dwagh3fY; 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 e7si14926866plt.807.2017.11.22.13.32.47; Wed, 22 Nov 2017 13:32:59 -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=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=dwagh3fY; 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 S1752045AbdKVVbB (ORCPT + 77 others); Wed, 22 Nov 2017 16:31:01 -0500 Received: from mail-qk0-f182.google.com ([209.85.220.182]:46853 "EHLO mail-qk0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751956AbdKVVXi (ORCPT ); Wed, 22 Nov 2017 16:23:38 -0500 Received: by mail-qk0-f182.google.com with SMTP id b85so18612001qkc.13 for ; Wed, 22 Nov 2017 13:23:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id; bh=KoB9jxrEKyk2hLZr8AwsxOA1stySJMiw3OhHNERUwqY=; b=dwagh3fYBPh/TMESVYnVYXr8jKpo5Ogt8rQshsuSLiLntp9B2tCRgfqEIg25AOCCNQ a2wOfYVqSNpM2m0xK+SztLG4Wmyvd8iIKlBy4Um2/Z7rxYC1/bNVBKpFgFhKplsJb4wp E5lxRT7Z91ILMs4D9NfeOu0jXwIsBr1Crrx2x7kfA1wl34DzZbij4121X4NYMaQK2RL9 kfuN7levqGYJphy5wgfUOTAC8rFmHw5nX0TdQ0/jqObtZ2mJOVMhEf5BkX0Ul7c2NGDK HTsCJ8Oym+KsG2NeNubR55Zb02OpWbwCtJDpt/w6g+XNam6PTXqFzgcFPUBMHo16WJ84 JPEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=KoB9jxrEKyk2hLZr8AwsxOA1stySJMiw3OhHNERUwqY=; b=m/QJJPHxGs/J2YHKp1M0Gdv+fgydIqckiusQiir1+0MuMPbOD40iw7kZ6M3rSsBOXl rD2M8hTZWSPqDkV1fUaYEM4yiVbuzKcz+OXJKU5E47cTvrvBCg33TWeliT0hElBVtikM 2SwJAI74dpQJgi85+RABdwRixStV4t10/a+oW465DXm6yqAZa/QnpMVdtYXuL7aHmd1g XdAc3JWb0sDfhqtAmS4gaiwax194cQoGqoyiI3BEK8U3uC3wPTceXAgUmUZxYNDP9Qy6 cZ2K/s84ZWXaSSD2iIugAhqJf/5uiTe1RHmFBuAoQt3FCMPr5QOlJ++ZNqAmpd/G8aMe qRLQ== X-Gm-Message-State: AJaThX65Ue3IR8urH+vmwUoC2QR7tbedAWxPIHNZDF5PYw9O5e2iNOfK kPoUIYzed+2TFckOo4vaVvZC0A== X-Received: by 10.55.161.78 with SMTP id k75mr35527646qke.158.1511385817435; Wed, 22 Nov 2017 13:23:37 -0800 (PST) Received: from localhost (cpe-2606-A000-4381-1201-225-22FF-FEB3-E51A.dyn6.twc.com. [2606:a000:4381:1201:225:22ff:feb3:e51a]) by smtp.gmail.com with ESMTPSA id d198sm2234496qkg.16.2017.11.22.13.23.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Nov 2017 13:23:36 -0800 (PST) From: Josef Bacik To: 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 Subject: [PATCH v7 0/4] Add the ability to do BPF directed error injection Date: Wed, 22 Nov 2017 16:23:29 -0500 Message-Id: <1511385814-20863-1-git-send-email-josef@toxicpanda.com> X-Mailer: git-send-email 2.7.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is hopefully the final version, I've addressed the comment by Igno and added his Acks. v6->v7: - moved the opt-in macro to bpf.h out of kprobes.h. v5->v6: - add BPF_ALLOW_ERROR_INJECTION() tagging for functions that will support this feature. This way only functions that opt-in will be allowed to be overridden. - added a btrfs patch to allow error injection for open_ctree() so that the bpf sample actually works. v4->v5: - disallow kprobe_override programs from being put in the prog map array so we don't tail call into something we didn't check. This allows us to make the normal path still fast without a bunch of percpu operations. v3->v4: - fix a build error found by kbuild test bot (I didn't wait long enough apparently.) - Added a warning message as per Daniels suggestion. v2->v3: - added a ->kprobe_override flag to bpf_prog. - added some sanity checks to disallow attaching bpf progs that have ->kprobe_override set that aren't for ftrace kprobes. - added the trace_kprobe_ftrace helper to check if the trace_event_call is a ftrace kprobe. - renamed bpf_kprobe_state to bpf_kprobe_override, fixed it so we only read this value in the kprobe path, and thus only write to it if we're overriding or clearing the override. v1->v2: - moved things around to make sure that bpf_override_return could really only be used for an ftrace kprobe. - killed the special return values from trace_call_bpf. - renamed pc_modified to bpf_kprobe_state so bpf_override_return could tell if it was being called from an ftrace kprobe context. - reworked the logic in kprobe_perf_func to take advantage of bpf_kprobe_state. - updated the test as per Alexei's review. - Original message - A lot of our error paths are not well tested because we have no good way of injecting errors generically. Some subystems (block, memory) have ways to inject errors, but they are random so it's hard to get reproduceable results. With BPF we can add determinism to our error injection. We can use kprobes and other things to verify we are injecting errors at the exact case we are trying to test. This patch gives us the tool to actual do the error injection part. It is very simple, we just set the return value of the pt_regs we're given to whatever we provide, and then override the PC with a dummy function that simply returns. Right now this only works on x86, but it would be simple enough to expand to other architectures. Thanks, Josef From 1585123637585787565@xxx Sun Nov 26 10:21:41 +0000 2017 X-GM-THRID: 1585123637585787565 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread