Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically include ZFS paths when they exists #7

Merged
merged 2 commits into from
Nov 8, 2019

Conversation

prakashsurya
Copy link
Contributor

No description provided.

@prakashsurya
Copy link
Contributor Author

git-ab-pre-push is here

@prakashsurya
Copy link
Contributor Author

cc: @sebroy

@sebroy sebroy merged commit 31a7a0b into delphix:6.0/release Nov 8, 2019
delphix-devops-bot pushed a commit that referenced this pull request Mar 21, 2020
This fixes the following error.

```
% sudo ./src/bpftrace -e 'w::0x10000000:8:: {}'
AddressSanitizer:DEADLYSIGNAL
=================================================================
==26761==ERROR: AddressSanitizer: SEGV on unknown address 0x614000010000 (pc 0x0000008dc6b6 bp 0x7ffe172080c0 sp 0x7ffe17207540 T0)
==26761==The signal is caused by a READ memory access.
    #0 0x8dc6b6 in bpftrace::ast::SemanticAnalyser::visit(bpftrace::ast::AttachPoint&) /home/ubuntu/work/bpftrace/bpftrace/build_asan/../src/ast/semantic_analyser.cpp:1684:25
    #1 0x87c3e3 in bpftrace::ast::AttachPoint::accept(bpftrace::ast::Visitor&) /home/ubuntu/work/bpftrace/bpftrace/build_asan/../src/ast/ast.cpp:323:5
    #2 0x8dd1bc in bpftrace::ast::SemanticAnalyser::visit(bpftrace::ast::Probe&) /home/ubuntu/work/bpftrace/bpftrace/build_asan/../src/ast/semantic_analyser.cpp:1737:9
    #3 0x87c603 in bpftrace::ast::Probe::accept(bpftrace::ast::Visitor&) /home/ubuntu/work/bpftrace/bpftrace/build_asan/../src/ast/ast.cpp:355:5
    #4 0x8dd2eb in bpftrace::ast::SemanticAnalyser::visit(bpftrace::ast::Program&) /home/ubuntu/work/bpftrace/bpftrace/build_asan/../src/ast/semantic_analyser.cpp:1751:12
    #5 0x87c6b3 in bpftrace::ast::Program::accept(bpftrace::ast::Visitor&) /home/ubuntu/work/bpftrace/bpftrace/build_asan/../src/ast/ast.cpp:364:5
    #6 0x8dd35a in bpftrace::ast::SemanticAnalyser::analyse() /home/ubuntu/work/bpftrace/bpftrace/build_asan/../src/ast/semantic_analyser.cpp:1760:12
    #7 0x80f63f in main /home/ubuntu/work/bpftrace/bpftrace/build_asan/../src/main.cpp:577:19
    #8 0x7fec4efa5b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
    #9 0x5c1e39 in _start (/home/ubuntu/work/bpftrace/bpftrace/build_asan/src/bpftrace+0x5c1e39)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/ubuntu/work/bpftrace/bpftrace/build_asan/../src/ast/semantic_analyser.cpp:1684:25 in bpftrace::ast::SemanticAnalyser::visit(bpftrace::ast::AttachPoint&)
==26761==ABORTING
```

This is because `ap.mode.size()` is zero (`ap.mode` is a empty string)
and `ap.mode.size() - 1` causes underflow (`size_t` is unsigned).

https://github.com/iovisor/bpftrace/blob/96b6eb83c93668fd1e54147c8e1929fedd571dac/src/ast/semantic_analyser.cpp#L1683-L1684

With this patch,

```
% sudo ./src/bpftrace -e 'w::0x10000000:8:: {}'
stdin:1:1-18: ERROR: watchpoint mode must be combination of (r,w,x)
w::0x10000000:8:: {}
~~~~~~~~~~~~~~~~
```
delphix-devops-bot pushed a commit that referenced this pull request Apr 17, 2020
This prevents the error like the follwing:

```
% sudo ASAN_OPTIONS=detect_leaks=0 ./src/bpftrace -e 'BEGIN { @ = max(exit()); }'
AddressSanitizer:DEADLYSIGNAL
=================================================================
==25253==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00000089e3dc bp 0x7fff0bf07270 sp 0x7fff0bf07270 T0)
==25253==The signal is caused by a READ memory access.
==25253==Hint: address points to the zero page.
    #0 0x89e3dc in llvm::Value::getType() const /usr/lib/llvm-10/include/llvm/IR/Value.h:246:34
    #1 0x89cd6e in llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>::CreateIntCast(llvm::Value*, llvm::Type*, bool, llvm::Twine const&) /usr/lib/llvm-10/include/llvm/IR/IRBuilder.h:2172:12
    #2 0x889ad5 in bpftrace::ast::CodegenLLVM::visit(bpftrace::ast::Call&) /home/ubuntu/work/bpftrace/bpftrace/src/ast/codegen_llvm.cpp:328:16
    #3 0x880160 in bpftrace::ast::Call::accept(bpftrace::ast::Visitor&) /home/ubuntu/work/bpftrace/bpftrace/src/ast/ast.cpp:129:5
    #4 0x8966c0 in bpftrace::ast::CodegenLLVM::visit(bpftrace::ast::AssignMapStatement&) /home/ubuntu/work/bpftrace/bpftrace/src/ast/codegen_llvm.cpp:1315:20
    #5 0x880fa3 in bpftrace::ast::AssignMapStatement::accept(bpftrace::ast::Visitor&) /home/ubuntu/work/bpftrace/bpftrace/src/ast/ast.cpp:284:5
    #6 0x897a70 in bpftrace::ast::CodegenLLVM::visit(bpftrace::ast::Probe&) /home/ubuntu/work/bpftrace/bpftrace/src/ast/codegen_llvm.cpp:1510:13
    #7 0x8815f3 in bpftrace::ast::Probe::accept(bpftrace::ast::Visitor&) /home/ubuntu/work/bpftrace/bpftrace/src/ast/ast.cpp:355:5
    #8 0x89895b in bpftrace::ast::CodegenLLVM::visit(bpftrace::ast::Program&) /home/ubuntu/work/bpftrace/bpftrace/src/ast/codegen_llvm.cpp:1601:12
    #9 0x8816a3 in bpftrace::ast::Program::accept(bpftrace::ast::Visitor&) /home/ubuntu/work/bpftrace/bpftrace/src/ast/ast.cpp:364:5
    #10 0x89b397 in bpftrace::ast::CodegenLLVM::compile(bpftrace::DebugLevel, std::ostream&) /home/ubuntu/work/bpftrace/bpftrace/src/ast/codegen_llvm.cpp:2019:10
    #11 0x813f3c in main /home/ubuntu/work/bpftrace/bpftrace/src/main.cpp:589:22
    #12 0x7f2794c4db96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
    #13 0x5c64c9 in _start (/home/ubuntu/work/bpftrace/bpftrace/build_llvm10/src/bpftrace+0x5c64c9)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /usr/lib/llvm-10/include/llvm/IR/Value.h:246:34 in llvm::Value::getType() const
==25253==ABORTING
```
delphix-devops-bot pushed a commit that referenced this pull request Oct 22, 2020
The expr_ of a PositionalParameter is a pointer to a buffer, and an
offset can be added to it (e.g., `str($1 + 1)`). Cast expr_ to int so
that llvm does not complain about type mismatches when operating addition.

This fixes the following error reported by AddressSanitizer.

```
% sudo ./src/bpftrace -e 'BEGIN { printf("%s", str($1 + 1)); exit(); }' hello
AddressSanitizer:DEADLYSIGNAL
=================================================================
==3979==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000f8b (pc 0x7f1947a755ba bp 0x60700000def0 sp 0x7ffc07b486b0 T0)
==3979==The signal is caused by a READ memory access.
==3979==Hint: address points to the zero page.
    #0 0x7f1947a755ba in llvm::Constant::isNullValue() const (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0xa735ba)
    #1 0x7f1948826177 in llvm::LazyValueInfo::getPredicateAt(unsigned int, llvm::Value*, llvm::Constant*, llvm::Instruction*) (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x1824177)
    #2 0x7f194841e4a8  (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x141c4a8)
    #3 0x7f1948420049  (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x141e049)
    #4 0x7f1947b13ed5 in llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0xb11ed5)
    #5 0x7f194879ca90  (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0x179aa90)
    #6 0x7f1947b145ff in llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0xb125ff)
    #7 0x851bbe in bpftrace::ast::CodegenLLVM::optimize() /home/ubuntu/work/bpftrace/bpftrace/src/ast/codegen_llvm.cpp:2720:6
    #8 0x791416 in main /home/ubuntu/work/bpftrace/bpftrace/src/main.cpp:745:10
    #9 0x7f1945cc8b96 in __libc_start_main /build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:310
    #10 0x4d1c79 in _start (/home/ubuntu/work/bpftrace/bpftrace/build_dev/src/bpftrace+0x4d1c79)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/usr/lib/x86_64-linux-gnu/libLLVM-10.so.1+0xa735ba) in llvm::Constant::isNullValue() const
==3979==ABORTING
```
delphix-devops-bot pushed a commit that referenced this pull request Jan 14, 2021
I though #1572 fixes the issue of invalid tuple creation, but there is
another issue. libfuzzer found the following:

```
% sudo ./src/bpftrace -e 'BEGIN { (1, !(int1)1); }'
/disk/work/bpftrace2/src/struct.cpp:29:37: runtime error: division by zero
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /disk/work/bpftrace2/src/struct.cpp:29:37 in
AddressSanitizer:DEADLYSIGNAL
=================================================================
==46777==ERROR: AddressSanitizer: FPE on unknown address 0x00000000b6b9 (pc 0x0000009aa53c bp 0x7fffffff68d0 sp 0x7fffffff64a0 T0)
    #0 0x9aa53c in bpftrace::Tuple::Create(std::vector<bpftrace::SizedType, std::allocator<bpftrace::SizedType> >) /disk/work/bpftrace2/src/struct.cpp:29:37
    #1 0x9cb00a in bpftrace::CreateTuple(std::vector<bpftrace::SizedType, std::allocator<bpftrace::SizedType> > const&) /disk/work/bpftrace2/src/types.cpp:443:20
    #2 0xc9dd2c in bpftrace::ast::SemanticAnalyser::visit(bpftrace::ast::Tuple&) /disk/work/bpftrace2/src/ast/semantic_analyser.cpp:1994:16
    #3 0xa8048b in bpftrace::ast::Tuple::accept(bpftrace::ast::Visitor&) /disk/work/bpftrace2/src/ast/ast.cpp:31:1
    #4 0xc9e116 in bpftrace::ast::SemanticAnalyser::visit(bpftrace::ast::ExprStatement&) /disk/work/bpftrace2/src/ast/semantic_analyser.cpp:1999:14
    #5 0xa805eb in bpftrace::ast::ExprStatement::accept(bpftrace::ast::Visitor&) /disk/work/bpftrace2/src/ast/ast.cpp:32:1
    #6 0xcbb643 in bpftrace::ast::SemanticAnalyser::visit(bpftrace::ast::Probe&) /disk/work/bpftrace2/src/ast/semantic_analyser.cpp:2473:11
    #7 0xa8124b in bpftrace::ast::Probe::accept(bpftrace::ast::Visitor&) /disk/work/bpftrace2/src/ast/ast.cpp:41:1
    #8 0xcbb97d in bpftrace::ast::SemanticAnalyser::visit(bpftrace::ast::Program&) /disk/work/bpftrace2/src/ast/semantic_analyser.cpp:2481:12
    #9 0xa813ab in bpftrace::ast::Program::accept(bpftrace::ast::Visitor&) /disk/work/bpftrace2/src/ast/ast.cpp:42:1
    #10 0xcbbda0 in bpftrace::ast::SemanticAnalyser::analyse() /disk/work/bpftrace2/src/ast/semantic_analyser.cpp:2490:12
    #11 0xa474fa in main /disk/work/bpftrace2/src/main.cpp:738:19
    #12 0x7fffed57e0b2 in __libc_start_main /build/glibc-ZN95T4/glibc-2.31/csu/../csu/libc-start.c:308:16
    #13 0x4fe68d in _start (/disk/work/bpftrace2/build/src/bpftrace+0x4fe68d)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: FPE /disk/work/bpftrace2/src/struct.cpp:29:37 in bpftrace::Tuple::Create(std::vector<bpftrace::SizedType, std::allocator<bpftrace::SizedType> >)
==46777==ABORTING
```

In this case, `elem->type` is `int` because of `!`, but its size is zero
and that causes the problem. To fix issue, don't create tuple if an
elemenet size is zero.
delphix-devops-bot pushed a commit that referenced this pull request Jul 3, 2024
If it is dummy, then the visit() operation should not be executed. For
example, on aarch64, there is no syscalls:sys_{enter,exit}_open
tracepoint, however, opensnoop.bt tool will try to attch them and visit
args's field. We expect to get a warning, but instead we get a segmentation
fault. As follows:

    $ sudo gdb bpftrace
    ...
    (gdb) set args opensnoop.bt
    (gdb) r
    opensnoop.bt:22-24: WARNING: tracepoint not found: syscalls:sys_enter_open
    opensnoop.bt:28-30: WARNING: tracepoint not found: syscalls:sys_exit_open

    Thread 1 "bpftrace" received signal SIGSEGV, Segmentation fault.
    0x000000000052bbd8 in __gnu_cxx::__normal_iterator<bpftrace::Field const*, std::vector<bpftrace::Field, std::allocator<bpftrace::Field> > >::__normal_iterator (this=0xffffffffb0b8, __i=<error reading variable: Cannot access memory at address 0x10>)
        at /usr/include/c++/14/bits/stl_iterator.h:1068
    1068              : _M_current(__i) { }
    (gdb) bt
    #0  0x000000000052bbd8 in __gnu_cxx::__normal_iterator<bpftrace::Field const*, std::vector<bpftrace::Field, std::allocator<bpftrace::Field> > >::__normal_iterator (this=0xffffffffb0b8,
        __i=<error reading variable: Cannot access memory at address 0x10>) at /usr/include/c++/14/bits/stl_iterator.h:1068
    #1  0x0000000000525bdc in std::vector<bpftrace::Field, std::allocator<bpftrace::Field> >::begin (this=0x10)
        at /usr/include/c++/14/bits/stl_vector.h:884
    #2  0x000000000059ce8c in bpftrace::Struct::GetField (this=0x0, name="filename")
        at /home/rongtao/Git/bpftrace/bpftrace/src/struct.cpp:131
    #3  0x00000000005a70a0 in bpftrace::SizedType::GetField (this=0xe9b998, name="filename")
        at /home/rongtao/Git/bpftrace/bpftrace/src/types.cpp:538
    #4  0x00000000007c7178 in bpftrace::ast::CodegenLLVM::visit (this=0xffffffffc650, acc=...)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:1973
    #5  0x0000000000847db0 in bpftrace::ast::FieldAccess::accept (this=0xe9be30, v=...)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/ast.cpp:31
    #6  0x00000000007d2404 in bpftrace::ast::CodegenLLVM::accept (this=0xffffffffc650, node=0xe9be30)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:3778
    #7  0x00000000007c8bec in bpftrace::ast::CodegenLLVM::visit (this=0xffffffffc650, assignment=...)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:2218
    #8  0x0000000000847eb4 in bpftrace::ast::AssignMapStatement::accept (this=0xffffe4429250, v=...)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/ast.cpp:36
    #9  0x00000000007d2404 in bpftrace::ast::CodegenLLVM::accept (this=0xffffffffc650, node=0xffffe4429250)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:3778
    #10 0x00000000007ca4c4 in bpftrace::ast::CodegenLLVM::generateProbe (this=0xffffffffc650, probe=..., full_func_id="dummy",
        name="dummy", func_type=0xff2b50, usdt_location_index=std::optional [no contained value], dummy=true)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:2539
    #11 0x00000000007cb4e4 in bpftrace::ast::CodegenLLVM::visit (this=0xffffffffc650, probe=...)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:2734
    #12 0x00000000008480f0 in bpftrace::ast::Probe::accept (this=0xffffe4427650, v=...)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/ast.cpp:47
    #13 0x00000000007d2404 in bpftrace::ast::CodegenLLVM::accept (this=0xffffffffc650, node=0xffffe4427650)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:3778
    #14 0x00000000007cb7a4 in bpftrace::ast::CodegenLLVM::visit (this=0xffffffffc650, program=...)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:2752
    #15 0x000000000084818c in bpftrace::ast::Program::accept (this=0xe90f50, v=...)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/ast.cpp:50
    #16 0x00000000007d2404 in bpftrace::ast::CodegenLLVM::accept (this=0xffffffffc650, node=0xe90f50)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:3778
    #17 0x00000000007d03fc in bpftrace::ast::CodegenLLVM::generate_ir (this=0xffffffffc650)
        at /home/rongtao/Git/bpftrace/bpftrace/src/ast/passes/codegen_llvm.cpp:3450
    #18 0x0000000000478138 in main (argc=2, argv=0xfffffffff4c8) at /home/rongtao/Git/bpftrace/bpftrace/src/main.cpp:898

We can simplify opensnoop.bt to:

    tracepoint:syscalls:sys_enter_open_not_exist,
    tracepoint:syscalls:sys_enter_openat
    {
        @ = args.filename;
    }

This will produce the following error:

    stdin:1:1-45: WARNING: tracepoint not found: syscalls:sys_enter_open_not_exist
    tracepoint:syscalls:sys_enter_open_not_exist,tracepoint:syscalls:sys_enter_openat {@ = args.filename;}
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Segmentation fault

We need to generate the dummy probe only for cases when none of the probe
attach points exists.

Link: bpftrace/bpftrace#3274
Signed-off-by: Viktor Malik <viktor.malik@gmail.com>
Signed-off-by: Rong Tao <rongtao@cestc.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants