All of lore.kernel.org
 help / color / mirror / Atom feed
* scif_insert_vma()
@ 2019-03-11  6:45 Jarkko Sakkinen
  2019-03-18  5:47 ` scif_insert_vma() Sudeep Dutt
  0 siblings, 1 reply; 3+ messages in thread
From: Jarkko Sakkinen @ 2019-03-11  6:45 UTC (permalink / raw)
  To: sudeep.dutt, ashutosh.dixit; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: scif_insert_vma()
  2019-03-11  6:45 scif_insert_vma() Jarkko Sakkinen
@ 2019-03-18  5:47 ` Sudeep Dutt
  2019-03-20 10:26   ` scif_insert_vma() Jarkko Sakkinen
  0 siblings, 1 reply; 3+ messages in thread
From: Sudeep Dutt @ 2019-03-18  5:47 UTC (permalink / raw)
  To: Jarkko Sakkinen; +Cc: Sudeep Dutt, ashutosh.dixit, linux-kernel

On Mon, 2019-03-11 at 08:45 +0200, Jarkko Sakkinen wrote:
> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: scif_insert_vma()
  2019-03-18  5:47 ` scif_insert_vma() Sudeep Dutt
@ 2019-03-20 10:26   ` Jarkko Sakkinen
  0 siblings, 0 replies; 3+ messages in thread
From: Jarkko Sakkinen @ 2019-03-20 10:26 UTC (permalink / raw)
  To: Sudeep Dutt; +Cc: ashutosh.dixit, linux-kernel

On Sun, Mar 17, 2019 at 10:47:40PM -0700, Sudeep Dutt wrote:
> On Mon, 2019-03-11 at 08:45 +0200, Jarkko Sakkinen wrote:
> > 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.

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-20 10:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-11  6:45 scif_insert_vma() Jarkko Sakkinen
2019-03-18  5:47 ` scif_insert_vma() Sudeep Dutt
2019-03-20 10:26   ` scif_insert_vma() Jarkko Sakkinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.