From: Mike Snitzer <snitzer@redhat.com>
To: Defang Bo <bodefang@126.com>
Cc: dm-devel@redhat.com, linux-kernel@vger.kernel.org, agk@redhat.com
Subject: Re: [dm-devel] dm snap : add sanity checks to snapshot_ctr
Date: Mon, 4 Jan 2021 15:27:50 -0500 [thread overview]
Message-ID: <20210104202749.GA3721@redhat.com> (raw)
In-Reply-To: <1608878926-2283057-1-git-send-email-bodefang@126.com>
On Fri, Dec 25 2020 at 1:48am -0500,
Defang Bo <bodefang@126.com> wrote:
> Similar to commit<70de2cbd>,there should be a check for argc and argv to prevent Null pointer dereferencing
> when the dm_get_device invoked twice on the same device path with differnt mode.
>
> Signed-off-by: Defang Bo <bodefang@126.com>
> ---
> drivers/md/dm-snap.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
> index 4668b2c..dccce8b 100644
> --- a/drivers/md/dm-snap.c
> +++ b/drivers/md/dm-snap.c
> @@ -1258,6 +1258,13 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
>
> as.argc = argc;
> as.argv = argv;
> +
> + if (!strcmp(argv[0], argv[1])) {
> + ti->error = "Error setting metadata or data device";
> + r = -EINVAL;
> + goto bad;
> + }
> +
> dm_consume_args(&as, 4);
> r = parse_snapshot_features(&as, s, ti);
> if (r)
> --
> 2.7.4
>
We already have this later in snapshot_ctr:
if (cow_dev && cow_dev == origin_dev) {
ti->error = "COW device cannot be the same as origin device";
r = -EINVAL;
goto bad_cow;
}
Which happens before the 2nd dm_get_device() for the cow device. So
I'm not seeing how you could experience the NULL pointer you say is
possible.
Mike
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
WARNING: multiple messages have this Message-ID (diff)
From: Mike Snitzer <snitzer@redhat.com>
To: Defang Bo <bodefang@126.com>
Cc: agk@redhat.com, linux-kernel@vger.kernel.org, dm-devel@redhat.com
Subject: Re: dm snap : add sanity checks to snapshot_ctr
Date: Mon, 4 Jan 2021 15:27:50 -0500 [thread overview]
Message-ID: <20210104202749.GA3721@redhat.com> (raw)
In-Reply-To: <1608878926-2283057-1-git-send-email-bodefang@126.com>
On Fri, Dec 25 2020 at 1:48am -0500,
Defang Bo <bodefang@126.com> wrote:
> Similar to commit<70de2cbd>,there should be a check for argc and argv to prevent Null pointer dereferencing
> when the dm_get_device invoked twice on the same device path with differnt mode.
>
> Signed-off-by: Defang Bo <bodefang@126.com>
> ---
> drivers/md/dm-snap.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
> index 4668b2c..dccce8b 100644
> --- a/drivers/md/dm-snap.c
> +++ b/drivers/md/dm-snap.c
> @@ -1258,6 +1258,13 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
>
> as.argc = argc;
> as.argv = argv;
> +
> + if (!strcmp(argv[0], argv[1])) {
> + ti->error = "Error setting metadata or data device";
> + r = -EINVAL;
> + goto bad;
> + }
> +
> dm_consume_args(&as, 4);
> r = parse_snapshot_features(&as, s, ti);
> if (r)
> --
> 2.7.4
>
We already have this later in snapshot_ctr:
if (cow_dev && cow_dev == origin_dev) {
ti->error = "COW device cannot be the same as origin device";
r = -EINVAL;
goto bad_cow;
}
Which happens before the 2nd dm_get_device() for the cow device. So
I'm not seeing how you could experience the NULL pointer you say is
possible.
Mike
next prev parent reply other threads:[~2021-01-04 20:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-25 6:48 [PATCH] dm snap : add sanity checks to snapshot_ctr Defang Bo
2021-01-04 20:27 ` Mike Snitzer [this message]
2021-01-04 20:27 ` Mike Snitzer
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=20210104202749.GA3721@redhat.com \
--to=snitzer@redhat.com \
--cc=agk@redhat.com \
--cc=bodefang@126.com \
--cc=dm-devel@redhat.com \
--cc=linux-kernel@vger.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 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.