Skip to content

Commit

Permalink
Make reading blacklist from debugfs optional
Browse files Browse the repository at this point in the history
With lockdown enabled one sees the following:

```
$ sudo /usr/share/bcc/tools/funccount -Ti 1 run_timer_softirq
[Errno 1] Operation not permitted: '/sys/kernel/debug/tracing/../kprobes/blacklist'
```

Which is accompanied by the following in `dmesg`:

```
[Fri May 29 22:12:47 2020] Lockdown: funccount: debugfs access is restricted; see man kernel_lockdown.7
```

Since blacklist is not a required feature, let's make
reading from it optional, so that bcc can work out of the box.
  • Loading branch information
bobrik authored and yonghong-song committed May 30, 2020
1 parent d007478 commit 5558e36
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/python/bcc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,15 @@ def attach_raw_socket(fn, dev):

@staticmethod
def get_kprobe_functions(event_re):
with open("%s/../kprobes/blacklist" % TRACEFS, "rb") as blacklist_f:
blacklist = set([line.rstrip().split()[1] for line in blacklist_f])
blacklist_file = "%s/../kprobes/blacklist" % TRACEFS
try:
with open(blacklist_file, "rb") as blacklist_f:
blacklist = set([line.rstrip().split()[1] for line in blacklist_f])
except IOError as e:
if e.errno != errno.EPERM:
raise e
blacklist = set([])

fns = []

in_init_section = 0
Expand Down Expand Up @@ -607,7 +614,7 @@ def _del_kprobe_fd(self, name):
global _num_open_probes
del self.kprobe_fds[name]
_num_open_probes -= 1

def _add_uprobe_fd(self, name, fd):
global _num_open_probes
self.uprobe_fds[name] = fd
Expand Down Expand Up @@ -643,7 +650,7 @@ def fix_syscall_fnname(self, name):
if name.startswith(prefix):
return self.get_syscall_fnname(name[len(prefix):])
return name

def attach_kprobe(self, event=b"", event_off=0, fn_name=b"", event_re=b""):
event = _assert_is_bytes(event)
fn_name = _assert_is_bytes(fn_name)
Expand Down

0 comments on commit 5558e36

Please sign in to comment.