Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1623950yba; Thu, 25 Apr 2019 03:01:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqzeT4pk9S1Q0JdifSIRNFsROwQ++nwxYWNXJWPfT/S5p8klQhyieRBHTg87sH9CDKJcdpSQ X-Received: by 2002:a63:121f:: with SMTP id h31mr36147941pgl.287.1556186507726; Thu, 25 Apr 2019 03:01:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556186507; cv=none; d=google.com; s=arc-20160816; b=K+zhRe/VyEkPWxgBdzCJ+DJonXo8PkF6EBn7XPPvcdU6mtwObjrmvFfim23QLc98z7 pYwwstqPfN1EMai4rT+5Xxwjznqi1WDRKmnc3xyj5O69CTbxhDtCCl2xnEMlAE7AzQb/ IbIdcJrBPQlu8Lrymxn9924743BSYw8DyNEoud4SkocWkA92nQ2pw3xCmiWk3JFnUfDJ YeJhR+SjgmEjeADoSsm1uKjtWCP4Jr5z0xPoVy3vc1J0ZnGWSwZUAvyDF2+goKz8t7V0 DV4Ql32pqldlfpQznGUF7YLZ2nRfk2uCI/al8aMFLYtRHaH/AToL4Xa4BIEOTCuS5IDI Xl0Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=yAtvfpbreo1+TQY+KrNZG9h3fZsfDQzNvha7lc7f0tg=; b=q1YTJbx+t/6RxZ+09FXaEmQeV3GllQhVkTxw/vBRmkR1wpkE/+rLCHI81UkdUIbvvR pcsIaot3T4gt4EBs1DSMu4+eswAWTFsHo5CoFZZX5bM6x7GDXS9MaFrG3gbaoijfyq1b IFA236DWCqDpFk+YNJ09LMYH70mZtKnvP25i9kwjssFFOOCQx1RzlRA4vY1jVlwsy7Ir BrVWPefo1QvbYW5862TSvK9h0FxSoxgUxkntUGdANQGMejtqkpGEgCPP1muaAwau0umu Do7Ui8vjhZK0pbvxphVt/McWcKKwaOB9eZWlS5Ox9KDigOmvlPHe9aj4M9uc3qvs+Qju Oj6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=ViqkAqCn; 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=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p85si22397917pfi.27.2019.04.25.03.01.31; Thu, 25 Apr 2019 03:01:47 -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=@fb.com header.s=facebook header.b=ViqkAqCn; 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=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388764AbfDXTH5 (ORCPT + 99 others); Wed, 24 Apr 2019 15:07:57 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:36960 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730531AbfDXTH5 (ORCPT ); Wed, 24 Apr 2019 15:07:57 -0400 Received: from pps.filterd (m0001255.ppops.net [127.0.0.1]) by mx0b-00082601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3OJ3O4V018909; Wed, 24 Apr 2019 12:07:37 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=facebook; bh=yAtvfpbreo1+TQY+KrNZG9h3fZsfDQzNvha7lc7f0tg=; b=ViqkAqCnwtAAmeWqpQ06th31RtukqC/1gdWj87zEUGBgdiMgjnUe7keCJdrugGvgfeJZ u+v/EINijhckJE8SKCsCjIjJNSFGE2+LKnh1qZ+VhRxa/vevge/YfSjtNd8GiNMsNICJ Q2byitxj4WrjfF76JX7Co47PBEgWJ2TCCEs= Received: from mail.thefacebook.com (mailout.thefacebook.com [199.201.64.23]) by mx0b-00082601.pphosted.com with ESMTP id 2s27u3w3kk-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 24 Apr 2019 12:07:37 -0700 Received: from mmullins-1.thefacebook.com (2620:10d:c081:10::13) by mail.thefacebook.com (2620:10d:c081:35::127) with Microsoft SMTP Server id 15.1.1713.5; Wed, 24 Apr 2019 12:07:30 -0700 From: Matt Mullins To: , , , , CC: , Daniel Borkmann , Martin KaFai Lau , Song Liu , "Yonghong Song" Subject: [PATCH bpf-next v4 0/5] writable contexts for bpf raw tracepoints Date: Wed, 24 Apr 2019 12:07:16 -0700 Message-ID: <20190424190721.24453-1-mmullins@fb.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [2620:10d:c081:10::13] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-04-24_12:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds an opt-in interface for tracepoints to expose a writable context to BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE programs that are attached, while supporting read-only access from existing BPF_PROG_TYPE_RAW_TRACEPOINT programs, as well as from non-BPF-based tracepoints. The initial motivation is to support tracing that can be observed from the remote end of an NBD socket, e.g. by adding flags to the struct nbd_request header. Earlier attempts included adding an NBD-specific tracepoint fd, but in code review, I was recommended to implement it more generically -- as a result, this patchset is far simpler than my initial try. v3->v4: * fixed a silly copy/paste typo in include/trace/events/bpf_test_run.h (_TRACE_NBD_H -> _TRACE_BPF_TEST_RUN_H) * fixed incorrect/misleading wording in patch 1's commit message, since the pointer cannot be directly dereferenced in a BPF_PROG_TYPE_RAW_TRACEPOINT * cleaned up the error message wording if the prog_tests fail * Addressed feedback from Yonghong * reject non-pointer-sized accesses to the buffer pointer * use sizeof(struct nbd_request) as one-byte-past-the-end in raw_tp_writable_reject_nbd_invalid.c * use BPF_MOV64_IMM instead of BPF_LD_IMM64 v2->v3: * Andrew addressed Josef's comments: * C-style commenting in nbd.c * Collapsed identical events into a single DECLARE_EVENT_CLASS. This saves about 2kB of kernel text v1->v2: * add selftests * sync tools/include/uapi/linux/bpf.h * reject variable offset into the buffer * add string representation of PTR_TO_TP_BUFFER to reg_type_str Andrew Hall (1): nbd: add tracepoints for send/receive timing Matt Mullins (4): bpf: add writable context for raw tracepoints nbd: trace sending nbd requests tools: sync bpf.h selftests: bpf: test writable buffers in raw tps MAINTAINERS | 1 + drivers/block/nbd.c | 13 +++ include/linux/bpf.h | 2 + include/linux/bpf_types.h | 1 + include/linux/tracepoint-defs.h | 1 + include/trace/bpf_probe.h | 27 ++++- include/trace/events/bpf_test_run.h | 50 ++++++++ include/trace/events/nbd.h | 107 ++++++++++++++++++ include/uapi/linux/bpf.h | 1 + kernel/bpf/syscall.c | 8 +- kernel/bpf/verifier.c | 31 +++++ kernel/trace/bpf_trace.c | 24 ++++ net/bpf/test_run.c | 4 + tools/include/uapi/linux/bpf.h | 1 + tools/lib/bpf/libbpf.c | 1 + tools/lib/bpf/libbpf_probes.c | 1 + .../raw_tp_writable_reject_nbd_invalid.c | 42 +++++++ .../bpf/prog_tests/raw_tp_writable_test_run.c | 80 +++++++++++++ .../selftests/bpf/verifier/raw_tp_writable.c | 34 ++++++ 19 files changed, 425 insertions(+), 4 deletions(-) create mode 100644 include/trace/events/bpf_test_run.h create mode 100644 include/trace/events/nbd.h create mode 100644 tools/testing/selftests/bpf/prog_tests/raw_tp_writable_reject_nbd_invalid.c create mode 100644 tools/testing/selftests/bpf/prog_tests/raw_tp_writable_test_run.c create mode 100644 tools/testing/selftests/bpf/verifier/raw_tp_writable.c -- 2.17.1