Skip to content

Commit 7ac243f

Browse files
Yufeng Modavem330
authored andcommitted
net: hns3: add input length check for debugfs write function
If the input length reaches the maximum value of size_t, the reverse is triggered when 1 is added. In addition, there is no need to have such a large length. Therefore, the input length should be checked and the value should be less than or equal to 1024. Signed-off-by: Yufeng Mo <[email protected]> Reviewed-by: Peng Li <[email protected]> Signed-off-by: Huazhong Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent eb977d9 commit 7ac243f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "hns3_enet.h"
99

1010
#define HNS3_DBG_READ_LEN 256
11+
#define HNS3_DBG_WRITE_LEN 1024
1112

1213
static struct dentry *hns3_dbgfs_root;
1314

@@ -322,6 +323,9 @@ static ssize_t hns3_dbg_cmd_write(struct file *filp, const char __user *buffer,
322323
test_bit(HNS3_NIC_STATE_RESETTING, &priv->state))
323324
return 0;
324325

326+
if (count > HNS3_DBG_WRITE_LEN)
327+
return -ENOSPC;
328+
325329
cmd_buf = kzalloc(count + 1, GFP_KERNEL);
326330
if (!cmd_buf)
327331
return count;

0 commit comments

Comments
 (0)