Skip to content

Commit ef65726

Browse files
committed
Merge: CVE-2024-53681 nvmet: Don't overflow subsysnqn
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/351 JIRA: https://issues.redhat.com/browse/RHEL-74084 CVE: CVE-2024-53681 Fix a memory overflow when modifying subsysnqn All submissions to CentOS Stream must reference a ticket in [Red Hat Jira](https://issues.redhat.com/). <details><summary>Click for formatting instructions</summary> Please follow the CentOS Stream [contribution documentation](https://docs.centos.org/en-US/stream-contrib/quickstart/) for how to file this ticket and have it approved. List tickets each on their own line of this description using the format "Resolves: RHEL-76229", "Related: RHEL-76229" or "Reverts: RHEL-76229", as appropriate. </details> Signed-off-by: Maurizio Lombardi <mlombard@redhat.com> Approved-by: bgurney <bgurney@redhat.com> Approved-by: Ming Lei <ming.lei@redhat.com> Approved-by: John Meneghini <jmeneghi@redhat.com> Approved-by: Ewan D. Milne <emilne@redhat.com> Approved-by: Chris Leech <cleech@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Jan Stancek <jstancek@redhat.com>
2 parents b93e021 + 0240b00 commit ef65726

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/nvme/target/configfs.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,12 +2227,17 @@ static ssize_t nvmet_root_discovery_nqn_store(struct config_item *item,
22272227
const char *page, size_t count)
22282228
{
22292229
struct list_head *entry;
2230+
char *old_nqn, *new_nqn;
22302231
size_t len;
22312232

22322233
len = strcspn(page, "\n");
22332234
if (!len || len > NVMF_NQN_FIELD_LEN - 1)
22342235
return -EINVAL;
22352236

2237+
new_nqn = kstrndup(page, len, GFP_KERNEL);
2238+
if (!new_nqn)
2239+
return -ENOMEM;
2240+
22362241
down_write(&nvmet_config_sem);
22372242
list_for_each(entry, &nvmet_subsystems_group.cg_children) {
22382243
struct config_item *item =
@@ -2241,13 +2246,15 @@ static ssize_t nvmet_root_discovery_nqn_store(struct config_item *item,
22412246
if (!strncmp(config_item_name(item), page, len)) {
22422247
pr_err("duplicate NQN %s\n", config_item_name(item));
22432248
up_write(&nvmet_config_sem);
2249+
kfree(new_nqn);
22442250
return -EINVAL;
22452251
}
22462252
}
2247-
memset(nvmet_disc_subsys->subsysnqn, 0, NVMF_NQN_FIELD_LEN);
2248-
memcpy(nvmet_disc_subsys->subsysnqn, page, len);
2253+
old_nqn = nvmet_disc_subsys->subsysnqn;
2254+
nvmet_disc_subsys->subsysnqn = new_nqn;
22492255
up_write(&nvmet_config_sem);
22502256

2257+
kfree(old_nqn);
22512258
return len;
22522259
}
22532260

0 commit comments

Comments
 (0)