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

[BPF] printk gets fmt from .rodata instead of stack #9417

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion felix/bpf-gpl/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#ifdef BPF_CORE_SUPPORTED
#define bpf_log(__fmt, ...) do { \
char fmt[] = IPVER_PFX __fmt; \
static const char fmt[] = IPVER_PFX __fmt; \
bpf_trace_printk(fmt, sizeof(fmt), ## __VA_ARGS__); \
} while (0)
#else
Expand Down
2 changes: 1 addition & 1 deletion felix/bpf/hook/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (pm *ProgramsMap) loadObj(at AttachType, file string) (Layout, error) {

for m, err := obj.FirstMap(); m != nil && err == nil; m, err = m.NextMap() {
mapName := m.Name()
if strings.HasPrefix(mapName, ".rodata") {
if strings.Contains(mapName, ".rodata") {
continue
}

Expand Down
2 changes: 1 addition & 1 deletion felix/bpf/nat/connecttime.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func loadProgram(logLevel, ipver string, udpNotSeen time.Duration, excludeUDP bo
// userspace before the program is loaded.
mapName := m.Name()
if m.IsMapInternal() {
if strings.HasPrefix(mapName, ".rodata") {
if strings.Contains(mapName, ".rodata") {
continue
}
if err := libbpf.CTLBSetGlobals(m, udpNotSeen, excludeUDP); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion felix/bpf/ut/bpf_prog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ func objLoad(fname, bpfFsDir, ipFamily string, topts testOpts, polProg, hasHostC

for m, err := obj.FirstMap(); m != nil && err == nil; m, err = m.NextMap() {
if m.IsMapInternal() {
if strings.HasPrefix(m.Name(), ".rodata") {
if strings.Contains(m.Name(), ".rodata") {
continue
}
if forXDP {
Expand Down