mirror of
https://github.com/torvalds/linux.git
synced 2026-06-08 06:25:52 +02:00
scsi: bfa: integer overflow in debugfs
[ Upstream commit3e35127565] We could allocate less memory than intended because we do: bfad->regdata = kzalloc(len << 2, GFP_KERNEL); The shift can overflow leading to a crash. This is debugfs code so the impact is very small. I fixed the network version of this in March with commit13e2d5187f("bna: integer overflow bug in debugfs"). Fixes:ab2a9ba189("[SCSI] bfa: add debugfs support") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
798f085014
commit
a114af87c0
|
|
@ -254,7 +254,8 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
|
|||
struct bfad_s *bfad = port->bfad;
|
||||
struct bfa_s *bfa = &bfad->bfa;
|
||||
struct bfa_ioc_s *ioc = &bfa->ioc;
|
||||
int addr, len, rc, i;
|
||||
int addr, rc, i;
|
||||
u32 len;
|
||||
u32 *regbuf;
|
||||
void __iomem *rb, *reg_addr;
|
||||
unsigned long flags;
|
||||
|
|
@ -265,7 +266,7 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
|
|||
return PTR_ERR(kern_buf);
|
||||
|
||||
rc = sscanf(kern_buf, "%x:%x", &addr, &len);
|
||||
if (rc < 2) {
|
||||
if (rc < 2 || len > (UINT_MAX >> 2)) {
|
||||
printk(KERN_INFO
|
||||
"bfad[%d]: %s failed to read user buf\n",
|
||||
bfad->inst_no, __func__);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user