Skip to contentSkip to conversation

scif_insert_vma()

DISCUSSION Jarkko Sakkinen 2 participants 3 messages Mar 11, 2019 – Mar 20, 2019

lore
Share & tools
lore
#0 lore raw

Hi

Just wondering what will happen if kzalloc() fails in scif_mmap.c. How it is recovered? I don't see anything in the VMA callbacks taking care of this.

/Jarkko

#1 lore raw
Quoted 5 lines · Jarkko Sakkinen

Hi

Just wondering what will happen if kzalloc() fails in scif_mmap.c. How it is recovered? I don't see anything in the VMA callbacks taking care of this.

Hi Jarkko,

scif_insert_vma(..) is called from scif_mmap(..) and scif_vma_open(..). scif_mmap(..) checks for allocation failures but scif_vma_open(..) does not on purpose.

The vm_operations_struct open(..)/close(..) callbacks do not allow returning errors. The driver will take a reference to the VMA private data structure irrespective of whether the allocation during the open(..) callback succeeds or fails. The close(..) callback cleans up the data structures from the mmap(..) or open(..) callbacks if any.

Thanks,
Sudeep Dutt

#2 lore raw
Quoted 13 lines · Sudeep Dutt
Quoted 5 lines · Jarkko Sakkinen

Hi

Just wondering what will happen if kzalloc() fails in scif_mmap.c. How it is recovered? I don't see anything in the VMA callbacks taking care of this.

Hi Jarkko,

scif_insert_vma(..) is called from scif_mmap(..) and scif_vma_open(..). scif_mmap(..) checks for allocation failures but scif_vma_open(..) does not on purpose.

Quoted 5 lines

The vm_operations_struct open(..)/close(..) callbacks do not allow returning errors. The driver will take a reference to the VMA private data structure irrespective of whether the allocation during the open(..) callback succeeds or fails. The close(..) callback cleans up the data structures from the mmap(..) or open(..) callbacks if any.

I'm doing allocations also in SGX vma_open callback and was grepping through kernel tree for how allocations were handled. Thanks for clarifying this. In SGX's case I ended up with allowing to fail in vma open and doing SIGBUS in the #PF handler if so...

/Jarkko