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

Improve string buffer checking on uprobe attach and detach #1338

Merged
merged 1 commit into from
Sep 8, 2017

Conversation

palmtenor
Copy link
Member

BCC encodes target binary's path in uprobe event's name and the attach command also includes target binary's path, which could be very long. Error would happen if the long event name or binary path overflows our internal string buffer.

This commit improves buffer size checking, on top of #1328:

  • Increase buffer size of event alias in uprobe to PATH_MAX.
  • Add check of snprintf return value and output debug message when overflow happens.
  • Expand buffer size and add check for bpf_detach_probe as well.


snprintf(new_name, sizeof(new_name), "%s_bcc_%d", ev_name, getpid());
reader = perf_reader_new(cb, NULL, NULL, cb_cookie, probe_perf_reader_page_cnt);
if (!reader)
goto error;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If returning error here, kfd will be uninitialized. So you may want to initialize kfd = -1.

@palmtenor
Copy link
Member Author

Good catch! Thank you and fixed:)

Copy link
Collaborator

@yonghong-song yonghong-song left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@4ast 4ast merged commit 15b15ed into iovisor:master Sep 8, 2017
@palmtenor palmtenor deleted the uprobe_check branch September 10, 2017 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants