All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Michal Kalderon <michal.kalderon@marvell.com>
Cc: mkalderon@marvell.com, aelior@marvell.com, dledford@redhat.com,
	bmt@zurich.ibm.com, galpress@amazon.com, sleybo@amazon.com,
	leon@kernel.org, linux-rdma@vger.kernel.org
Subject: Re: [PATCH v11 rdma-next 2/7] RDMA/core: Create mmap database and cookie helper functions
Date: Thu, 19 Sep 2019 14:14:50 -0300	[thread overview]
Message-ID: <20190919171450.GA4132@ziepe.ca> (raw)
In-Reply-To: <20190905100117.20879-3-michal.kalderon@marvell.com>

On Thu, Sep 05, 2019 at 01:01:12PM +0300, Michal Kalderon wrote:

>  int rdma_user_mmap_io(struct ib_ucontext *ucontext, struct vm_area_struct *vma,
>  		      unsigned long pfn, unsigned long size, pgprot_t prot)
>  {
>  	struct ib_uverbs_file *ufile = ucontext->ufile;
> -	struct rdma_umap_priv *priv;
> +	int ret;
>  
>  	if (!(vma->vm_flags & VM_SHARED))
>  		return -EINVAL;
> @@ -57,17 +114,240 @@ int rdma_user_mmap_io(struct ib_ucontext *ucontext, struct vm_area_struct *vma,
>  		return -EINVAL;
>  	lockdep_assert_held(&ufile->device->disassociate_srcu);
>  
> -	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
> -	if (!priv)
> -		return -ENOMEM;
> +	ret = rdma_umap_priv_init(vma, NULL);
> +	if (ret)
> +		return ret;
>  
>  	vma->vm_page_prot = prot;
>  	if (io_remap_pfn_range(vma, vma->vm_start, pfn, size, prot)) {
> -		kfree(priv);
> +		rdma_umap_priv_delete(ufile, vma->vm_private_data);
>  		return -EAGAIN;

This leaves vma->vm_private_data set to the priv after it has been
freed. This does not seem like such a good idea, can it use after
free? It looks like no, but still would not be a bad idea to null it
here.

Jason

  reply	other threads:[~2019-09-19 17:14 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-05 10:01 [PATCH v11 rdma-next 0/7] RDMA/qedr: Use the doorbell overflow recovery mechanism for RDMA Michal Kalderon
2019-09-05 10:01 ` [PATCH v11 rdma-next 1/7] RDMA/core: Move core content from ib_uverbs to ib_core Michal Kalderon
2019-09-05 10:01 ` [PATCH v11 rdma-next 2/7] RDMA/core: Create mmap database and cookie helper functions Michal Kalderon
2019-09-19 17:14   ` Jason Gunthorpe [this message]
2019-09-19 17:48   ` Jason Gunthorpe
2019-09-19 18:07   ` Jason Gunthorpe
2019-09-23  9:36     ` [EXT] " Michal Kalderon
2019-09-23 13:30       ` Jason Gunthorpe
2019-09-24  8:31         ` Michal Kalderon
2019-09-24 12:37           ` Jason Gunthorpe
2019-09-05 10:01 ` [PATCH v11 rdma-next 3/7] RDMA/efa: Use the common mmap_xa helpers Michal Kalderon
2019-09-19 17:37   ` Jason Gunthorpe
2019-09-23  9:15     ` Michal Kalderon
2019-09-23 13:28       ` Jason Gunthorpe
2019-09-05 10:01 ` [PATCH v11 rdma-next 4/7] RDMA/siw: " Michal Kalderon
2019-09-05 10:01 ` [PATCH v11 rdma-next 5/7] RDMA/qedr: Use the common mmap API Michal Kalderon
2019-09-19 17:55   ` Jason Gunthorpe
2019-09-20 13:39     ` Gal Pressman
2019-09-23  9:21       ` Michal Kalderon
2019-09-23 13:29         ` Jason Gunthorpe
2019-09-24  8:25           ` [EXT] " Michal Kalderon
2019-09-24  8:49         ` Pressman, Gal
2019-09-24  9:31           ` Michal Kalderon
2019-10-20  7:19             ` Gal Pressman
2019-10-21 17:33               ` Jason Gunthorpe
2019-10-23  6:40                 ` Gal Pressman
2019-10-23 14:41                   ` Jason Gunthorpe
2019-10-24  8:06                     ` Gal Pressman
2019-09-05 10:01 ` [PATCH v11 rdma-next 6/7] RDMA/qedr: Add doorbell overflow recovery support Michal Kalderon
2019-09-19 18:02   ` Jason Gunthorpe
2019-09-20 13:30     ` Gal Pressman
2019-09-20 13:38       ` Jason Gunthorpe
2019-09-20 14:00         ` Gal Pressman
2019-09-23  9:37           ` Michal Kalderon
2019-09-25 19:16         ` [EXT] " Michal Kalderon
2019-09-25 19:21           ` Jason Gunthorpe
2019-09-25 19:37             ` Michal Kalderon
2019-09-26 19:10               ` Jason Gunthorpe
2019-09-23  9:30     ` Michal Kalderon
2019-09-23 13:26       ` Jason Gunthorpe
2019-09-05 10:01 ` [PATCH v11 rdma-next 7/7] RDMA/qedr: Add iWARP doorbell " Michal Kalderon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190919171450.GA4132@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=aelior@marvell.com \
    --cc=bmt@zurich.ibm.com \
    --cc=dledford@redhat.com \
    --cc=galpress@amazon.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=michal.kalderon@marvell.com \
    --cc=mkalderon@marvell.com \
    --cc=sleybo@amazon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.