Message ID | 20240415072155.30840-1-mrangankar@marvell.com |
---|---|
State | New |
Headers | show |
Series | [v2] qedi: Fix crash while reading debugfs attribute. | expand |
Manish, > The qedi_dbg_do_not_recover_cmd_read() function invokes sprintf() > directly on a __user pointer, which results into the crash. Applied to 6.10/scsi-staging, thanks!
On Mon, 15 Apr 2024 12:51:55 +0530, Manish Rangankar wrote: > The qedi_dbg_do_not_recover_cmd_read() function invokes sprintf() > directly on a __user pointer, which results into the crash. > > To fix this issue, use a small local stack buffer for sprintf() and then > call simple_read_from_buffer(), which in turns make the copy_to_user() > call. > > [...] Applied to 6.10/scsi-queue, thanks! [1/1] qedi: Fix crash while reading debugfs attribute. https://git.kernel.org/mkp/scsi/c/28027ec8e32e
diff --git a/drivers/scsi/qedi/qedi_debugfs.c b/drivers/scsi/qedi/qedi_debugfs.c index 8deb2001dc2f..37eed6a27816 100644 --- a/drivers/scsi/qedi/qedi_debugfs.c +++ b/drivers/scsi/qedi/qedi_debugfs.c @@ -120,15 +120,11 @@ static ssize_t qedi_dbg_do_not_recover_cmd_read(struct file *filp, char __user *buffer, size_t count, loff_t *ppos) { - size_t cnt = 0; - - if (*ppos) - return 0; + char buf[64]; + int len; - cnt = sprintf(buffer, "do_not_recover=%d\n", qedi_do_not_recover); - cnt = min_t(int, count, cnt - *ppos); - *ppos += cnt; - return cnt; + len = sprintf(buf, "do_not_recover=%d\n", qedi_do_not_recover); + return simple_read_from_buffer(buffer, count, ppos, buf, len); } static int