powerpc/pseries: add input size check in ofdt_write
Subsystems (2)
PATCH 1/1 powerpc/pseries: add input size check in ofdt_write
A malicious user could pass an arbitrarily bad value to memdup_user_nul(), potentially causing kernel crash.
This follows the same pattern as commit ee76746387f6 ("netdevsim: prevent bad user input in nsim_dev_health_break_write()")
Found via static analysis and code review.
Fixes 3783225130f0 ("powerpc/pseries: use memdup_user_nul")
Signed-off-by Miaoqian Lin <[email protected]>
--- arch/powerpc/platforms/pseries/reconfig.c | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/platforms/pseries/reconfig.c +3 -0
@@ -366,6 +366,9 @@ static ssize_t ofdt_write(struct file *file, const char __user *buf, size_t counif (rv)return rv; +if (count ==0 || count >PAGE_SIZE ) +return -EINVAL ; + kbuf =memdup_user_nul (buf, count);if (IS_ERR (kbuf))return PTR_ERR (kbuf);
Signature · 1 line
2.39.5 (Apple Git-154)