Skip to content

Commit d381de7

Browse files
Yuuoniygregkh
authored andcommitted
xtensa: simdisk: add input size check in proc_write_simdisk
commit 5d5f08f upstream. A malicious user could pass an arbitrarily bad value to memdup_user_nul(), potentially causing kernel crash. This follows the same pattern as commit ee76746 ("netdevsim: prevent bad user input in nsim_dev_health_break_write()") Fixes: b6c7e87 ("xtensa: ISS: add host file-based simulated disk") Fixes: 16e5c1f ("convert a bunch of open-coded instances of memdup_user_nul()") Cc: stable@vger.kernel.org Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Message-Id: <20250829083015.1992751-1-linmq006@gmail.com> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e3c5ac6 commit d381de7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

arch/xtensa/platforms/iss/simdisk.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,14 @@ static ssize_t proc_read_simdisk(struct file *file, char __user *buf,
230230
static ssize_t proc_write_simdisk(struct file *file, const char __user *buf,
231231
size_t count, loff_t *ppos)
232232
{
233-
char *tmp = memdup_user_nul(buf, count);
233+
char *tmp;
234234
struct simdisk *dev = pde_data(file_inode(file));
235235
int err;
236236

237+
if (count == 0 || count > PAGE_SIZE)
238+
return -EINVAL;
239+
240+
tmp = memdup_user_nul(buf, count);
237241
if (IS_ERR(tmp))
238242
return PTR_ERR(tmp);
239243

0 commit comments

Comments
 (0)