Linux-mtd Archive on lore.kernel.org
 help / color / Atom feed
From: Hou Tao <houtao1@huawei.com>
To: Wen Yang <wenyang@linux.alibaba.com>,
	Richard Weinberger <richard@nod.at>,
	 Miquel Raynal <miquel.raynal@bootlin.com>,
	Vignesh Raghavendra <vigneshr@ti.com>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
	xlpang@linux.alibaba.com
Subject: Re: [PATCH] UBI: fix use after free in ubi_remove_volume()
Date: Thu, 5 Dec 2019 09:33:18 +0800
Message-ID: <58208ceb-4d72-c4a1-8a2b-9e38854e3672@huawei.com> (raw)
In-Reply-To: <65b49705-e28c-e077-c0de-c5167e34d1c5@huawei.com>

Hi,

On 2019/12/3 21:13, Hou Tao wrote:
> Reviewed-by: Hou Tao <houtao1@huawei.com>
> 
Sorry for my early conclusion.

The reference of ubi_volume had already been increased in ubi_open_volume()
in ubi_cdev_ioctl(), so this reference dropped in ubi_remove_volume() will not
be the last one, and there will no use-after-free problem.

Regards,
Tao

> On 2019/11/30 17:33, Wen Yang wrote:
>> We can't use "vol" after it has been freed.
>>
>> Fixes: 493cfaeaa0c9 ("mtd: utilize new cdev_device_add helper function")
>> Signed-off-by: Wen Yang <wenyang@linux.alibaba.com>
>> Cc: Richard Weinberger <richard@nod.at>
>> Cc: Miquel Raynal <miquel.raynal@bootlin.com>
>> Cc: Vignesh Raghavendra <vigneshr@ti.com>
>> Cc: linux-mtd@lists.infradead.org
>> Cc: linux-kernel@vger.kernel.org
>> ---
>>  drivers/mtd/ubi/vmt.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
>> index 139ee13..8ff1478 100644
>> --- a/drivers/mtd/ubi/vmt.c
>> +++ b/drivers/mtd/ubi/vmt.c
>> @@ -375,7 +375,6 @@ int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl)
>>  	}
>>  
>>  	cdev_device_del(&vol->cdev, &vol->dev);
>> -	put_device(&vol->dev);
>>  
>>  	spin_lock(&ubi->volumes_lock);
>>  	ubi->rsvd_pebs -= reserved_pebs;
>> @@ -388,6 +387,8 @@ int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl)
>>  	if (!no_vtbl)
>>  		self_check_volumes(ubi);
>>  
>> +	put_device(&vol->dev);
>> +
>>  	return 0;
>>  
>>  out_err:
>>
> 
> 
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
> 
> 


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

      reply index

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-30  9:33 Wen Yang
2019-12-03 13:13 ` Hou Tao
2019-12-05  1:33   ` Hou Tao [this message]

Reply instructions:

You may reply publically 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=58208ceb-4d72-c4a1-8a2b-9e38854e3672@huawei.com \
    --to=houtao1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.com \
    --cc=wenyang@linux.alibaba.com \
    --cc=xlpang@linux.alibaba.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

Linux-mtd Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mtd/0 linux-mtd/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mtd linux-mtd/ https://lore.kernel.org/linux-mtd \
		linux-mtd@lists.infradead.org
	public-inbox-index linux-mtd

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-mtd


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git