mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: cuigaosheng <cuigaosheng1@huawei.com>
To: <miquel.raynal@bootlin.com>, <richard@nod.at>, <vigneshr@ti.com>,
	<cuigaosheng1@huawei.com>
Cc: <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
	<gongruiqi1@huawei.com>, <wangweiyang2@huawei.com>
Subject: Re: [PATCH -next] mtd/ftl: Fix uaf in ftl_remove_dev()
Date: Thu, 18 Aug 2022 09:32:13 +0800	[thread overview]
Message-ID: <a2b4dccd-0942-69ff-39ac-a9313f41fed1@huawei.com> (raw)
In-Reply-To: <20220715071119.2321463-1-cuigaosheng1@huawei.com>

PING

在 2022/7/15 15:11, Gaosheng Cui 写道:
> del_mtd_blktrans_dev will reclaim the resources of mtd_blktrans_dev,
> and call kfree(dev) in blktrans_dev_put to release the memory of
> mtd_blktrans_dev, so when ftl_freepart reclaims the memory of other
> member pointers of the partition_t, it will trigger the uaf problem,
> Fix it by moving ftl_freepart in front of del_mtd_blktrans_dev.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
> ---
>   drivers/mtd/ftl.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
> index 200271bdc7aa..bec56070039d 100644
> --- a/drivers/mtd/ftl.c
> +++ b/drivers/mtd/ftl.c
> @@ -1039,8 +1039,12 @@ static void ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
>   
>   static void ftl_remove_dev(struct mtd_blktrans_dev *dev)
>   {
> +	struct partition_t *partition;
> +
> +	partition = container_of(dev, struct partition_t, mbd);
> +
> +	ftl_freepart(partition);
>   	del_mtd_blktrans_dev(dev);
> -	ftl_freepart((partition_t *)dev);
>   }
>   
>   static struct mtd_blktrans_ops ftl_tr = {

      reply	other threads:[~2022-08-18  1:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-15  7:11 Gaosheng Cui
2022-08-18  1:32 ` cuigaosheng [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=a2b4dccd-0942-69ff-39ac-a9313f41fed1@huawei.com \
    --to=cuigaosheng1@huawei.com \
    --cc=gongruiqi1@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=wangweiyang2@huawei.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

all inboxes | Powered by JetHome®