dm: ioctl: prevent double freeing
Subsystems (2)
PATCH 1/1 dm: ioctl: prevent double freeing
DM_PARAMS_KMALLOC and DM_PARAMS_VMALLOC should never be set together in param_flags. We are setting these flags while allocating so we know that there is almost no chance of having these two set together but still we can have some additional safety.
--- drivers/md/dm-ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-ioctl.c +1 -1
@@ -1680,7 +1680,7 @@ static void free_params(struct dm_ioctl *param, size_t param_size, int param_flaif (param_flags &DM_PARAMS_KMALLOC )kfree (param); -if (param_flags &DM_PARAMS_VMALLOC ) +else if (param_flags &DM_PARAMS_VMALLOC )vfree (param); }
Signature · 1 line
1.9.1
Quoted 7 lines · Sudip Mukherjee
DM_PARAMS_KMALLOCandDM_PARAMS_VMALLOCshould never be set together inparam_flags. We are setting these flags while allocating so we know that there is almost no chance of having these two set together but still we can have some additional safety.Signed-off-by Sudip Mukherjee <[email protected]>---
A gentle ping.
regards
sudip
Quoted 15 lines · Sudip Mukherjee
DM_PARAMS_KMALLOCandDM_PARAMS_VMALLOCshould never be set together inparam_flags. We are setting these flags while allocating so we know that there is almost no chance of having these two set together but still we can have some additional safety.Signed-off-by Sudip Mukherjee <[email protected]>--- drivers/md/dm-ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/md/dm-ioctl.c +0
-0
drivers/md/dm-ioctl.c static void free_params(struct dm_ioctl *param, size_t param_size, int param_fla · line 1683
Quoted 5 lines
drivers/md/dm-ioctl.c +1
-1@@ -1680,7 +1680,7 @@ static void free_params(struct dm_ioctl *param, size_t param_size, int param_flaif (param_flags &DM_PARAMS_KMALLOC )kfree (param); -if (param_flags &DM_PARAMS_VMALLOC ) +else if (param_flags &DM_PARAMS_VMALLOC )
Wouldn't you also want a WARN_ON to complain about both flags being set?
--D
Quoted 10 lines
drivers/md/dm-ioctl.c +0
-0vfree (param); }Signature · 6 lines
1.9.1 -- dm-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/dm-devel
Quoted 17 lines · Darrick J. Wong
Quoted 16 lines · Sudip Mukherjee
DM_PARAMS_KMALLOCandDM_PARAMS_VMALLOCshould never be set together inparam_flags. We are setting these flags while allocating so we know that there is almost no chance of having these two set together but still we can have some additional safety.Signed-off-by Sudip Mukherjee <[email protected]>--- drivers/md/dm-ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/md/dm-ioctl.c +0
-0@@ -1680,7 +1680,7 @@ static void free_params(struct dm_ioctl *param, size_t param_size, int param_fla
Quoted 6 lines
drivers/md/dm-ioctl.c static void free_params(struct dm_ioctl *param, size_t param_size, int param_fla · line 1683
Quoted 4 lines
drivers/md/dm-ioctl.c +1
-1if (param_flags &DM_PARAMS_KMALLOC )kfree (param); -if (param_flags &DM_PARAMS_VMALLOC ) +else if (param_flags &DM_PARAMS_VMALLOC )Wouldn't you also want a
WARN_ONto complain about both flags being set?
No, this is getting rediculous now. Please stop the insanity.
DM_PARAMS_KMALLOC and DM_PARAMS_VMALLOC are mutually exclussive -- always will be. Sprinkling defensive code around isn't high on my list of changes I'm interested in.
At some point I'll stage the original change from Sudip for 4.4 but I'm re-writing the subject and header to not be so alarmist (this is more to do with eliminating a conditional than anything else). There is _zero_ potential for a double-free with the current code.
Mike