Skip to content

Commit 666854e

Browse files
minhbq-99kuba-moo
authored andcommitted
ice: ensure the copied buf is NUL terminated
Currently, we allocate a count-sized kernel buffer and copy count bytes from userspace to that buffer. Later, we use sscanf on this buffer but we don't ensure that the string is terminated inside the buffer, this can lead to OOB read when using sscanf. Fix this issue by using memdup_user_nul instead of memdup_user. Fixes: 96a9a93 ("ice: configure FW logging") Fixes: 73671c3 ("ice: enable FW logging") Reviewed-by: Przemek Kitszel <[email protected]> Signed-off-by: Bui Quang Minh <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 52afb15 commit 666854e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/net/ethernet/intel/ice/ice_debugfs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ ice_debugfs_module_write(struct file *filp, const char __user *buf,
171171
if (*ppos != 0 || count > 8)
172172
return -EINVAL;
173173

174-
cmd_buf = memdup_user(buf, count);
174+
cmd_buf = memdup_user_nul(buf, count);
175175
if (IS_ERR(cmd_buf))
176176
return PTR_ERR(cmd_buf);
177177

@@ -257,7 +257,7 @@ ice_debugfs_nr_messages_write(struct file *filp, const char __user *buf,
257257
if (*ppos != 0 || count > 4)
258258
return -EINVAL;
259259

260-
cmd_buf = memdup_user(buf, count);
260+
cmd_buf = memdup_user_nul(buf, count);
261261
if (IS_ERR(cmd_buf))
262262
return PTR_ERR(cmd_buf);
263263

@@ -332,7 +332,7 @@ ice_debugfs_enable_write(struct file *filp, const char __user *buf,
332332
if (*ppos != 0 || count > 2)
333333
return -EINVAL;
334334

335-
cmd_buf = memdup_user(buf, count);
335+
cmd_buf = memdup_user_nul(buf, count);
336336
if (IS_ERR(cmd_buf))
337337
return PTR_ERR(cmd_buf);
338338

@@ -428,7 +428,7 @@ ice_debugfs_log_size_write(struct file *filp, const char __user *buf,
428428
if (*ppos != 0 || count > 5)
429429
return -EINVAL;
430430

431-
cmd_buf = memdup_user(buf, count);
431+
cmd_buf = memdup_user_nul(buf, count);
432432
if (IS_ERR(cmd_buf))
433433
return PTR_ERR(cmd_buf);
434434

0 commit comments

Comments
 (0)