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

Possible null pointer dereference? #7592

Open
lexborisov opened this issue May 3, 2024 · 0 comments
Open

Possible null pointer dereference? #7592

lexborisov opened this issue May 3, 2024 · 0 comments

Comments

@lexborisov
Copy link

Hello, everyone!

There are logical inconsistencies in the TaskConcurrentCancelCheck(...) function in src/backend/distributed/utils/background_jobs.c.

Specifically, line 710 has a check:

if (!task || task->status == BACKGROUND_TASK_STATUS_CANCELLING)

where it is assumed that task can be NULL.
Then, inside this branching (if !task), there is a dereferencing of task in line 722. This may cause dereferencing of a NULL pointer.

But that's half the problem.

Let's take a look at line 708 which is immediately before checking task for NULL.
It turns out that task can be NULL in the taskExecutionContext->task.
Unfortunately, further down the code, task taken from taskExecutionContext->task is actively used without checking for NULL.
For example, in the TaskEnded(...) function which will be called after the TaskConcurrentCancelCheck(...) function.

Based on the above:

  1. Can task be a NULL pointer? Or is it an unnecessary check in the code.
  2. If task can be NULL, we have two different places in the code with potential NULL dereferencing.
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

No branches or pull requests

1 participant