GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Initialize rem_* in DwarfParser.parseInstructions. by krk · Pull Request #1039 · async-profiler/async-profiler

Conversation

@krk

@krk krk commented Oct 23, 2024

Copy link
Copy Markdown
Contributor

Description

rem_* variables may not be initialized in all code paths.

How has this been tested?

make test

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@krk
Initialize rem_* in DwarfParser.parseInstructions.
739763c
apangin
apangin reviewed Oct 23, 2024
View reviewed changes
Comment thread src/dwarf.cpp Outdated
u32 rem_cfa_reg = 0;
int rem_cfa_off = 0;
int rem_fp_off = 0;
int rem_pc_off = 0;

@apangin apangin Oct 23, 2024

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

What problem does this fix?
rem values are valid only after they have been assigned to by DW_CFA_remember_state instruction. Otherwise, 0 is just as much garbage as any other random value.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@krk krk Oct 24, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This is from a static analyzer finding. Hypothetically, there may be a corrupt dwarf file, causing uninitialized values to be used, which would add an invalid frame description.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@apangin apangin Oct 24, 2024

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I understand. My point is it's not a fix anyway. I.e., when using 0 instead of uninitialized values, it will be just a similar invalid frame descriptor.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@apangin apangin Oct 24, 2024

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Initializing with an empty frame descriptor would be slightly better, but does not change the situation fundamentally. I mean, bogus dwarf will result in an invalid or truncated stack trace anyway.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

krk reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@krk krk Oct 25, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I was able to make DwarfParser use uninitialized variables with this eh_frame_hdr, which could lead to undefined behavior:

00000000: 0103 0333 6100 0000 0100 0000 0100 0000  ...3a...........
00000010: 3000 0000 0000 0000 0000 0000 0000 0000  0...............
00000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000030: 1400 0000 0400 0000 0900 0000 0400 0000  ................
00000040: 000b 0000 00                             .....
DwarfParser p("name", 0, eh_frame_hdr);

I haven't investigated if invalid or malicious values could lead to a crash.

Updated the code to use the empty frame descriptor.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@krk
address comments
f47b86d
@apangin
apangin merged commit 116504c into async-profiler:master Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@apangin apangin apangin left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@krk @apangin
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.