> -----Original Message----- > From: Jason Gunthorpe <jgg@xxxxxxxxxx> > Sent: Tuesday, 3 January 2023 15:15 > To: Bernard Metzler <BMT@xxxxxxxxxxxxxx> > Cc: linux-rdma@xxxxxxxxxxxxxxx; leonro@xxxxxxxxxx; > David.Laight@xxxxxxxxxx > Subject: [EXTERNAL] Re: Re: [PATCH] RDMA/siw: Fix missing permission > check in user buffer registration > > On Tue, Jan 03, 2023 at 02:11:19PM +0000, Bernard Metzler wrote: > > Oh ok, thanks. It is probably find_vma() further down the call > > which makes sure the address is valid for the user context. I > > tried reserving bogus user memory with siw and indeed get the > > right failure from trying to pin it. > > Why isn't this using a normal umem which does all this for you? > > Jason siw as a software only drivers sits on top of TCP sockets and just wants to read and write from/to pages. For efficiency in starting/resuming sending or receiving, it benefits from a simple mechanism to get the right page of a registered mem region as quick as possible. So it keeps the pages of a memory region in a two dimensional array, indexable with very simple arithmetic - see siw_get_upage(). ib_umem_get() provides a scatterlist of pages, which a sw provider would have to traverse linearly on the fast path to get to the right page to read/write. siw als does not care about dma addresses. I see other drivers, such as hfi or qib, which also do not use ib_umem_get(). siw could of course use ib_umem_get() first to get a scatterlist of pinned pages and translate this into an indexable internal presentation of pages, but I considered this an unacceptable waste of kernel resources. Bernard.