Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
2867473e
Commit
2867473e
authored
May 20, 2018
by
yonghong-song
Committed by
GitHub
May 20, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1772 from pchaigno/limit-rewrites-from-ctx
Limit dereference rewriter to tracing contexts
parents
8996719b
05b2083c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletion
+29
-1
src/cc/frontends/clang/b_frontend_action.cc
src/cc/frontends/clang/b_frontend_action.cc
+10
-1
tests/python/test_clang.py
tests/python/test_clang.py
+19
-0
No files found.
src/cc/frontends/clang/b_frontend_action.cc
View file @
2867473e
...
...
@@ -911,7 +911,16 @@ void BTypeConsumer::HandleTranslationUnit(ASTContext &Context) {
if
(
fe_
.
is_rewritable_ext_func
(
F
))
{
for
(
auto
arg
:
F
->
parameters
())
{
if
(
arg
==
F
->
getParamDecl
(
0
))
{
probe_visitor1_
.
set_ctx
(
arg
);
/**
* Limit tracing of pointers from context to tracing contexts.
* We're whitelisting instead of blacklisting to avoid issues with
* existing programs if new context types are added in the future.
*/
string
type
=
arg
->
getType
().
getAsString
();
if
(
type
==
"struct pt_regs *"
||
type
==
"struct bpf_raw_tracepoint_args *"
||
type
.
substr
(
0
,
19
)
==
"struct tracepoint__"
)
probe_visitor1_
.
set_ctx
(
arg
);
}
else
if
(
!
arg
->
getType
()
->
isFundamentalType
())
{
probe_visitor1_
.
set_ptreg
(
arg
);
}
...
...
tests/python/test_clang.py
View file @
2867473e
...
...
@@ -810,6 +810,25 @@ int test(struct pt_regs *ctx) {
b
=
BPF
(
text
=
text
)
fn
=
b
.
load_func
(
"test"
,
BPF
.
KPROBE
)
@
skipUnless
(
kernel_version_ge
(
4
,
7
),
"requires kernel >= 4.7"
)
def
test_probe_read_tc_ctx
(
self
):
text
=
"""
#include <uapi/linux/pkt_cls.h>
#include <linux/if_ether.h>
int test(struct __sk_buff *ctx) {
void* data_end = (void*)(long)ctx->data_end;
void* data = (void*)(long)ctx->data;
if (data + sizeof(struct ethhdr) > data_end)
return TC_ACT_SHOT;
struct ethhdr *eh = (struct ethhdr *)data;
if (eh->h_proto == 0x1)
return TC_ACT_SHOT;
return TC_ACT_OK;
}
"""
b
=
BPF
(
text
=
text
)
fn
=
b
.
load_func
(
"test"
,
BPF
.
SCHED_CLS
)
if
__name__
==
"__main__"
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment