uvm: fix NULL pointer dereference in uvm_hmm_unregister_gpu#1110
Open
JCorners68 wants to merge 1 commit intoNVIDIA:mainfrom
Open
uvm: fix NULL pointer dereference in uvm_hmm_unregister_gpu#1110JCorners68 wants to merge 1 commit intoNVIDIA:mainfrom
JCorners68 wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
Guard gpu->parent->devmem dereference with a NULL check. devmem is only initialized when uvm_pmm_devmem_init() succeeds during init_parent_gpu(). When it is NULL — because init failed or was never called for this GPU — the unconditional dereference at the top of uvm_hmm_unregister_gpu() causes a kernel NULL pointer dereference (Xid 79, "GPU has fallen off the bus") during CUDA process exit: BUG: kernel NULL pointer dereference, address: 00000000000000a8 RIP: uvm_hmm_unregister_gpu+0x51/0x3a0 [nvidia_uvm] Call Trace: unregister_gpu+0xc4/0x5b0 [nvidia_uvm] uvm_va_space_destroy+0x22e/0x770 [nvidia_uvm] uvm_release+0x7a/0x180 [nvidia_uvm] __fput+0xea/0x2d0 do_exit+0x1fa/0x480 The existing uvm_hmm_is_enabled(va_space) check only validates that HMM is enabled for the VA space — it does not guarantee that the specific GPU has device-private memory initialized. When devmem is NULL there are no device-private pages to evict, so skip the eviction loop and proceed directly to block unregistration. Also move the lock assertions above the devmem access so they can actually fire before the NULL dereference. Fixes: NVIDIA#1082 Tested: confirmed workaround (uvm_disable_hmm=1) resolves the crash; this patch is the proper fix for the same code path. Signed-off-by: Jonathan Corners <[email protected]>
|
jcorners68 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #1082 — kernel NULL pointer dereference in
uvm_hmm_unregister_gpu()during CUDA process exit.gpu->parent->devmemis dereferenced unconditionally, but it is only initialized whenuvm_pmm_devmem_init()succeeds duringinit_parent_gpu(). When it is NULL, the dereference crashes the kernel:The existing
uvm_hmm_is_enabled(va_space)guard only checks the VA space — it does not guarantee the specific GPU has device-private memory initialized.Fix
devmemdereference and page-eviction loop withif (gpu->parent->devmem).devmemis NULL there are no device-private pages to evict, so skip straight to HMM block unregistration.devmemaccess so they fire before the NULL dereference (secondary bug: in the original code, the assertions were placed after the crash site and could never trigger).Reproduction
Observed repeatedly on two different systems:
Triggered by any CUDA process exit (training jobs,
nvtop, tokio async runtime,fossilizeshader compilation). The kernel oops corrupts driver state and cascades to Xid 79 ("GPU has fallen off the bus") within minutes to hours, requiring a full node reboot.Testing
options nvidia_uvm uvm_disable_hmm=1(which skips this code path entirely) eliminates the crash, validating that the fault is in this function.