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

Fix nil pointer dereference in addSCSI #1497

Merged
merged 1 commit into from
Sep 1, 2022

Conversation

ambarve
Copy link
Contributor

@ambarve ambarve commented Sep 1, 2022

The new change that we added to fix a race condition in addSCSI introduced a bug where the code ends up accessing a
nil pointer in certain situations. For example, the deferred function to unblock any waiters of the attach
SCSI operation accesses the scsi mount object to propagate any errors. However, this pointer is a named return
value of the function and is set to nil when returning an error. In those cases the deferred function panics
with the nil pointer dereference error. To fix this we don't use the named return value for the scsi mount
object anymore.
This change also removes the check for zero SCSI controllers since that check is done by the
allocateSCSIMount function.

Signed-off-by: Amit Barve ambarve@microsoft.com

The new change that we added to fix a race condition in addSCSI introduced a bug where the code ends up accessing a
nil pointer in certain situations. For example, the deferred function to unblock any waiters of the attach
SCSI operation accesses the scsi mount object to propagate any errors. However, this pointer is a named return
value of the function and is set to `nil` when returning an error. In those cases the deferred function panics
with the nil pointer dereference error. To fix this we don't use the named return value for the scsi mount
object anymore.
This change also removes the check for zero SCSI controllers since that check is done by the
`allocateSCSIMount` function.

Signed-off-by: Amit Barve <ambarve@microsoft.com>
@ambarve ambarve requested a review from a team as a code owner September 1, 2022 20:29
Copy link
Contributor

@anmaxvl anmaxvl left a comment

Choose a reason for hiding this comment

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

lgtm

@ambarve ambarve merged commit 895853a into microsoft:main Sep 1, 2022
KenGordon pushed a commit to KenGordon/hcsshim that referenced this pull request May 17, 2024
The new change that we added to fix a race condition in addSCSI introduced a bug where the code ends up accessing a
nil pointer in certain situations. For example, the deferred function to unblock any waiters of the attach
SCSI operation accesses the scsi mount object to propagate any errors. However, this pointer is a named return
value of the function and is set to `nil` when returning an error. In those cases the deferred function panics
with the nil pointer dereference error. To fix this we don't use the named return value for the scsi mount
object anymore.
This change also removes the check for zero SCSI controllers since that check is done by the
`allocateSCSIMount` function.

Signed-off-by: Amit Barve <ambarve@microsoft.com>

Signed-off-by: Amit Barve <ambarve@microsoft.com>
(cherry picked from commit 895853a)
Signed-off-by: Amit Barve <ambarve@microsoft.com>
KenGordon pushed a commit to KenGordon/hcsshim that referenced this pull request May 17, 2024
…1497)

Fix nil pointer dereference in addSCSI (microsoft#1497)

The new change that we added to fix a race condition in addSCSI introduced a bug where the code ends up accessing a
nil pointer in certain situations. For example, the deferred function to unblock any waiters of the attach
SCSI operation accesses the scsi mount object to propagate any errors. However, this pointer is a named return
value of the function and is set to `nil` when returning an error. In those cases the deferred function panics
with the nil pointer dereference error. To fix this we don't use the named return value for the scsi mount
object anymore.
This change also removes the check for zero SCSI controllers since that check is done by the
`allocateSCSIMount` function.

Signed-off-by: Amit Barve <ambarve@microsoft.com>

Signed-off-by: Amit Barve <ambarve@microsoft.com>
(cherry picked from commit 895853a)
Signed-off-by: Amit Barve <ambarve@microsoft.com>

Related work items: microsoft#1497
princepereira pushed a commit to princepereira/hcsshim that referenced this pull request Aug 29, 2024
The new change that we added to fix a race condition in addSCSI introduced a bug where the code ends up accessing a
nil pointer in certain situations. For example, the deferred function to unblock any waiters of the attach
SCSI operation accesses the scsi mount object to propagate any errors. However, this pointer is a named return
value of the function and is set to `nil` when returning an error. In those cases the deferred function panics
with the nil pointer dereference error. To fix this we don't use the named return value for the scsi mount
object anymore.
This change also removes the check for zero SCSI controllers since that check is done by the
`allocateSCSIMount` function.

Signed-off-by: Amit Barve <ambarve@microsoft.com>

Signed-off-by: Amit Barve <ambarve@microsoft.com>
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