mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-27 22:24:11 +08:00
nvmet: lock config semaphore when accessing DH-HMAC-CHAP key
When the DH-HMAC-CHAP key is accessed via configfs we need to take the config semaphore as a reconnect might be running at the same time. Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Daniel Wagner <dwagner@suse.de> Signed-off-by: Keith Busch <kbusch@kernel.org>
This commit is contained in:
parent
6ad0d7e0f4
commit
213cbada7b
@ -44,6 +44,7 @@ int nvmet_auth_set_key(struct nvmet_host *host, const char *secret,
|
||||
dhchap_secret = kstrdup(secret, GFP_KERNEL);
|
||||
if (!dhchap_secret)
|
||||
return -ENOMEM;
|
||||
down_write(&nvmet_config_sem);
|
||||
if (set_ctrl) {
|
||||
kfree(host->dhchap_ctrl_secret);
|
||||
host->dhchap_ctrl_secret = strim(dhchap_secret);
|
||||
@ -53,6 +54,7 @@ int nvmet_auth_set_key(struct nvmet_host *host, const char *secret,
|
||||
host->dhchap_secret = strim(dhchap_secret);
|
||||
host->dhchap_key_hash = key_hash;
|
||||
}
|
||||
up_write(&nvmet_config_sem);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1990,11 +1990,17 @@ static struct config_group nvmet_ports_group;
|
||||
static ssize_t nvmet_host_dhchap_key_show(struct config_item *item,
|
||||
char *page)
|
||||
{
|
||||
u8 *dhchap_secret = to_host(item)->dhchap_secret;
|
||||
u8 *dhchap_secret;
|
||||
ssize_t ret;
|
||||
|
||||
down_read(&nvmet_config_sem);
|
||||
dhchap_secret = to_host(item)->dhchap_secret;
|
||||
if (!dhchap_secret)
|
||||
return sprintf(page, "\n");
|
||||
return sprintf(page, "%s\n", dhchap_secret);
|
||||
ret = sprintf(page, "\n");
|
||||
else
|
||||
ret = sprintf(page, "%s\n", dhchap_secret);
|
||||
up_read(&nvmet_config_sem);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t nvmet_host_dhchap_key_store(struct config_item *item,
|
||||
@ -2018,10 +2024,16 @@ static ssize_t nvmet_host_dhchap_ctrl_key_show(struct config_item *item,
|
||||
char *page)
|
||||
{
|
||||
u8 *dhchap_secret = to_host(item)->dhchap_ctrl_secret;
|
||||
ssize_t ret;
|
||||
|
||||
down_read(&nvmet_config_sem);
|
||||
dhchap_secret = to_host(item)->dhchap_ctrl_secret;
|
||||
if (!dhchap_secret)
|
||||
return sprintf(page, "\n");
|
||||
return sprintf(page, "%s\n", dhchap_secret);
|
||||
ret = sprintf(page, "\n");
|
||||
else
|
||||
ret = sprintf(page, "%s\n", dhchap_secret);
|
||||
up_read(&nvmet_config_sem);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t nvmet_host_dhchap_ctrl_key_store(struct config_item *item,
|
||||
|
Loading…
Reference in New Issue
Block a user