Skip to content

libmultipath: check get_word() result in disassemble_map() - #155

Open
wallycheng wants to merge 1 commit into
opensvc:masterfrom
wallycheng:fix-dmparser-null-check
Open

libmultipath: check get_word() result in disassemble_map()#155
wallycheng wants to merge 1 commit into
opensvc:masterfrom
wallycheng:fix-dmparser-null-check

Conversation

@wallycheng

Copy link
Copy Markdown

get_word() leaves *word == NULL and returns 0 if its internal
calloc() fails, which can happen under memory pressure. Every
other call site in disassemble_map() checks for this case, but the
path-arguments loop skipped the check before calling atoi(word),
causing a NULL-pointer dereference on the OOM path.

Jump to the existing out1 label, which already frees word, to
match the rest of the function and bail out cleanly.

@wallycheng
wallycheng marked this pull request as draft August 14, 2026 04:12
@wallycheng
wallycheng marked this pull request as ready for review August 14, 2026 04:13
@wallycheng

Copy link
Copy Markdown
Author

@mwilck Hi, Could you take a look please? Thanks!

@bmarzins bmarzins left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the patch! It looks good other than two nitpicks.

  1. Would you mind changing the commit message? This is not just a problem on OOM (which is unlikely to happen in practice). A malformed multipath table, where the last path has no arguments, will also cause a crash, and that seems like a more likely thing to happen.
  2. since we know word is NULL, we might as well just jump to out, instead of out1.

@wallycheng
wallycheng force-pushed the fix-dmparser-null-check branch 2 times, most recently from 0559c86 to 237cf0f Compare August 16, 2026 08:58
@wallycheng

Copy link
Copy Markdown
Author

Thanks for the patch! It looks good other than two nitpicks.

  1. Would you mind changing the commit message? This is not just a problem on OOM (which is unlikely to happen in practice). A malformed multipath table, where the last path has no arguments, will also cause a crash, and that seems like a more likely thing to happen.
  2. since we know word is NULL, we might as well just jump to out, instead of out1.

Thanks for the review! Updated the commit message to mention malformed tables as well. and switched to "goto out" as well.

@wallycheng
wallycheng requested a review from bmarzins August 17, 2026 01:28

@bmarzins bmarzins left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me.

@wallycheng

Copy link
Copy Markdown
Author

@bmarzins Hi — The PR’s checks are stuck as pending; I don’t have permission to re-run workflows. Could someone with repo access please re-run the CI or advise? Thanks!

@mwilck

mwilck commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

@wallycheng, don't worry about the PR checks.

I will apply your patch in my "tip" branch. From there it will be merged to the "queue" branch and ultimately into the next release.

@mwilck

mwilck commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

@wallycheng

Hm. Your patch contains an extra semicolon causing the CI failures. I have fixed this now, but it shows that you didn't even compile-test your change. Please do that next time.

    get_word() returns 0 and sets *word to NULL not only when calloc()
    fails, but also when the input table is malformed(e.g, the last path
    has no arguments). In both cases, dereferencing word later in
    atoi(word) causes a NULL pointer dereference.

    Add a check for !word and jump to out since word is already NULL,
    matching the error-handling pattern used elsewhere in the function.

Signed-off-by: wallycheng <295412260@qq.com>
@wallycheng
wallycheng force-pushed the fix-dmparser-null-check branch from 237cf0f to 48fa855 Compare August 20, 2026 17:18
@wallycheng

Copy link
Copy Markdown
Author

Thanks!I've fixed it in the latest commit.

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.

3 participants