* [PATCH] dm snap : add sanity checks to snapshot_ctr
@ 2020-12-25 6:48 Defang Bo
2021-01-04 20:27 ` Mike Snitzer
0 siblings, 1 reply; 2+ messages in thread
From: Defang Bo @ 2020-12-25 6:48 UTC (permalink / raw)
To: agk, snitzer; +Cc: linux-kernel, Defang Bo
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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: dm snap : add sanity checks to snapshot_ctr
2020-12-25 6:48 [PATCH] dm snap : add sanity checks to snapshot_ctr Defang Bo
@ 2021-01-04 20:27 ` Mike Snitzer
0 siblings, 0 replies; 2+ messages in thread
From: Mike Snitzer @ 2021-01-04 20:27 UTC (permalink / raw)
To: Defang Bo; +Cc: agk, linux-kernel, dm-devel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-04 20:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-25 6:48 [PATCH] dm snap : add sanity checks to snapshot_ctr Defang Bo
2021-01-04 20:27 ` Mike Snitzer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox