target/iscsi: double free in lio_target_tiqn_addtpg()
Subsystems (2)
PATCH 1/1 target/iscsi: double free in lio_target_tiqn_addtpg()
This iscsit_tpg_add_portal_group() function is only called from lio_target_tiqn_addtpg(). Both functions free the "tpg" pointer on error so it's a double free bug. The memory is allocated in the caller so it should be freed in the caller and not here.
drivers/target/iscsi/iscsi_target_tpg.c +0 -1
@@ -260,7 +260,6 @@ int iscsit_tpg_add_portal_group(struct iscsi_tiqn *tiqn, struct iscsi_portal_groiscsi_release_param_list (tpg->param_list); tpg->param_list =NULL ; } -kfree (tpg);return -ENOMEM ; }
Quoted 13 lines · Dan Carpenter
This
iscsit_tpg_add_portal_group()function is only called fromlio_target_tiqn_addtpg(). Both functions free the "tpg" pointer on error so it's a double free bug. The memory is allocated in the caller so it should be freed in the caller and not here.Fixes e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1")Signed-off-by Dan Carpenter <[email protected]>drivers/target/iscsi/iscsi_target_tpg.c +0
-0
drivers/target/iscsi/iscsi_target_tpg.c int iscsit_tpg_add_portal_group(struct iscsi_tiqn *tiqn, struct iscsi_portal_gro · line 264
Quoted 6 lines
drivers/target/iscsi/iscsi_target_tpg.c +0
-1@@ -260,7 +260,6 @@ int iscsit_tpg_add_portal_group(struct iscsi_tiqn *tiqn, struct iscsi_portal_groiscsi_release_param_list (tpg->param_list); tpg->param_list =NULL ; } -kfree (tpg);return -ENOMEM ; }
Looks good, and works for me if I manually trigger the error path.
Quoted 7 lines · Dan Carpenter
This
iscsit_tpg_add_portal_group()function is only called fromlio_target_tiqn_addtpg(). Both functions free the "tpg" pointer on error so it's a double free bug. The memory is allocated in the caller so it should be freed in the caller and not here.Fixes e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1")Signed-off-by Dan Carpenter <[email protected]>
Hello Dan,
Do you think a "Cc: stable" tag should be added to this patch?
Bart.
Quoted 6 lines · Bart Van Assche
Quoted 5 lines · Dan Carpenter
This
iscsit_tpg_add_portal_group()function is only called fromlio_target_tiqn_addtpg(). Both functions free the "tpg" pointer on error so it's a double free bug. The memory is allocated in the caller so it should be freed in the caller and not here.
Quoted 7 lines
Quoted 2 lines
Fixes e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1")Signed-off-by Dan Carpenter <[email protected]>Hello Dan,
Do you think a "Cc: stable" tag should be added to this patch?
It will basically only fail for allocation errors. It's probably not super likely. These are static checker fixes, not something I encountered in real life.
regards,
dan carpenter
Quoted 7 lines · Dan Carpenter
Quoted 6 lines · Bart Van Assche
Quoted 5 lines · Dan Carpenter
This
iscsit_tpg_add_portal_group()function is only called fromlio_target_tiqn_addtpg(). Both functions free the "tpg" pointer on error so it's a double free bug. The memory is allocated in the caller so it should be freed in the caller and not here.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Fixes e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1")Signed-off-by Dan Carpenter <[email protected]>Do you think a "Cc: stable" tag should be added to this patch?
It will basically only fail for allocation errors. It's probably not super likely. These are static checker fixes, not something I encountered in real life.
Hello Dan,
Thanks for the patch and for the additional clarification. I have queued your patch for kernel version v4.10.
Bart.