platform/x86: dell-wmi-sysman: fix heap OOB when scanning for a newline
Subsystems (3)
PATCH 1/1 platform/x86: dell-wmi-sysman: fix heap OOB when scanning for a newline
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")
Signed-off-by Hyunjung Ko <[email protected]>
--- 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(-)
drivers/platform/x86/dell/dell-wmi-sysman/dell-wmi-sysman.h +1 -1
@@ -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' ; \
drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c +1 -1
@@ -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' ;
Signature · 1 line
2.43.0