Received: by 10.223.164.202 with SMTP id h10csp1239213wrb; Fri, 17 Nov 2017 17:00:09 -0800 (PST) X-Google-Smtp-Source: AGs4zMZDyHRPusGKXj+av/GSN3KcRphhZvUXHonq+iqXOUbkOIQAKEe28otSUV3aAow6RXOVntym X-Received: by 10.84.132.35 with SMTP id 32mr6804526ple.225.1510966809258; Fri, 17 Nov 2017 17:00:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510966809; cv=none; d=google.com; s=arc-20160816; b=M8V+FGE2IfQZTYZLoF4+VwKeWyceur69fORgWuAUOx7bpueNry13mH8iWDMukVdSE5 XtLk064shMwpKfIS8ex2lj12cYPux7Nez4kTn5Z6HIl+smVNBF+znfbei30Bbdd6u+rl Uj1WCChsZOuWsZcIO2jPYA0bYzR8hsjJ1/I1bNGmu1b3oKgzAQS25XTPs/Ww9MPkxfDe RZnvMzmDC4tyO9XvnCbgsOCmss/lDrMzUDqVd2yIor+XN67hZ1gK2Pg9qOF48810DkBG QWtaUoS5GSAqO/ku67XF5bhttySeVyOroeL3qO82WwCTnGLkrW6Nlpy9kOAS5NCloh+k HFIw== 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=fgIl1QB3Zl/YwfVav22f0fK8dC+wvOqgwl2TD15wp3A=; b=aUyEEGy6xySM/ZFDF0y/1WhewUoQcxMUYKAHk483YHIc19pwZZKT0SzYOqUdNO1dzk pSBL3HlN3uVpgG1X7YMcwOrXmM3t9eu60MiWDjmk0VUseKFyv72l12uc86JCVAHrNakl oVNQnpY6l95LxJxsfU7Vx616HZjRsuPtUZG0YF/b2oy5pfpoffFnNKcgrisQeHMP/HXx Ds6dimxhKX/V/SKIqVXpcR2Hk3hOoVsxSSEvThcdqh+J+kBhU8wHyT0MpSi5NFmXwZBs daqzudunHkQnL9mVy2fVS6bcLo0zGvrBkCIkmkCC/UsOczi9aNC7j9Iluk6fgJk+pbUp z15Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=FF9PlaH0; 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 m65si4003047pfj.327.2017.11.17.16.59.33; Fri, 17 Nov 2017 17:00:09 -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=FF9PlaH0; 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 S1754618AbdKQSAS (ORCPT + 93 others); Fri, 17 Nov 2017 13:00:18 -0500 Received: from mail-qk0-f171.google.com ([209.85.220.171]:38877 "EHLO mail-qk0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751022AbdKQSAK (ORCPT ); Fri, 17 Nov 2017 13:00:10 -0500 Received: by mail-qk0-f171.google.com with SMTP id a142so333664qkb.5 for ; Fri, 17 Nov 2017 10:00:10 -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=fgIl1QB3Zl/YwfVav22f0fK8dC+wvOqgwl2TD15wp3A=; b=FF9PlaH0HC2zLFEXOM9Ig/VVkwLAD4fanlPaKW140KX+6ZvbgFy3b0EGwZFJeFAYIs 8VXVv62F/9M76b0jXHnEFXkaClLCBZAjdZEop0M9l0+ZuHJiDrxuNUkSebcqc9QSR5/Q tZmSjFwI7NbhVv16+cvT7itIU8E+RIharksEyth2wrBLMHdNKGhsQj1q/EHOQV/oSAzl kozyH1rOvJRY//IHkKjZzCpV0EvY0Drms6rGSyj4CXd4yPKXOmGmSUfh0+zNWQACUDTT N2gTiTsdcqVw1cb4u8TAau7apdZdw7oPUakIhwyzVNngeAGlW9akOrADg/ckKCdpu3vw sV8Q== 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=fgIl1QB3Zl/YwfVav22f0fK8dC+wvOqgwl2TD15wp3A=; b=gAtFsAKNUMyA8zQQKifQKXuDhBzlpIJJSUgHEGRFBq6XOXdFkblF5dk+eYbk/OCrGd A+CdtfVbdK7DT3Di49CofHHV80uFaUgqdcGqiKSdlMSePLd7kjUfqbwmW3wlG2Y01xgJ JtcFejzArADmhbaLm1n4vmOJhV7qBtTWyDtVd+De81WbVNePzdqihoD7FTqnVepFUVE8 KrPrTKgmsDMe7OPDz1byo28ll0aAVJtrL0Pgrn8P/MOKqi4a+rsRm0YguW6HI9SLv3iI 2U3hdgfVdgTFkwcg8k/McO9zzJ7y4L5Vj49pSEEQ4SUQBrWeNK24rwMSJLFVujAIuYMH lV6g== X-Gm-Message-State: AJaThX5UHbPYeF/xsC10PFA/fA/6A6EotmjbXz8IgXBxRySx4/1C/VjS 7af++7XTm2NvwmMkXL+raHt/VQ== X-Received: by 10.55.72.75 with SMTP id v72mr9717099qka.92.1510941610019; Fri, 17 Nov 2017 10:00:10 -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 6sm2865482qtz.68.2017.11.17.10.00.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Nov 2017 10:00:09 -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 0/4][v6] Add the ability to do BPF directed error injection Date: Fri, 17 Nov 2017 13:00:03 -0500 Message-Id: <1510941607-3997-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 I've reworked this to be opt-in only as per Igno and Alexei. Still needs to go through Dave because of the bpf bits, but I need tracing guys to weigh in and sign off on my approach please. 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 1584377578168357341@xxx Sat Nov 18 04:43:23 +0000 2017 X-GM-THRID: 1584361079802501756 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread