Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: 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

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Reviewed-by: Chris Leech <cleech@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Maurizio Lombardi and committed by
Martin K. Petersen
5dd6c493 5676234f

+8 -8
+8 -8
drivers/target/iscsi/iscsi_target_auth.c
··· 89 89 return CHAP_DIGEST_UNKNOWN; 90 90 } 91 91 92 + static void chap_close(struct iscsi_conn *conn) 93 + { 94 + kfree(conn->auth_protocol); 95 + conn->auth_protocol = NULL; 96 + } 97 + 92 98 static struct iscsi_chap *chap_server_open( 93 99 struct iscsi_conn *conn, 94 100 struct iscsi_node_auth *auth, ··· 132 126 case CHAP_DIGEST_UNKNOWN: 133 127 default: 134 128 pr_err("Unsupported CHAP_A value\n"); 135 - kfree(conn->auth_protocol); 129 + chap_close(conn); 136 130 return NULL; 137 131 } 138 132 ··· 147 141 * Generate Challenge. 148 142 */ 149 143 if (chap_gen_challenge(conn, 1, aic_str, aic_len) < 0) { 150 - kfree(conn->auth_protocol); 144 + chap_close(conn); 151 145 return NULL; 152 146 } 153 147 154 148 return chap; 155 - } 156 - 157 - static void chap_close(struct iscsi_conn *conn) 158 - { 159 - kfree(conn->auth_protocol); 160 - conn->auth_protocol = NULL; 161 149 } 162 150 163 151 static int chap_server_compute_md5(