Skip to contentSkip to conversation

target/iscsi: set auth_protocol back to NULL if CHAP_A value is not supported.

PATCH Superseded Maurizio Lombardi 1 participant 2 messages Jun 26, 2019 SCSI target

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/iscsi: set auth_protocol back to NULL if CHAP_A value is not supported.

If the CHAP_A value is not supported, the chap_server_open() function should free the auth_protocol pointer and set it to NULL, or we will leave a dangling pointer around.

[   66.010905] Unsupported CHAP_A value
[   66.011660] Security negotiation failed.
[   66.012443] iSCSI Login negotiation failed.
[   68.413924] general protection fault: 0000 [#1] SMP PTI
[   68.414962] CPU: 0 PID: 1562 Comm: targetcli Kdump: loaded Not tainted 4.18.0-80.el8.x86_64 #1
[   68.416589] Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
[   68.417677] RIP: 0010:__kmalloc_track_caller+0xc2/0x210
---
 drivers/target/iscsi/iscsi_target_auth.c | 1 +
 1 file changed, 1 insertion(+)
drivers/target/iscsi/iscsi_target_auth.c +1 -0
index b6e4862cc242..139abb19da43 100644
@@ -119,6 +119,7 @@ static struct iscsi_chap *chap_server_open(
 	default:
 		pr_err("Unsupported CHAP_A value\n");
 		kfree(conn->auth_protocol);
+		conn->auth_protocol = NULL;
 		return NULL;
 	}
 
Signature · 1 line
Maurizio Lombardi
#1 lore raw

I found another dangling pointer, see V2

Dne 26.6.2019 v 17:48 Maurizio Lombardi napsal(a):

Quoted 30 lines

If the CHAP_A value is not supported, the chap_server_open() function should free the auth_protocol pointer and set it to NULL, or we will leave a dangling pointer around.

[   66.010905] Unsupported CHAP_A value
[   66.011660] Security negotiation failed.
[   66.012443] iSCSI Login negotiation failed.
[   68.413924] general protection fault: 0000 [#1] SMP PTI
[   68.414962] CPU: 0 PID: 1562 Comm: targetcli Kdump: loaded Not tainted 4.18.0-80.el8.x86_64 #1
[   68.416589] Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
[   68.417677] RIP: 0010:__kmalloc_track_caller+0xc2/0x210
---
 drivers/target/iscsi/iscsi_target_auth.c | 1 +
 1 file changed, 1 insertion(+)
drivers/target/iscsi/iscsi_target_auth.c +1 -0
index b6e4862cc242..139abb19da43 100644
@@ -119,6 +119,7 @@ static struct iscsi_chap *chap_server_open(
 	default:
 		pr_err("Unsupported CHAP_A value\n");
 		kfree(conn->auth_protocol);
+		conn->auth_protocol = NULL;
 		return NULL;
 	}