From: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
To: Dan Carpenter <dan.carpenter@oracle.com>, Song Liu <song@kernel.org>
Cc: Shaohua Li <shli@fb.com>, NeilBrown <neilb@suse.com>,
linux-raid@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] md-cluster: Fix potential error pointer dereference in resize_bitmaps()
Date: Tue, 04 Aug 2020 10:40:18 +0000 [thread overview]
Message-ID: <824849e0-c98d-1f22-817c-7a76d3ee22b1@cloud.ionos.com> (raw)
In-Reply-To: <20200804101645.GB392148@mwanda>
On 8/4/20 12:16 PM, Dan Carpenter wrote:
> The error handling calls md_bitmap_free(bitmap) which checks for NULL
> but will Oops if we pass an error pointer. Let's set "bitmap" to NULL
> on this error path.
>
> Fixes: afd756286083 ("md-cluster/raid10: resize all the bitmaps before start reshape")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/md/md-cluster.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
> index 73fd50e77975..d50737ec4039 100644
> --- a/drivers/md/md-cluster.c
> +++ b/drivers/md/md-cluster.c
> @@ -1139,6 +1139,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
> bitmap = get_bitmap_from_slot(mddev, i);
> if (IS_ERR(bitmap)) {
> pr_err("can't get bitmap from slot %d\n", i);
> + bitmap = NULL;
> goto out;
> }
> counts = &bitmap->counts;
Thanks for the catch, Reviewed-by: Guoqing Jiang
<guoqing.jiang@cloud.ionos.com>
BTW, seems there could be memory leak in the function since it keeps
allocate bitmap
in the loop ..., will send a format patch.
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 73fd50e77975..89d7b32489d8 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -1165,6 +1165,8 @@ static int resize_bitmaps(struct mddev *mddev,
sector_t newsize, sector_t oldsiz
* can't resize bitmap
*/
goto out;
+
+ md_bitmap_free(bitmap);
}
return 0;
Thanks,
Guoqing
next prev parent reply other threads:[~2020-08-04 10:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-04 10:16 [PATCH] md-cluster: Fix potential error pointer dereference in resize_bitmaps() Dan Carpenter
2020-08-04 10:40 ` Guoqing Jiang [this message]
2020-08-04 11:15 ` Dan Carpenter
2020-08-06 0:20 ` Song Liu
2020-10-03 15:57 ` heming.zhao
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=824849e0-c98d-1f22-817c-7a76d3ee22b1@cloud.ionos.com \
--to=guoqing.jiang@cloud.ionos.com \
--cc=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.com \
--cc=shli@fb.com \
--cc=song@kernel.org \
/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).