Skip to content

Commit f299ee7

Browse files
minhbq-99kuba-moo
authored andcommitted
octeontx2-af: avoid off-by-one read from userspace
We try to access count + 1 byte from userspace with memdup_user(buffer, count + 1). However, the userspace only provides buffer of count bytes and only these count bytes are verified to be okay to access. To ensure the copied buffer is NUL terminated, we use memdup_user_nul instead. Fixes: 3a2eb51 ("octeontx2-af: Fix an off by one in rvu_dbg_qsize_write()") 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 8c34096 commit f299ee7

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -999,12 +999,10 @@ static ssize_t rvu_dbg_qsize_write(struct file *filp,
999999
u16 pcifunc;
10001000
int ret, lf;
10011001

1002-
cmd_buf = memdup_user(buffer, count + 1);
1002+
cmd_buf = memdup_user_nul(buffer, count);
10031003
if (IS_ERR(cmd_buf))
10041004
return -ENOMEM;
10051005

1006-
cmd_buf[count] = '\0';
1007-
10081006
cmd_buf_tmp = strchr(cmd_buf, '\n');
10091007
if (cmd_buf_tmp) {
10101008
*cmd_buf_tmp = '\0';

0 commit comments

Comments
 (0)