The current_value and new_password store handlers copy the input with kstrdup(), which stops at the first NUL, and then search the copy for a newline with memchr() over the full write size. If the written data contains an embedded NUL, memchr() reads past the end of the copy, and a newline found there is overwritten with a NUL byte. The copy is NUL-terminated, so use strchr() instead. This is the same issue that was fixed in hp-bioscfg by commit ea146aaac690 ("platform/x86: hp-bioscfg: fix heap OOB in hp_enforce_single_line_input()"). Fixes: e8a60aa7404b ("platform/x86: Introduce support for Systems Management Driver over WMI for Dell Systems") Cc: stable@vger.kernel.org Signed-off-by: Hyunjung Ko --- drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h | 2 +- drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h b/drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h index eb48ced55823..808ff9e70add 100644 --- a/drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h +++ b/drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h @@ -144,7 +144,7 @@ static ssize_t curr_val##_store(struct kobject *kobj, \ buf_cp = kstrdup(buf, GFP_KERNEL); \ if (!buf_cp) \ return -ENOMEM; \ - p = memchr(buf_cp, '\n', count); \ + p = strchr(buf_cp, '\n'); \ \ if (p != NULL) \ *p = '\0'; \ diff --git a/drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c b/drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c index be939b731063..9677811436bc 100644 --- a/drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c +++ b/drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c @@ -79,7 +79,7 @@ static ssize_t new_password_store(struct kobject *kobj, buf_cp = kstrdup(buf, GFP_KERNEL); if (!buf_cp) return -ENOMEM; - p = memchr(buf_cp, '\n', count); + p = strchr(buf_cp, '\n'); if (p != NULL) *p = '\0'; -- 2.43.0