linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurence Oberman <loberman@redhat.com>
To: Johannes Thumshirn <jthumshirn@suse.de>
Cc: "Martin K . Petersen" <martin.petersen@oracle.com>,
	James Bottomley <jejb@linux.vnet.ibm.com>,
	Linux SCSI Mailinglist <linux-scsi@vger.kernel.org>,
	Linux Kernel Mailinglist <linux-kernel@vger.kernel.org>,
	Narsimhulu Musini <nmusini@cisco.com>,
	Sesidhar Baddela <sebaddel@cisco.com>
Subject: Re: [PATCH] snic: Fix use-after-free in case of a dma mapping error
Date: Thu, 23 Jun 2016 11:07:46 -0400 (EDT)	[thread overview]
Message-ID: <1818494207.887633.1466694466763.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20160623123720.24244-1-jthumshirn@suse.de>



----- Original Message -----
> From: "Johannes Thumshirn" <jthumshirn@suse.de>
> To: "Martin K . Petersen" <martin.petersen@oracle.com>, "James Bottomley" <jejb@linux.vnet.ibm.com>
> Cc: "Linux SCSI Mailinglist" <linux-scsi@vger.kernel.org>, "Linux Kernel Mailinglist" <linux-kernel@vger.kernel.org>,
> "Narsimhulu Musini" <nmusini@cisco.com>, "Sesidhar Baddela" <sebaddel@cisco.com>, "Johannes Thumshirn"
> <jthumshirn@suse.de>
> Sent: Thursday, June 23, 2016 8:37:20 AM
> Subject: [PATCH] snic: Fix use-after-free in case of a dma mapping error
> 
> If there is a dma mapping error snic kfree()s buf right before printing it.
> Change the order to not accidently trip on memory that's not owned by us
> anymore.
> 
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> ---
>  drivers/scsi/snic/snic_disc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/snic/snic_disc.c b/drivers/scsi/snic/snic_disc.c
> index b0fefd6..b106596 100644
> --- a/drivers/scsi/snic/snic_disc.c
> +++ b/drivers/scsi/snic/snic_disc.c
> @@ -113,11 +113,11 @@ snic_queue_report_tgt_req(struct snic *snic)
>  
>  	pa = pci_map_single(snic->pdev, buf, buf_len, PCI_DMA_FROMDEVICE);
>  	if (pci_dma_mapping_error(snic->pdev, pa)) {
> -		kfree(buf);
> -		snic_req_free(snic, rqi);
>  		SNIC_HOST_ERR(snic->shost,
>  			      "Rpt-tgt rspbuf %p: PCI DMA Mapping Failed\n",
>  			      buf);
> +		kfree(buf);
> +		snic_req_free(snic, rqi);
>  		ret = -EINVAL;
>  
>  		goto error;
> --
> 2.8.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

Looks fine to me
Reviewed-by Laurence Oberman <loberman@redhat.com>

      reply	other threads:[~2016-06-23 15:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-23 12:37 [PATCH] snic: Fix use-after-free in case of a dma mapping error Johannes Thumshirn
2016-06-23 15:07 ` Laurence Oberman [this message]

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=1818494207.887633.1466694466763.JavaMail.zimbra@redhat.com \
    --to=loberman@redhat.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=jthumshirn@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=nmusini@cisco.com \
    --cc=sebaddel@cisco.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).