Skip to content

NVIDIA: SAUCE: nvme-pci: fix NVFS SGL pool selection and DMA iter leak#333

Open
sourabgupta3 wants to merge 1 commit intoNVIDIA:24.04_linux-nvidia-6.17-nextfrom
sourabgupta3:sg_24.04_linux-nvidia-6.17-next-nvme-fix
Open

NVIDIA: SAUCE: nvme-pci: fix NVFS SGL pool selection and DMA iter leak#333
sourabgupta3 wants to merge 1 commit intoNVIDIA:24.04_linux-nvidia-6.17-nextfrom
sourabgupta3:sg_24.04_linux-nvidia-6.17-next-nvme-fix

Conversation

@sourabgupta3
Copy link

For NVFS I/Os, blk_rq_nr_phys_segments() can undercount GPU physical segments since CPU-side segment contiguity may differ from GPU physical contiguity. This can undersize the SGL pool causing a buffer overrun.

Use payload size to select the pool: small (16 entries) for < 15*64K, large (256 entries) otherwise, bounded by actual pool capacity.

Also guard nvfs_blk_rq_dma_map_iter_next() with mapped < entries so we never create a DMA mapping that cannot be stored or unmapped, which would leave nvfs_n_ops elevated and block nvfs_exit() on rmmod.

Signed-off-by: Sourab Gupta sougupta@nvidia.com
Reviewed-by: Kiran Modukuri kmodukuri@nvidia.com

For NVFS I/Os, blk_rq_nr_phys_segments() can undercount GPU physical
segments since CPU-side segment contiguity may differ from GPU physical
contiguity. This can undersize the SGL pool causing a buffer overrun.

Use payload size to select the pool: small (16 entries) for < 15*64K,
large (256 entries) otherwise, bounded by actual pool capacity.

Also guard nvfs_blk_rq_dma_map_iter_next() with mapped < entries so we
never create a DMA mapping that cannot be stored or unmapped, which would
leave nvfs_n_ops elevated and block nvfs_exit() on rmmod.

Signed-off-by: Sourab Gupta <sougupta@nvidia.com>
Reviewed-by: Kiran Modukuri <kmodukuri@nvidia.com>
@sourabgupta3 sourabgupta3 force-pushed the sg_24.04_linux-nvidia-6.17-next-nvme-fix branch from 00f1a56 to f3872dd Compare March 6, 2026 21:54
@jamieNguyenNVIDIA
Copy link
Collaborator

Acked-by: Jamie Nguyen <jamien@nvidia.com>

Copy link
Collaborator

@nirmoy nirmoy left a comment

Choose a reason for hiding this comment

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

Acked-by: Nirmoy Das <nirmoyd@nvidia.com>

@jamieNguyenNVIDIA
Copy link
Collaborator

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