fix NULL pointer in dm_exception_store_create() when create dm device
Subsystems (3)
PATCH 1/1 fix NULL pointer in dm_exception_store_create() when create dm device
In some conditions(such as umount fs failed),origin path or origin bdev or both of the two is same as cow's.If this happens, origin dev will be freed when get cow dev in function "dm_get_device" , then "s->origin->dev" which used by "dm_exception_store_create" will be a NULL pointer.
--- drivers/md/dm-snap.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
drivers/md/dm-snap.c +10 -0
@@ -1102,6 +1102,7 @@ static void stop_merge(struct dm_snapshot *s)static int snapshot_ctr (struct dm_target *ti,unsigned int argc,char **argv) {struct dm_snapshot *s; +struct block_device *origin_bdev, *cow_bdev;int i;int r = -EINVAL ;char *origin_path, *cow_path;
@@ -1136,10 +1137,19 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) goto bad_origin; } + origin_bdev = s->origin->bdev; cow_path = argv[0 ]; argv++; argc--; +/*check cow dev is available*/ + cow_bdev =lookup_bdev (cow_path); +if (cow_bdev->bd_dev == origin_bdev->bd_dev){ + ti->error ="Invalid COW device" ; + r = -EINVAL ; + goto bad_cow; + } + r =dm_get_device (ti, cow_path,dm_table_get_mode (ti->table), &s->cow);if (r) { ti->error ="Cannot get COW device" ;
Signature · 1 line
1.7.1
Quoted 8 lines · DingXiang
In some conditions(such as umount fs failed),origin path or origin bdev or both of the two is same as cow's.If this happens, origin dev will be freed when get cow dev in function "
dm_get_device" , then "s->origin->dev" which used by "dm_exception_store_create" will be a NULL pointer.Signed-off-by Ding Xiang <[email protected]>--- drivers/md/dm-snap.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read Documentation/stable_kernel_rules.txt for how to do this properly.
</formletter>