提交 7b915752 编写于 作者: J James Smart 提交者: Zheng Zengkai

scsi: lpfc: Prevent buffer overflow crashes in debugfs with malformed user input

stable inclusion
from stable-v5.10.138
commit c29a4baaad38a332c0ae480cf6d6c5bf75ac1828
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I60QFD

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=c29a4baaad38a332c0ae480cf6d6c5bf75ac1828

--------------------------------

[ Upstream commit f8191d40 ]

Malformed user input to debugfs results in buffer overflow crashes.  Adapt
input string lengths to fit within internal buffers, leaving space for NULL
terminators.

Link: https://lore.kernel.org/r/20220701211425.2708-3-jsmart2021@gmail.comCo-developed-by: NJustin Tee <justin.tee@broadcom.com>
Signed-off-by: NJustin Tee <justin.tee@broadcom.com>
Signed-off-by: NJames Smart <jsmart2021@gmail.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 3853f101
...@@ -2609,8 +2609,8 @@ lpfc_debugfs_multixripools_write(struct file *file, const char __user *buf, ...@@ -2609,8 +2609,8 @@ lpfc_debugfs_multixripools_write(struct file *file, const char __user *buf,
struct lpfc_sli4_hdw_queue *qp; struct lpfc_sli4_hdw_queue *qp;
struct lpfc_multixri_pool *multixri_pool; struct lpfc_multixri_pool *multixri_pool;
if (nbytes > 64) if (nbytes > sizeof(mybuf) - 1)
nbytes = 64; nbytes = sizeof(mybuf) - 1;
memset(mybuf, 0, sizeof(mybuf)); memset(mybuf, 0, sizeof(mybuf));
...@@ -2690,8 +2690,8 @@ lpfc_debugfs_nvmestat_write(struct file *file, const char __user *buf, ...@@ -2690,8 +2690,8 @@ lpfc_debugfs_nvmestat_write(struct file *file, const char __user *buf,
if (!phba->targetport) if (!phba->targetport)
return -ENXIO; return -ENXIO;
if (nbytes > 64) if (nbytes > sizeof(mybuf) - 1)
nbytes = 64; nbytes = sizeof(mybuf) - 1;
memset(mybuf, 0, sizeof(mybuf)); memset(mybuf, 0, sizeof(mybuf));
...@@ -2828,8 +2828,8 @@ lpfc_debugfs_ioktime_write(struct file *file, const char __user *buf, ...@@ -2828,8 +2828,8 @@ lpfc_debugfs_ioktime_write(struct file *file, const char __user *buf,
char mybuf[64]; char mybuf[64];
char *pbuf; char *pbuf;
if (nbytes > 64) if (nbytes > sizeof(mybuf) - 1)
nbytes = 64; nbytes = sizeof(mybuf) - 1;
memset(mybuf, 0, sizeof(mybuf)); memset(mybuf, 0, sizeof(mybuf));
...@@ -2956,8 +2956,8 @@ lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf, ...@@ -2956,8 +2956,8 @@ lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf,
char mybuf[64]; char mybuf[64];
char *pbuf; char *pbuf;
if (nbytes > 63) if (nbytes > sizeof(mybuf) - 1)
nbytes = 63; nbytes = sizeof(mybuf) - 1;
memset(mybuf, 0, sizeof(mybuf)); memset(mybuf, 0, sizeof(mybuf));
...@@ -3062,8 +3062,8 @@ lpfc_debugfs_hdwqstat_write(struct file *file, const char __user *buf, ...@@ -3062,8 +3062,8 @@ lpfc_debugfs_hdwqstat_write(struct file *file, const char __user *buf,
char *pbuf; char *pbuf;
int i; int i;
if (nbytes > 64) if (nbytes > sizeof(mybuf) - 1)
nbytes = 64; nbytes = sizeof(mybuf) - 1;
memset(mybuf, 0, sizeof(mybuf)); memset(mybuf, 0, sizeof(mybuf));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册